diff --git a/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageEventSubscriber.java b/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageEventSubscriber.java index 4552e2f33..588cfd830 100644 --- a/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageEventSubscriber.java +++ b/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageEventSubscriber.java @@ -28,9 +28,11 @@ /* Stores the subscriber methods corresponding to GoogleCloudStorageEventBus */ public class GoogleCloudStorageEventSubscriber { + private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); private static GhfsGlobalStorageStatistics storageStatistics; + private static GoogleCloudStorageEventSubscriber INSTANCE = null; - public GoogleCloudStorageEventSubscriber(GhfsGlobalStorageStatistics storageStatistics) { + private GoogleCloudStorageEventSubscriber(GhfsGlobalStorageStatistics storageStatistics) { this.storageStatistics = storageStatistics; } @@ -38,7 +40,7 @@ public GoogleCloudStorageEventSubscriber(GhfsGlobalStorageStatistics storageStat * Singleton class such that registration of subscriber methods is only once. * */ public static synchronized GoogleCloudStorageEventSubscriber getInstance( - @Nonnull GhfsStorageStatistics storageStatistics) { + @Nonnull GhfsGlobalStorageStatistics storageStatistics) { if (INSTANCE == null) { logger.atFiner().log("Subscriber class invoked for first time"); INSTANCE = new GoogleCloudStorageEventSubscriber(storageStatistics); diff --git a/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystem.java b/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystem.java index 018f193fb..c147a7ed2 100644 --- a/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystem.java +++ b/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystem.java @@ -250,7 +250,7 @@ public GoogleHadoopFileSystem() { } GoogleCloudStorageEventBus.register( - new GoogleCloudStorageEventSubscriber(globalStorageStatistics)); + GoogleCloudStorageEventSubscriber.getInstance(globalStorageStatistics)); } /** diff --git a/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystemBase.java b/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystemBase.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/gcs/src/test/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageStatisticsTest.java b/gcs/src/test/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageStatisticsTest.java index 1fe709a58..3c82800b9 100644 --- a/gcs/src/test/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageStatisticsTest.java +++ b/gcs/src/test/java/com/google/cloud/hadoop/fs/gcs/GoogleCloudStorageStatisticsTest.java @@ -89,7 +89,7 @@ public void test_multiple_register_of_statistics() throws Exception { GoogleCloudStorageEventSubscriber.getInstance(storageStatistics)); GoogleCloudStorageEventBus.onGcsRequest(new GcsRequestExecutionEvent()); - GhfsStorageStatistics verifyCounterStats = new GhfsStorageStatistics(); + GhfsGlobalStorageStatistics verifyCounterStats = new GhfsGlobalStorageStatistics(); verifyCounterStats.incrementCounter(GCS_API_REQUEST_COUNT, 1); verifyStatistics(verifyCounterStats); }