public static void writeSegmentDescriptor(final FileSystem outputFS,
      final DataSegment segment,
      final Path descriptorPath) throws IOException {
    final DataPusher descriptorPusher = (DataPusher) RetryProxy.create(DataPusher.class, () -> {
      if (outputFS.exists(descriptorPath)) {
        if (!outputFS.delete(descriptorPath, false)) {
          throw new IOException(String.format("Failed to delete descriptor at [%s]", descriptorPath));
        }
      }
      try (final OutputStream descriptorOut = outputFS.create(descriptorPath, true, DEFAULT_FS_BUFFER_SIZE)) {
        JSON_MAPPER.writeValue(descriptorOut, segment);
        descriptorOut.flush();
      }
    }, RetryPolicies.exponentialBackoffRetry(NUM_RETRIES, SECONDS_BETWEEN_RETRIES, TimeUnit.SECONDS));
    descriptorPusher.push();
  }
Writes to filesystem serialized form of segment descriptor if an existing file exists it will try to replace it.

@param outputFS       filesystem.
@param segment        DataSegment object.
@param descriptorPath path.
@throws IOException in case any IO issues occur.
druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandlerUtils.java