test_class.declarator: mockExecutorService
test_class.modifier: @Mock private
test_class.original_string: @Mock private ExecutorService mockExecutorService;
test_class.type: ExecutorService
test_class.var_name: mockExecutorService
test_class.declarator: ghfs
test_class.modifier: private
test_class.original_string: private GoogleHadoopFileSystemBase ghfs;
test_class.type: GoogleHadoopFileSystemBase
test_class.var_name: ghfs
test_class.file: gcs/src/test/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopSyncableOutputStreamTest.java
test_class.identifier: GoogleHadoopSyncableOutputStreamTest
test_case.body: @Test
    public void testCloseTwice() throws IOException {
      Path objectPath = new Path(ghfs.getFileSystemRoot(), "dir/object.txt");
      FSDataOutputStream fout = ghfs.create(objectPath);
      fout.close();
      fout.close();  // Fine to close twice.
    }
test_case.class_method_signature: GoogleHadoopSyncableOutputStreamTest.testCloseTwice()
test_case.full_signature: @Test public void testCloseTwice()
test_case.identifier: testCloseTwice
test_case.invocations: getFileSystemRoot create close close
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCloseTwice()
focal_class.declarator: logger = GoogleLogger.forEnclosingClass()
focal_class.modifier: private static final
focal_class.original_string: private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
focal_class.type: GoogleLogger
focal_class.var_name: logger
focal_class.declarator: TEMPFILE_PREFIX = "_GCS_SYNCABLE_TEMPFILE_"
focal_class.modifier: public static final
focal_class.original_string: public static final String TEMPFILE_PREFIX = "_GCS_SYNCABLE_TEMPFILE_";
focal_class.type: String
focal_class.var_name: TEMPFILE_PREFIX
focal_class.declarator: TEMPFILE_CREATE_OPTIONS =
        CreateFileOptions.DEFAULT_NO_OVERWRITE.toBuilder()
            .setEnsureNoDirectoryConflict(false)
            .setEnsureParentDirectoriesExist(false)
            .setOverwriteGenerationId(0)
            .build()
focal_class.modifier: private static final
focal_class.original_string: private static final CreateFileOptions TEMPFILE_CREATE_OPTIONS =
        CreateFileOptions.DEFAULT_NO_OVERWRITE.toBuilder()
            .setEnsureNoDirectoryConflict(false)
            .setEnsureParentDirectoriesExist(false)
            .setOverwriteGenerationId(0)
            .build();
focal_class.type: CreateFileOptions
focal_class.var_name: TEMPFILE_CREATE_OPTIONS
focal_class.declarator: TEMPFILE_CLEANUP_THREADPOOL =
        Executors.newCachedThreadPool(
            new ThreadFactoryBuilder()
                .setNameFormat("gcs-syncable-output-stream-cleanup-pool-%d")
                .setDaemon(true)
                .build())
focal_class.modifier: private static final
focal_class.original_string: private static final ExecutorService TEMPFILE_CLEANUP_THREADPOOL =
        Executors.newCachedThreadPool(
            new ThreadFactoryBuilder()
                .setNameFormat("gcs-syncable-output-stream-cleanup-pool-%d")
                .setDaemon(true)
                .build());
focal_class.type: ExecutorService
focal_class.var_name: TEMPFILE_CLEANUP_THREADPOOL
focal_class.declarator: ghfs
focal_class.modifier: private final
focal_class.original_string: private final GoogleHadoopFileSystemBase ghfs;
focal_class.type: GoogleHadoopFileSystemBase
focal_class.var_name: ghfs
focal_class.declarator: finalGcsPath
focal_class.modifier: private final
focal_class.original_string: private final URI finalGcsPath;
focal_class.type: URI
focal_class.var_name: finalGcsPath
focal_class.declarator: statistics
focal_class.modifier: private final
focal_class.original_string: private final FileSystem.Statistics statistics;
focal_class.type: FileSystem.Statistics
focal_class.var_name: statistics
focal_class.declarator: fileOptions
focal_class.modifier: private final
focal_class.original_string: private final CreateFileOptions fileOptions;
focal_class.type: CreateFileOptions
focal_class.var_name: fileOptions
focal_class.declarator: deletionFutures
focal_class.modifier: private final
focal_class.original_string: private final List<Future<Void>> deletionFutures;
focal_class.type: List<Future<Void>>
focal_class.var_name: deletionFutures
focal_class.declarator: options
focal_class.modifier: private final
focal_class.original_string: private final SyncableOutputStreamOptions options;
focal_class.type: SyncableOutputStreamOptions
focal_class.var_name: options
focal_class.declarator: syncRateLimiter
focal_class.modifier: private final
focal_class.original_string: private final RateLimiter syncRateLimiter;
focal_class.type: RateLimiter
focal_class.var_name: syncRateLimiter
focal_class.declarator: cleanupThreadpool
focal_class.modifier: private final
focal_class.original_string: private final ExecutorService cleanupThreadpool;
focal_class.type: ExecutorService
focal_class.var_name: cleanupThreadpool
focal_class.declarator: curGcsPath
focal_class.modifier: private
focal_class.original_string: private URI curGcsPath;
focal_class.type: URI
focal_class.var_name: curGcsPath
focal_class.declarator: curDelegate
focal_class.modifier: private
focal_class.original_string: private GoogleHadoopOutputStream curDelegate;
focal_class.type: GoogleHadoopOutputStream
focal_class.var_name: curDelegate
focal_class.declarator: curComponentIndex
focal_class.modifier: private
focal_class.original_string: private int curComponentIndex;
focal_class.type: int
focal_class.var_name: curComponentIndex
focal_class.declarator: curDestGenerationId
focal_class.modifier: private
focal_class.original_string: private long curDestGenerationId;
focal_class.type: long
focal_class.var_name: curDestGenerationId
focal_class.file: gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopSyncableOutputStream.java
focal_class.identifier: GoogleHadoopSyncableOutputStream
focal_class.interfaces: implements Syncable
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options)
focal_class.full_signature: public  GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options)
focal_class.identifier: GoogleHadoopSyncableOutputStream
focal_class.modifiers: public
focal_class.parameters: (
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options)
focal_class.signature:  GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options,
        ExecutorService cleanupThreadpool)
focal_class.full_signature: @VisibleForTesting  GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options,
        ExecutorService cleanupThreadpool)
focal_class.identifier: GoogleHadoopSyncableOutputStream
focal_class.modifiers: @VisibleForTesting
focal_class.parameters: (
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options,
        ExecutorService cleanupThreadpool)
focal_class.signature:  GoogleHadoopSyncableOutputStream(
        GoogleHadoopFileSystemBase ghfs,
        URI gcsPath,
        FileSystem.Statistics statistics,
        CreateFileOptions createFileOptions,
        SyncableOutputStreamOptions options,
        ExecutorService cleanupThreadpool)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.createRateLimiter(Duration minSyncInterval)
focal_class.full_signature: private static RateLimiter createRateLimiter(Duration minSyncInterval)
focal_class.identifier: createRateLimiter
focal_class.modifiers: private static
focal_class.parameters: (Duration minSyncInterval)
focal_class.return: RateLimiter
focal_class.signature: RateLimiter createRateLimiter(Duration minSyncInterval)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.write(int b)
focal_class.full_signature: @Override public void write(int b)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (int b)
focal_class.return: void
focal_class.signature: void write(int b)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.write(byte[] b, int offset, int len)
focal_class.full_signature: @Override public void write(byte[] b, int offset, int len)
focal_class.identifier: write
focal_class.modifiers: @Override public
focal_class.parameters: (byte[] b, int offset, int len)
focal_class.return: void
focal_class.signature: void write(byte[] b, int offset, int len)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.sync()
focal_class.full_signature: public void sync()
focal_class.identifier: sync
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void sync()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.hflush()
focal_class.full_signature: @Override public void hflush()
focal_class.identifier: hflush
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void hflush()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.hsync()
focal_class.full_signature: @Override public void hsync()
focal_class.identifier: hsync
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void hsync()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.hsyncInternal(long startTimeNs)
focal_class.full_signature: private void hsyncInternal(long startTimeNs)
focal_class.identifier: hsyncInternal
focal_class.modifiers: private
focal_class.parameters: (long startTimeNs)
focal_class.return: void
focal_class.signature: void hsyncInternal(long startTimeNs)
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.commitCurrentFile()
focal_class.full_signature: private void commitCurrentFile()
focal_class.identifier: commitCurrentFile
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void commitCurrentFile()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.getNextTemporaryPath()
focal_class.full_signature: private URI getNextTemporaryPath()
focal_class.identifier: getNextTemporaryPath
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: URI
focal_class.signature: URI getNextTemporaryPath()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.isOpen()
focal_class.full_signature: private boolean isOpen()
focal_class.identifier: isOpen
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isOpen()
focal_class.class_method_signature: GoogleHadoopSyncableOutputStream.throwIfNotOpen()
focal_class.full_signature: private void throwIfNotOpen()
focal_class.identifier: throwIfNotOpen
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void throwIfNotOpen()
focal_class.superclass: extends OutputStream
focal_method.body: @Override
    public void close() throws IOException {
      logger.atFine().log(
          "close(): Current tail file: %s final destination: %s", curGcsPath, finalGcsPath);
      if (!isOpen()) {
        logger.atFinest().log("close(): Ignoring; stream already closed.");
        return;
      }
      commitCurrentFile();
  
      // null denotes stream closed.
      // TODO(user): Add checks which throw IOException if further operations are attempted on a
      // closed stream, except for multiple calls to close(), which should behave as no-ops.
      curGcsPath = null;
      curDelegate = null;
  
      logger.atFine().log("close(): Awaiting %s deletionFutures", deletionFutures.size());
      for (Future<?> deletion : deletionFutures) {
        try {
          deletion.get();
        } catch (ExecutionException | InterruptedException e) {
          if (e instanceof InterruptedException) {
            Thread.currentThread().interrupt();
          }
          throw new IOException("Failed to delete files while closing stream", e);
        }
      }
    }
focal_method.class_method_signature: GoogleHadoopSyncableOutputStream.close()
focal_method.full_signature: @Override public void close()
focal_method.identifier: close
focal_method.invocations: log atFine isOpen log atFinest commitCurrentFile log atFine size get interrupt currentThread
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void close()