diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java index 3336ed9..71fd078 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java @@ -153,7 +153,7 @@ // log4j.properties file // if available, add to local resources and set into classpath - private String log4jPropFile = ""; + private String log4jPropFile = ""; // Start time for client private final long clientStartTime = System.currentTimeMillis(); @@ -164,7 +164,7 @@ private boolean keepContainers = false; // Debug flag - boolean debugFlag = false; + boolean debugFlag = false; // Command line options private Options opts; @@ -202,7 +202,7 @@ public static void main(String[] args) { } if (result) { LOG.info("Application completed successfully"); - System.exit(0); + System.exit(0); } LOG.error("Application failed to complete successfully"); System.exit(2); @@ -307,7 +307,7 @@ public boolean init(String[] args) throws ParseException { appName = cliParser.getOptionValue("appname", "DistributedShell"); amPriority = Integer.parseInt(cliParser.getOptionValue("priority", "0")); amQueue = cliParser.getOptionValue("queue", "default"); - amMemory = Integer.parseInt(cliParser.getOptionValue("master_memory", "10")); + amMemory = Integer.parseInt(cliParser.getOptionValue("master_memory", "10")); amVCores = Integer.parseInt(cliParser.getOptionValue("master_vcores", "1")); if (amMemory < 0) { @@ -321,7 +321,7 @@ public boolean init(String[] args) throws ParseException { if (!cliParser.hasOption("jar")) { throw new IllegalArgumentException("No jar file specified for application master"); - } + } appMasterJar = cliParser.getOptionValue("jar"); @@ -409,16 +409,16 @@ public boolean run() throws IOException, YarnException { + ", queueCurrentCapacity=" + queueInfo.getCurrentCapacity() + ", queueMaxCapacity=" + queueInfo.getMaximumCapacity() + ", queueApplicationCount=" + queueInfo.getApplications().size() - + ", queueChildQueueCount=" + queueInfo.getChildQueues().size()); + + ", queueChildQueueCount=" + queueInfo.getChildQueues().size()); List listAclInfo = yarnClient.getQueueAclsInfo(); for (QueueUserACLInfo aclInfo : listAclInfo) { for (QueueACL userAcl : aclInfo.getUserAcls()) { LOG.info("User ACL Info for Queue" - + ", queueName=" + aclInfo.getQueueName() + + ", queueName=" + aclInfo.getQueueName() + ", userAcl=" + userAcl.name()); } - } + } // Get a new application id YarnClientApplication app = yarnClient.createApplication(); @@ -437,7 +437,7 @@ public boolean run() throws IOException, YarnException { + ", specified=" + amMemory + ", max=" + maxMem); amMemory = maxMem; - } + } int maxVCores = appResponse.getMaximumResourceCapability().getVirtualCores(); LOG.info("Max virtual cores capabililty of resources in this cluster " + maxVCores); @@ -461,7 +461,7 @@ public boolean run() throws IOException, YarnException { // set local resources for the application master // local files or archives as needed - // In this scenario, the jar file for the application master is part of the local resources + // In this scenario, the jar file for the application master is part of the local resources Map localResources = new HashMap(); LOG.info("Copy App Master jar from local filesystem and add to local environment"); @@ -475,14 +475,14 @@ public boolean run() throws IOException, YarnException { if (!log4jPropFile.isEmpty()) { addToLocalResources(fs, log4jPropFile, log4jPath, appId.toString(), localResources, null); - } + } // The shell script has to be made available on the final container(s) // where it will be executed. // To do this, we need to first copy into the filesystem that is visible // to the yarn framework. // We do not need to set this as a local resource for the application - // master as the application master does not need it. + // master as the application master does not need it. String hdfsShellScriptLocation = ""; long hdfsShellScriptLen = 0; long hdfsShellScriptTimestamp = 0; @@ -525,8 +525,8 @@ public boolean run() throws IOException, YarnException { env.put(DSConstants.DISTRIBUTEDSHELLSCRIPTTIMESTAMP, Long.toString(hdfsShellScriptTimestamp)); env.put(DSConstants.DISTRIBUTEDSHELLSCRIPTLEN, Long.toString(hdfsShellScriptLen)); - // Add AppMaster.jar location to classpath - // At some point we should not be required to add + // Add AppMaster.jar location to classpath + // At some point we should not be required to add // the hadoop specific classpaths to the env. // It should be provided out of the box. // For now setting all required classpaths including @@ -570,7 +570,7 @@ public boolean run() throws IOException, YarnException { for (Map.Entry entry : shellEnv.entrySet()) { vargs.add("--shell_env " + entry.getKey() + "=" + entry.getValue()); - } + } if (debugFlag) { vargs.add("--debug"); } @@ -584,9 +584,9 @@ public boolean run() throws IOException, YarnException { command.append(str).append(" "); } - LOG.info("Completed setting up app master command " + command.toString()); + LOG.info("Completed setting up app master command " + command.toString()); List commands = new ArrayList(); - commands.add(command.toString()); + commands.add(command.toString()); amContainer.setCommands(commands); // Set up resource type requirements @@ -700,22 +700,22 @@ private boolean monitorApplication(ApplicationId appId) + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false; - } + } } - else if (YarnApplicationState.KILLED == state + else if (YarnApplicationState.KILLED == state || YarnApplicationState.FAILED == state) { LOG.info("Application did not finish." + " YarnState=" + state.toString() + ", DSFinalStatus=" + dsStatus.toString() + ". Breaking monitoring loop"); return false; - } + } if (System.currentTimeMillis() > (clientStartTime + clientTimeout)) { LOG.info("Reached client specified timeout for application. Killing application"); forceKillApplication(appId); - return false; + return false; } - } + } } @@ -733,7 +733,7 @@ private void forceKillApplication(ApplicationId appId) // Response can be ignored as it is non-null on success or // throws an exception in case of failures - yarnClient.killApplication(appId); + yarnClient.killApplication(appId); } private void addToLocalResources(FileSystem fs, String fileSrcPath,