storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [1/4] storm git commit: STORM-2266 Close NimbusClient instances appropriately
Date Tue, 03 Jan 2017 14:31:57 GMT
Repository: storm
Updated Branches:
  refs/heads/1.x-branch 4d882dc0a -> 0d40546a9


STORM-2266 Close NimbusClient instances appropriately


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/f8e8292f
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/f8e8292f
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/f8e8292f

Branch: refs/heads/1.x-branch
Commit: f8e8292f8f8ff2275ade4ea08b740853c8aa503e
Parents: 8ab0285
Author: Satish Duggana <sduggana@hortonworks.com>
Authored: Thu Dec 29 12:54:43 2016 +0530
Committer: Satish Duggana <sduggana@hortonworks.com>
Committed: Thu Dec 29 12:54:43 2016 +0530

----------------------------------------------------------------------
 .../apache/storm/hdfs/blobstore/HdfsClientBlobStore.java    | 7 ++++++-
 storm-core/src/jvm/org/apache/storm/StormSubmitter.java     | 5 +----
 .../src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java  | 8 ++------
 storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java | 9 +--------
 4 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/f8e8292f/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/blobstore/HdfsClientBlobStore.java
----------------------------------------------------------------------
diff --git a/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/blobstore/HdfsClientBlobStore.java
b/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/blobstore/HdfsClientBlobStore.java
index 1fc80d0..d88211c 100644
--- a/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/blobstore/HdfsClientBlobStore.java
+++ b/external/storm-hdfs/src/main/java/org/apache/storm/hdfs/blobstore/HdfsClientBlobStore.java
@@ -45,6 +45,7 @@ public class HdfsClientBlobStore extends ClientBlobStore {
     private static final Logger LOG = LoggerFactory.getLogger(HdfsClientBlobStore.class);
     private HdfsBlobStore _blobStore;
     private Map _conf;
+    private NimbusClient client;
 
     @Override
     public void prepare(Map conf) {
@@ -105,6 +106,7 @@ public class HdfsClientBlobStore extends ClientBlobStore {
 
     @Override
     public boolean setClient(Map conf, NimbusClient client) {
+        this.client = client;
         return true;
     }
 
@@ -115,6 +117,9 @@ public class HdfsClientBlobStore extends ClientBlobStore {
 
     @Override
     public void shutdown() {
-        // do nothing
+        if(client != null) {
+            client.close();
+            client = null;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/f8e8292f/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
index e414d60..d382dd9 100644
--- a/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
+++ b/storm-core/src/jvm/org/apache/storm/StormSubmitter.java
@@ -132,12 +132,9 @@ public class StormSubmitter {
                 LOG.info("Pushing Credentials to topology {} in local mode", name);
                 localNimbus.uploadNewCredentials(name, new Credentials(fullCreds));
             } else {
-                NimbusClient client = NimbusClient.getConfiguredClient(conf);
-                try {
+                try(NimbusClient client = NimbusClient.getConfiguredClient(conf)) {
                     LOG.info("Uploading new credentials to {}", name);
                     client.getClient().uploadNewCredentials(name, new Credentials(fullCreds));
-                } finally {
-                    client.close();
                 }
             }
             LOG.info("Finished pushing creds to topology: {}", name);

http://git-wip-us.apache.org/repos/asf/storm/blob/f8e8292f/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java
index a1d3f5a..0cac61f 100644
--- a/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java
+++ b/storm-core/src/jvm/org/apache/storm/blobstore/BlobStoreUtils.java
@@ -108,7 +108,6 @@ public class BlobStoreUtils {
     // Download missing blobs from potential nimbodes
     public static boolean downloadMissingBlob(Map conf, BlobStore blobStore, String key,
Set<NimbusInfo> nimbusInfos)
             throws TTransportException {
-        NimbusClient client;
         ReadableBlobMeta rbm;
         ClientBlobStore remoteBlobStore;
         InputStreamWithMeta in;
@@ -118,8 +117,7 @@ public class BlobStoreUtils {
             if(isSuccess) {
                 break;
             }
-            try {
-                client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(),
null);
+            try(NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(),
null)) {
                 rbm = client.getClient().getBlobMeta(key);
                 remoteBlobStore = new NimbusBlobStore();
                 remoteBlobStore.setClient(conf, client);
@@ -158,7 +156,6 @@ public class BlobStoreUtils {
     // Download updated blobs from potential nimbodes
     public static boolean downloadUpdatedBlob(Map conf, BlobStore blobStore, String key,
Set<NimbusInfo> nimbusInfos)
             throws TTransportException {
-        NimbusClient client;
         ClientBlobStore remoteBlobStore;
         InputStreamWithMeta in;
         AtomicOutputStream out;
@@ -168,8 +165,7 @@ public class BlobStoreUtils {
             if (isSuccess) {
                 break;
             }
-            try {
-                client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(),
null);
+            try(NimbusClient client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(),
null)) {
                 remoteBlobStore = new NimbusBlobStore();
                 remoteBlobStore.setClient(conf, client);
                 in = remoteBlobStore.getBlob(key);

http://git-wip-us.apache.org/repos/asf/storm/blob/f8e8292f/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java b/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
index 85209d6..aaddf3d 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
@@ -78,16 +78,13 @@ public class NimbusClient extends ThriftClient {
         for (String host : seeds) {
             int port = Integer.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT).toString());
             NimbusSummary nimbusSummary;
-            NimbusClient client = null;
-            try {
-                client = new NimbusClient(conf, host, port, null, asUser);
+            try(NimbusClient client = new NimbusClient(conf, host, port, null, asUser)) {
                 nimbusSummary = client.getClient().getLeader();
                 if (nimbusSummary != null) {
                     String leaderNimbus = nimbusSummary.get_host() + ":" + nimbusSummary.get_port();
                     LOG.info("Found leader nimbus : {}", leaderNimbus);
                     if (nimbusSummary.get_host().equals(host) && nimbusSummary.get_port()
== port) {
                         NimbusClient ret = client;
-                        client = null;
                         return ret;
                     }
                     try {
@@ -100,10 +97,6 @@ public class NimbusClient extends ThriftClient {
                 LOG.warn("Ignoring exception while trying to get leader nimbus info from
" + host
                         + ". will retry with a different seed host.", e);
                 continue;
-            } finally {
-                if (client != null) {
-                    client.close();
-                }
             }
             throw new NimbusLeaderNotFoundException("Could not find a nimbus leader, please
try " +
                     "again after some time.");


Mime
View raw message