SLIDER-635 Duration should be closed upon return from LaunchedApplication#monitorAppToState()
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/693fddd1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/693fddd1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/693fddd1 Branch: refs/heads/feature/SLIDER-622-windows Commit: 693fddd1a35d0828a6faa959150673a7b95f8282 Parents: 62cdd69 Author: tedyu <[email protected]> Authored: Mon Nov 10 15:31:58 2014 -0800 Committer: tedyu <[email protected]> Committed: Mon Nov 10 15:31:58 2014 -0800 ---------------------------------------------------------------------- .../slider/client/SliderYarnClientImpl.java | 51 +++++++++++--------- .../launch/SerializedApplicationReport.java | 4 +- .../server/services/security/SecurityUtils.java | 12 ++++- 3 files changed, 40 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/693fddd1/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java b/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java index a2a7fe7..856b34c 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderYarnClientImpl.java @@ -195,35 +195,38 @@ public class SliderYarnClientImpl extends YarnClientImpl { duration.limit, desiredState); duration.start(); - while (true) { + try { + while (true) { + // Get application report for the appId we are interested in - // Get application report for the appId we are interested in + ApplicationReport r = getApplicationReport(appId); - ApplicationReport r = getApplicationReport(appId); - - log.debug("queried status is\n{}", - new SliderUtils.OnDemandReportStringifier(r)); - - YarnApplicationState state = r.getYarnApplicationState(); - if (state.ordinal() >= desiredState.ordinal()) { - log.debug("App in desired state (or higher) :{}", state); - return r; - } - if (duration.getLimitExceeded()) { - log.debug( - "Wait limit of {} millis to get to state {}, exceeded; app status\n {}", - duration.limit, - desiredState, + log.debug("queried status is\n{}", new SliderUtils.OnDemandReportStringifier(r)); - return null; - } - // sleep 1s. - try { - Thread.sleep(1000); - } catch (InterruptedException ignored) { - log.debug("Thread sleep in monitoring loop interrupted"); + YarnApplicationState state = r.getYarnApplicationState(); + if (state.ordinal() >= desiredState.ordinal()) { + log.debug("App in desired state (or higher) :{}", state); + return r; + } + if (duration.getLimitExceeded()) { + log.debug( + "Wait limit of {} millis to get to state {}, exceeded; app status\n {}", + duration.limit, + desiredState, + new SliderUtils.OnDemandReportStringifier(r)); + return null; + } + + // sleep 1s. + try { + Thread.sleep(1000); + } catch (InterruptedException ignored) { + log.debug("Thread sleep in monitoring loop interrupted"); + } } + } finally { + duration.close(); } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/693fddd1/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java b/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java index dfa037d..116aeb3 100644 --- a/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java +++ b/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java @@ -19,6 +19,7 @@ package org.apache.slider.core.launch; import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.slider.core.persist.ApplicationReportSerDeser; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -77,7 +78,8 @@ public class SerializedApplicationReport { this.diagnostics = report.getDiagnostics(); this.startTime = report.getStartTime(); this.finishTime = report.getFinishTime(); - this.finalStatus = report.getFinalApplicationStatus().toString(); + FinalApplicationStatus appStatus = report.getFinalApplicationStatus(); + this.finalStatus = appStatus == null ? "" : appStatus.toString(); this.progress = report.getProgress(); } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/693fddd1/slider-core/src/main/java/org/apache/slider/server/services/security/SecurityUtils.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/services/security/SecurityUtils.java b/slider-core/src/main/java/org/apache/slider/server/services/security/SecurityUtils.java index 527d4e6..ecbb637 100644 --- a/slider-core/src/main/java/org/apache/slider/server/services/security/SecurityUtils.java +++ b/slider-core/src/main/java/org/apache/slider/server/services/security/SecurityUtils.java @@ -153,8 +153,9 @@ public class SecurityUtils { File dbDir = new File(secDirFile, "db"); File newCertsDir = new File(dbDir, "newcerts"); newCertsDir.mkdirs(); + RawLocalFileSystem fileSystem = null; try { - RawLocalFileSystem fileSystem = new RawLocalFileSystem(); + fileSystem = new RawLocalFileSystem(); FsPermission permissions = new FsPermission(FsAction.ALL, FsAction.NONE, FsAction.NONE); fileSystem.setPermission(new Path(dbDir.getAbsolutePath()), @@ -164,11 +165,18 @@ public class SecurityUtils { permissions); File indexFile = new File(dbDir, "index.txt"); indexFile.createNewFile(); - SecurityUtils.writeCaConfigFile(secDirFile.getAbsolutePath().replace('\\', '/')); } catch (IOException e) { LOG.error("Unable to create SSL configuration directories/files", e); + } finally { + if (fileSystem != null) { + try { + fileSystem.close(); + } catch (IOException e) { + LOG.warn("Unable to close fileSystem", e); + } + } } // need to create the password }
