code: public static <T extends State> void serializeState(FileSystem fs, Path jobStateFilePath, T state, short replication)
        throws IOException {
  
      try (DataOutputStream dataOutputStream = new DataOutputStream(fs.create(jobStateFilePath, replication))) {
        state.write(dataOutputStream);
      }
    }
docs: Serialize a {@link State} instance to a file.
  
  @param fs the {@link FileSystem} instance for creating the file
  @param jobStateFilePath the path to the file
  @param state the {@link State} to serialize
  @param replication replication of the serialized file.
  @param <T> the {@link State} object type
  @throws IOException if it fails to serialize the {@link State} instance