Repository: hadoop Updated Branches: refs/heads/yarn-native-services 42d1244fc -> 4516cedfb
YARN-6115. Few additional paths in Slider client still uses get all Applications without tags/states filter. Contributed by Gour Saha Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4516cedf Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4516cedf Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4516cedf Branch: refs/heads/yarn-native-services Commit: 4516cedfba4d282d9f4fc44c36c7efb6f42dedc8 Parents: 42d1244 Author: Billie Rinaldi <bil...@apache.org> Authored: Wed Jan 25 14:20:58 2017 -0800 Committer: Billie Rinaldi <bil...@apache.org> Committed: Wed Jan 25 14:20:58 2017 -0800 ---------------------------------------------------------------------- .../org/apache/slider/client/SliderClient.java | 43 +++++++++++------ .../slider/core/registry/YarnAppListClient.java | 51 +++++++++++++++++--- 2 files changed, 73 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/4516cedf/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java index 1a959d6..032eb6e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -142,7 +142,6 @@ import org.apache.slider.core.launch.ClasspathConstructor; import org.apache.slider.core.launch.CredentialUtils; import org.apache.slider.core.launch.JavaCommandLineBuilder; import org.apache.slider.core.launch.LaunchedApplication; -import org.apache.slider.core.launch.RunningApplication; import org.apache.slider.core.launch.SerializedApplicationReport; import org.apache.slider.core.main.RunService; import org.apache.slider.core.persist.AppDefinitionPersister; @@ -1535,7 +1534,9 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe public void updateLifetime(String appName, long lifetime) throws YarnException, IOException { - ApplicationReport report = findInstance(appName); + EnumSet<YarnApplicationState> appStates = EnumSet.range( + YarnApplicationState.NEW, YarnApplicationState.RUNNING); + ApplicationReport report = findInstance(appName, appStates); if (report == null) { throw new YarnException("Application not found for " + appName); } @@ -2672,15 +2673,17 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe } /** - * List Slider instances belonging to a specific user. This will include - * failed and killed instances; there may be duplicates + * List Slider instances belonging to a specific user with a specific app + * name and within a set of app states. * @param user user: "" means all users, null means "default" + * @param appName name of the application set as a tag + * @param appStates a set of states the applications should be in * @return a possibly empty list of Slider AMs */ - - public List<ApplicationReport> listSliderInstances(String user) - throws YarnException, IOException { - return yarnAppListClient.listInstances(user); + public List<ApplicationReport> listSliderInstances(String user, + String appName, EnumSet<YarnApplicationState> appStates) + throws YarnException, IOException { + return yarnAppListClient.listInstances(user, appName, appStates); } /** @@ -2806,7 +2809,9 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe } // and those the RM knows about - List<ApplicationReport> instances = listSliderInstances(null); + EnumSet<YarnApplicationState> appStates = EnumSet.range(min, max); + List<ApplicationReport> instances = listSliderInstances(null, clustername, + appStates); sortApplicationsByMostRecent(instances); Map<String, ApplicationReport> reportMap = buildApplicationReportMap(instances, min, max); @@ -3053,7 +3058,7 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe } /** - * Find an instance of an application belonging to the current user + * Find an instance of an application belonging to the current user. * @param appname application name * @return the app report or null if none is found * @throws YarnException YARN issues @@ -3061,14 +3066,22 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe */ public ApplicationReport findInstance(String appname) throws YarnException, IOException { - return yarnAppListClient.findInstance(appname); + return findInstance(appname, null); } - private RunningApplication findApplication(String appname) + /** + * Find an instance of an application belonging to the current user and in + * specific app states. + * @param appname application name + * @param appStates app states in which the application should be in + * @return the app report or null if none is found + * @throws YarnException YARN issues + * @throws IOException IO problems + */ + public ApplicationReport findInstance(String appname, + EnumSet<YarnApplicationState> appStates) throws YarnException, IOException { - ApplicationReport applicationReport = findInstance(appname); - return applicationReport != null ? - new RunningApplication(yarnClient, applicationReport): null; + return yarnAppListClient.findInstance(appname, appStates); } /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/4516cedf/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java index 71cc193..d311fee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/core/registry/YarnAppListClient.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -77,7 +78,7 @@ public class YarnAppListClient { /** - * Find an instance of a application belong to the current user + * Find an instance of a application belong to the current user. * @param appname application name * @return the app report or null if none is found * @throws YarnException YARN issues @@ -86,7 +87,22 @@ public class YarnAppListClient { public ApplicationReport findInstance(String appname) throws YarnException, IOException { - List<ApplicationReport> instances = listInstances(null, appname); + return findInstance(appname, null); + } + + /** + * Find an instance of a application belong to the current user in specific + * app states. + * @param appname application name + * @param appStates list of states in which application should be in + * @return the app report or null if none is found + * @throws YarnException YARN issues + * @throws IOException IO problems + */ + public ApplicationReport findInstance(String appname, + EnumSet<YarnApplicationState> appStates) + throws YarnException, IOException { + List<ApplicationReport> instances = listInstances(null, appname, appStates); return yarnClient.findClusterInInstanceList(instances, appname); } @@ -111,21 +127,44 @@ public class YarnAppListClient { } /** - * List all instances belonging to a specific user and a specific appname. + * List all instances belonging to a specific user with a specific app name. + * + * @param user + * user if not the default. null means default, "" means all users, + * otherwise it is the name of a user + * @param appName + * application name set as an application tag + * @return a possibly empty list of AMs + * @throws YarnException + * @throws IOException + */ + public List<ApplicationReport> listInstances(String user, String appName) + throws YarnException, IOException { + return listInstances(user, appName, null); + } + + /** + * List all instances belonging to a specific user, with a specific app name + * and in specific app states. * * @param user * user if not the default. null means default, "" means all users, * otherwise it is the name of a user - * @param appname + * @param appName * application name set as an application tag + * @param appStates + * a set of application states within which the app should be in * @return a possibly empty list of AMs * @throws YarnException * @throws IOException */ - public List<ApplicationReport> listInstances(String user, String appname) + public List<ApplicationReport> listInstances(String user, String appName, + EnumSet<YarnApplicationState> appStates) throws YarnException, IOException { + log.debug("listInstances called with user: {}, appName: {}, appStates: {}", + user, appName, appStates); String listUser = user == null ? username : user; - return yarnClient.listDeployedInstances(listUser, null, appname); + return yarnClient.listDeployedInstances(listUser, appStates, appName); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org