@Override
  public void serialize(DataOutputStream stream) throws IOException {
    super.serialize(stream);

    // Ensure that the Size does not differ from the actual length during the reading process
    final ArrayList<Integer> copyStates = new ArrayList<>(states);
    stream.writeInt(copyStates.size());
    for (int state : copyStates) {
      stream.writeInt(state);
    }
  }
Set the next state for the procedure.

@param stateId the ordinal() of the state enum (or state id)
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/StateMachineProcedure.java