You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2017/01/03 14:31:46 UTC
[2/4] storm git commit: STORM-2266: Addressed review comments
STORM-2266: Addressed review comments
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/fe013c45
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/fe013c45
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/fe013c45
Branch: refs/heads/master
Commit: fe013c45d869107834b6d0e188e5019fdbc09351
Parents: 5ab547e
Author: Satish Duggana <sd...@hortonworks.com>
Authored: Tue Jan 3 07:01:51 2017 +0530
Committer: Satish Duggana <sd...@hortonworks.com>
Committed: Tue Jan 3 07:03:05 2017 +0530
----------------------------------------------------------------------
.../jvm/org/apache/storm/utils/NimbusClient.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/fe013c45/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 aaddf3d..6699ba8 100644
--- a/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
+++ b/storm-core/src/jvm/org/apache/storm/utils/NimbusClient.java
@@ -69,7 +69,7 @@ public class NimbusClient extends ThriftClient {
List<String> seeds;
if(conf.containsKey(Config.NIMBUS_HOST)) {
LOG.warn("Using deprecated config {} for backward compatibility. Please update your storm.yaml so it only has config {}",
- Config.NIMBUS_HOST, Config.NIMBUS_SEEDS);
+ Config.NIMBUS_HOST, Config.NIMBUS_SEEDS);
seeds = Lists.newArrayList(conf.get(Config.NIMBUS_HOST).toString());
} else {
seeds = (List<String>) conf.get(Config.NIMBUS_SEEDS);
@@ -78,13 +78,16 @@ public class NimbusClient extends ThriftClient {
for (String host : seeds) {
int port = Integer.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT).toString());
NimbusSummary nimbusSummary;
- try(NimbusClient client = new NimbusClient(conf, host, port, null, asUser)) {
+ NimbusClient client = null;
+ try {
+ 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 {
@@ -95,15 +98,19 @@ public class NimbusClient extends ThriftClient {
}
} catch (Exception e) {
LOG.warn("Ignoring exception while trying to get leader nimbus info from " + host
- + ". will retry with a different seed host.", e);
+ + ". 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.");
+ "again after some time.");
}
throw new NimbusLeaderNotFoundException(
"Could not find leader nimbus from seed hosts " + seeds + ". " +
- "Did you specify a valid list of nimbus hosts for config " +
+ "Did you specify a valid list of nimbus hosts for config " +
Config.NIMBUS_SEEDS + "?");
}