Permalink
Browse files

Adding some logging to AM.

  • Loading branch information...
1 parent c8bdc37 commit f88494e610eb8b8b021a8bced08547dc1b14c796 @acmurthy acmurthy committed Aug 6, 2013
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/main/java/com/hortonworks/simpleyarnapp/ApplicationMaster.java
@@ -14,6 +14,7 @@
import org.apache.hadoop.yarn.client.api.AMRMClient;
import org.apache.hadoop.yarn.client.api.AMRMClient.ContainerRequest;
import org.apache.hadoop.yarn.client.api.NMClient;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.util.Records;
public class ApplicationMaster {
@@ -24,7 +25,7 @@ public static void main(String[] args) throws Exception {
final int n = Integer.valueOf(args[1]);
// Initialize clients to ResourceManager and NodeManagers
- Configuration conf = new Configuration();
+ Configuration conf = new YarnConfiguration();
AMRMClient<ContainerRequest> rmClient = AMRMClient.createAMRMClient();
rmClient.init(conf);
@@ -35,8 +36,10 @@ public static void main(String[] args) throws Exception {
nmClient.start();
// Register with ResourceManager
+ System.out.println("registerApplicationMaster 0");
rmClient.registerApplicationMaster("", 0, "");
-
+ System.out.println("registerApplicationMaster 1");
+
// Priority for worker containers - priorities are intra-application
Priority priority = Records.newRecord(Priority.class);
priority.setPriority(0);
@@ -49,6 +52,7 @@ public static void main(String[] args) throws Exception {
// Make container requests to ResourceManager
for (int i = 0; i < n; ++i) {
ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority);
+ System.out.println("Making res-req " + i);
rmClient.addContainerRequest(containerAsk);
}
@@ -68,6 +72,7 @@ public static void main(String[] args) throws Exception {
" 1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout" +
" 2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr"
));
+ System.out.println("Launching container " + allocatedContainers);
nmClient.startContainer(container, ctx);
}
Thread.sleep(100);
@@ -78,9 +83,8 @@ public static void main(String[] args) throws Exception {
while (completedContainers < n) {
AllocateResponse response = rmClient.allocate(completedContainers/n);
for (ContainerStatus status : response.getCompletedContainersStatuses()) {
- if (status.getExitStatus() == 0) {
- ++completedContainers;
- }
+ ++completedContainers;
+ System.out.println("Completed container " + completedContainers);
}
Thread.sleep(100);
}

0 comments on commit f88494e

Please sign in to comment.