You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by go...@apache.org on 2015/06/16 02:22:12 UTC
incubator-slider git commit: SLIDER-904 Resource leak reported by
coverity scan results
Repository: incubator-slider
Updated Branches:
refs/heads/develop 55e86f172 -> 9104caad8
SLIDER-904 Resource leak reported by coverity scan results
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/9104caad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/9104caad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/9104caad
Branch: refs/heads/develop
Commit: 9104caad859981d070973ca22c62498362a640f1
Parents: 55e86f1
Author: Gour Saha <go...@apache.org>
Authored: Mon Jun 15 17:21:58 2015 -0700
Committer: Gour Saha <go...@apache.org>
Committed: Mon Jun 15 17:21:58 2015 -0700
----------------------------------------------------------------------
.../client/ipc/SliderClusterOperations.java | 67 +++++++++++---------
.../slider/server/appmaster/rpc/RpcBinder.java | 60 ++++++++++--------
2 files changed, 68 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/9104caad/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
index ae95b17..69dcb3b 100644
--- a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
+++ b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
@@ -282,45 +282,50 @@ public class SliderClusterOperations {
@VisibleForTesting
public int waitForRoleInstanceLive(String role, long timeout)
throws WaitTimeoutException, IOException, YarnException {
- Duration duration = new Duration(timeout).start();
+ Duration duration = new Duration(timeout);
+ duration.start();
boolean live = false;
int state = StateValues.STATE_CREATED;
log.info("Waiting {} millis for a live node in role {}", timeout, role);
- while (!live) {
- // see if there is a node in that role yet
- List<String> uuids = innerListNodeUUIDSByRole(role);
- String[] containers = uuids.toArray(new String[uuids.size()]);
- int roleCount = containers.length;
- ClusterNode roleInstance = null;
- if (roleCount != 0) {
-
- // if there is, get the node
- roleInstance = getNode(containers[0]);
- if (roleInstance != null) {
- state = roleInstance.state;
- live = state >= StateValues.STATE_LIVE;
+ try {
+ while (!live) {
+ // see if there is a node in that role yet
+ List<String> uuids = innerListNodeUUIDSByRole(role);
+ String[] containers = uuids.toArray(new String[uuids.size()]);
+ int roleCount = containers.length;
+ ClusterNode roleInstance = null;
+ if (roleCount != 0) {
+
+ // if there is, get the node
+ roleInstance = getNode(containers[0]);
+ if (roleInstance != null) {
+ state = roleInstance.state;
+ live = state >= StateValues.STATE_LIVE;
+ }
}
- }
- if (!live) {
- if (duration.getLimitExceeded()) {
- throw new WaitTimeoutException(
- String.format("Timeout after %d millis" +
- " waiting for a live instance of type %s; " +
- "instances found %d %s",
- timeout, role, roleCount,
- (roleInstance != null
- ? (" instance -\n" + roleInstance.toString())
- : "")
- ));
- } else {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignored) {
- // ignored
+ if (!live) {
+ if (duration.getLimitExceeded()) {
+ throw new WaitTimeoutException(
+ String.format("Timeout after %d millis" +
+ " waiting for a live instance of type %s; " +
+ "instances found %d %s",
+ timeout, role, roleCount,
+ (roleInstance != null
+ ? (" instance -\n" + roleInstance.toString())
+ : "")
+ ));
+ } else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ // ignored
+ }
}
}
}
+ } finally {
+ duration.close();
}
return state;
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/9104caad/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.java
index 9381b76..d5c9df7 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/RpcBinder.java
@@ -199,37 +199,41 @@ public class RpcBinder {
timeout.start();
Exception exception = null;
YarnApplicationState state = null;
- while (application != null &&
- (state = application.getYarnApplicationState()).equals(
- YarnApplicationState.RUNNING)) {
-
- try {
- return getProxy(conf, application, rpcTimeout);
- } catch (IOException e) {
- if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
- throw e;
- }
- exception = e;
- } catch (YarnException e) {
- if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
- throw e;
+ try {
+ while (application != null &&
+ (state = application.getYarnApplicationState()).equals(
+ YarnApplicationState.RUNNING)) {
+
+ try {
+ return getProxy(conf, application, rpcTimeout);
+ } catch (IOException e) {
+ if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
+ throw e;
+ }
+ exception = e;
+ } catch (YarnException e) {
+ if (connectTimeout <= 0 || timeout.getLimitExceeded()) {
+ throw e;
+ }
+ exception = e;
}
- exception = e;
+ //at this point: app failed to work
+ log.debug("Could not connect to {}. Waiting for getting the latest AM address...",
+ appId);
+ Thread.sleep(1000);
+ //or get the app report
+ application =
+ rmClient.getApplicationReport(
+ GetApplicationReportRequest.newInstance(appId)).getApplicationReport();
}
- //at this point: app failed to work
- log.debug("Could not connect to {}. Waiting for getting the latest AM address...",
- appId);
- Thread.sleep(1000);
- //or get the app report
- application =
- rmClient.getApplicationReport(
- GetApplicationReportRequest.newInstance(appId)).getApplicationReport();
+ //get here if the app is no longer running. Raise a specific
+ //exception but init it with the previous failure
+ throw new BadClusterStateException(
+ exception,
+ ErrorStrings.E_FINISHED_APPLICATION, appId, state );
+ } finally {
+ timeout.close();
}
- //get here if the app is no longer running. Raise a specific
- //exception but init it with the previous failure
- throw new BadClusterStateException(
- exception,
- ErrorStrings.E_FINISHED_APPLICATION, appId, state );
}
/**