SLIDER-570 sort found clusters by recent-ness
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/7b630000 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/7b630000 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/7b630000 Branch: refs/heads/develop Commit: 7b63000063609f9db0408e27b0b9356474f29ebc Parents: 09d16a1 Author: Steve Loughran <ste...@apache.org> Authored: Wed Oct 29 11:44:37 2014 +0000 Committer: Steve Loughran <ste...@apache.org> Committed: Fri Oct 31 11:07:49 2014 +0000 ---------------------------------------------------------------------- .../org/apache/slider/client/SliderClient.java | 21 +++++++++++--------- .../slider/client/SliderYarnClientImpl.java | 11 +++++----- 2 files changed, 17 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7b630000/slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java index 392280a..6ebbcdd 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -1693,13 +1693,16 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe return actionList(clustername, args); } - /** - * Implement the list action: list all nodes - - * @param clustername List out specific instance name - * @param args Action list arguments - * @return 0 if one or more entries were listed - */ + /** + * Implement the list action. + * @param clustername List out specific instance name + * @param args Action list arguments + * @return 0 if one or more entries were listed + * @throws IOException + * @throws YarnException + * @throws UnknownApplicationInstanceException if a specific instance + * was named but it was not found + */ @Override @VisibleForTesting public int actionList(String clustername, ActionListArgs args) @@ -1996,8 +1999,8 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe private RunningApplication findApplication(String appname) throws YarnException, IOException { ApplicationReport applicationReport = findInstance(appname); - return applicationReport != null ? new RunningApplication(yarnClient, applicationReport): null; - + return applicationReport != null ? + new RunningApplication(yarnClient, applicationReport): null; } /** http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7b630000/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 2f18b7a..a2a7fe7 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 @@ -259,19 +259,18 @@ public class SliderYarnClientImpl extends YarnClientImpl { */ public ApplicationReport findClusterInInstanceList(List<ApplicationReport> instances, String appname) { + // sort by most recent + SliderUtils.sortApplicationsByMostRecent(instances); ApplicationReport found = null; - ApplicationReport foundAndLive = null; for (ApplicationReport app : instances) { if (app.getName().equals(appname)) { - found = app; if (isApplicationLive(app)) { - foundAndLive = app; + return app; } + // set the found value if not set + found = found != null ? found : app; } } - if (foundAndLive != null) { - found = foundAndLive; - } return found; }