hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1213975 [5/6] - in /hadoop/common/trunk/hadoop-mapreduce-project: ./ hadoop-mapreduce-client/ hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/client/ hadoop-mapreduce-client/hadoop-mapre...
Date Tue, 13 Dec 2011 23:05:59 GMT
Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue;
+
+@XmlRootElement(name = "capacityScheduler")
+@XmlType(name = "capacityScheduler")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CapacitySchedulerInfo extends SchedulerInfo {
+
+  protected float capacity;
+  protected float usedCapacity;
+  protected float maxCapacity;
+  protected String queueName;
+  protected ArrayList<CapacitySchedulerQueueInfo> queues;
+
+  @XmlTransient
+  static final float EPSILON = 1e-8f;
+
+  public CapacitySchedulerInfo() {
+  } // JAXB needs this
+
+  public CapacitySchedulerInfo(CSQueue parent) {
+    this.queueName = parent.getQueueName();
+    this.usedCapacity = parent.getUsedCapacity() * 100;
+    this.capacity = parent.getCapacity() * 100;
+    float max = parent.getMaximumCapacity();
+    if (max < EPSILON || max > 1f)
+      max = 1f;
+    this.maxCapacity = max * 100;
+
+    queues = getQueues(parent);
+  }
+
+  public float getCapacity() {
+    return this.capacity;
+  }
+
+  public float getUsedCapacity() {
+    return this.usedCapacity;
+  }
+
+  public float getMaxCapacity() {
+    return this.maxCapacity;
+  }
+
+  public String getQueueName() {
+    return this.queueName;
+  }
+
+  public ArrayList<CapacitySchedulerQueueInfo> getSubQueues() {
+    return this.queues;
+  }
+
+  protected ArrayList<CapacitySchedulerQueueInfo> getQueues(CSQueue parent) {
+    CSQueue parentQueue = parent;
+    ArrayList<CapacitySchedulerQueueInfo> queuesInfo = new ArrayList<CapacitySchedulerQueueInfo>();
+    for (CSQueue queue : parentQueue.getChildQueues()) {
+      float usedCapacity = queue.getUsedCapacity() * 100;
+      float capacity = queue.getCapacity() * 100;
+      String queueName = queue.getQueueName();
+      String queuePath = queue.getQueuePath();
+      float max = queue.getMaximumCapacity();
+      if (max < EPSILON || max > 1f)
+        max = 1f;
+      float maxCapacity = max * 100;
+      String state = queue.getState().toString();
+      CapacitySchedulerQueueInfo info = new CapacitySchedulerQueueInfo(
+          capacity, usedCapacity, maxCapacity, queueName, state, queuePath);
+
+      if (queue instanceof ParentQueue) {
+        info.isParent = true;
+        info.queue = queue;
+        info.subQueues = getQueues(queue);
+      }
+      queuesInfo.add(info);
+    }
+    return queuesInfo;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerQueueInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerQueueInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerQueueInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/CapacitySchedulerQueueInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CapacitySchedulerQueueInfo {
+
+  @XmlTransient
+  protected String queuePath;
+  @XmlTransient
+  protected Boolean isParent = false;
+
+  // bit odd to store this but makes html easier for now
+  @XmlTransient
+  protected CSQueue queue;
+
+  protected float capacity;
+  protected float usedCapacity;
+  protected float maxCapacity;
+  protected String queueName;
+  protected String state;
+  protected ArrayList<CapacitySchedulerQueueInfo> subQueues;
+
+  CapacitySchedulerQueueInfo() {
+  };
+
+  CapacitySchedulerQueueInfo(float cap, float used, float max, String name,
+      String state, String path) {
+    this.capacity = cap;
+    this.usedCapacity = used;
+    this.maxCapacity = max;
+    this.queueName = name;
+    this.state = state;
+    this.queuePath = path;
+  }
+
+  public Boolean isParent() {
+    return this.isParent;
+  }
+
+  public CSQueue getQueue() {
+    return this.queue;
+  }
+
+  public float getCapacity() {
+    return this.capacity;
+  }
+
+  public float getUsedCapacity() {
+    return this.usedCapacity;
+  }
+
+  public float getMaxCapacity() {
+    return this.maxCapacity;
+  }
+
+  public String getQueueName() {
+    return this.queueName;
+  }
+
+  public String getQueueState() {
+    return this.state;
+  }
+
+  public String getQueuePath() {
+    return this.queuePath;
+  }
+
+  public ArrayList<CapacitySchedulerQueueInfo> getSubQueues() {
+    return this.subQueues;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.hadoop.util.VersionInfo;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.util.YarnVersionInfo;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ClusterInfo {
+
+  protected long id;
+  protected long startedOn;
+  protected String state;
+  protected String resourceManagerVersion;
+  protected String resourceManagerBuildVersion;
+  protected String resourceManagerVersionBuiltOn;
+  protected String hadoopVersion;
+  protected String hadoopBuildVersion;
+  protected String hadoopVersionBuiltOn;
+
+  public ClusterInfo() {
+  } // JAXB needs this
+
+  public ClusterInfo(ResourceManager rm) {
+    long ts = ResourceManager.clusterTimeStamp;
+
+    this.id = ts;
+    this.state = rm.getServiceState().toString();
+    this.startedOn = ts;
+    this.resourceManagerVersion = YarnVersionInfo.getVersion();
+    this.resourceManagerBuildVersion = YarnVersionInfo.getBuildVersion();
+    this.resourceManagerVersionBuiltOn = YarnVersionInfo.getDate();
+    this.hadoopVersion = VersionInfo.getVersion();
+    this.hadoopBuildVersion = VersionInfo.getBuildVersion();
+    this.hadoopVersionBuiltOn = VersionInfo.getDate();
+  }
+
+  public String getState() {
+    return this.state;
+  }
+
+  public String getRMVersion() {
+    return this.resourceManagerVersion;
+  }
+
+  public String getRMBuildVersion() {
+    return this.resourceManagerBuildVersion;
+  }
+
+  public String getRMVersionBuiltOn() {
+    return this.resourceManagerVersionBuiltOn;
+  }
+
+  public String getHadoopVersion() {
+    return this.hadoopVersion;
+  }
+
+  public String getHadoopBuildVersion() {
+    return this.hadoopBuildVersion;
+  }
+
+  public String getHadoopVersionBuiltOn() {
+    return this.hadoopVersionBuiltOn;
+  }
+
+  public long getClusterId() {
+    return this.id;
+  }
+
+  public long getStartedOn() {
+    return this.startedOn;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterMetricsInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterMetricsInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterMetricsInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterMetricsInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.hadoop.yarn.server.resourcemanager.ClusterMetrics;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+
+@XmlRootElement(name = "clusterMetrics")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ClusterMetricsInfo {
+
+  private static final long MB_IN_GB = 1024;
+
+  protected int appsSubmitted;
+  protected long reservedMB;
+  protected long availableMB;
+  protected long allocatedMB;
+  protected int containersAllocated;
+  protected long totalMB;
+  protected int totalNodes;
+  protected int lostNodes;
+  protected int unhealthyNodes;
+  protected int decommissionedNodes;
+  protected int rebootedNodes;
+
+  public ClusterMetricsInfo() {
+  } // JAXB needs this
+
+  public ClusterMetricsInfo(final ResourceManager rm, final RMContext rmContext) {
+    ResourceScheduler rs = rm.getResourceScheduler();
+    QueueMetrics metrics = rs.getRootQueueMetrics();
+    ClusterMetrics clusterMetrics = ClusterMetrics.getMetrics();
+
+    this.appsSubmitted = metrics.getAppsSubmitted();
+    this.reservedMB = metrics.getReservedGB() * MB_IN_GB;
+    this.availableMB = metrics.getAvailableGB() * MB_IN_GB;
+    this.allocatedMB = metrics.getAllocatedGB() * MB_IN_GB;
+    this.containersAllocated = metrics.getAllocatedContainers();
+    this.totalMB = availableMB + reservedMB + allocatedMB;
+    this.totalNodes = clusterMetrics.getNumNMs();
+    this.lostNodes = clusterMetrics.getNumLostNMs();
+    this.unhealthyNodes = clusterMetrics.getUnhealthyNMs();
+    this.decommissionedNodes = clusterMetrics.getNumDecommisionedNMs();
+    this.rebootedNodes = clusterMetrics.getNumRebootedNMs();
+
+  }
+
+  public int getAppsSubmitted() {
+    return this.appsSubmitted;
+  }
+
+  public long getReservedMB() {
+    return this.reservedMB;
+  }
+
+  public long getAvailableMB() {
+    return this.availableMB;
+  }
+
+  public long getAllocatedMB() {
+    return this.allocatedMB;
+  }
+
+  public int getContainersAllocated() {
+    return this.containersAllocated;
+  }
+
+  public long getTotalMB() {
+    return this.totalMB;
+  }
+
+  public int getTotalNodes() {
+    return this.totalNodes;
+  }
+
+  public int getLostNodes() {
+    return this.lostNodes;
+  }
+
+  public int getRebootedNodes() {
+    return this.rebootedNodes;
+  }
+
+  public int getUnhealthyNodes() {
+    return this.unhealthyNodes;
+  }
+
+  public int getDecommissionedNodes() {
+    return this.decommissionedNodes;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FifoSchedulerInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FifoSchedulerInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FifoSchedulerInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/FifoSchedulerInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.hadoop.yarn.api.records.QueueInfo;
+import org.apache.hadoop.yarn.api.records.QueueState;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
+
+@XmlRootElement(name = "fifoScheduler")
+@XmlType(name = "fifoScheduler")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FifoSchedulerInfo extends SchedulerInfo {
+
+  protected float capacity;
+  protected float usedCapacity;
+  protected QueueState qstate;
+  protected int minQueueMemoryCapacity;
+  protected int maxQueueMemoryCapacity;
+  protected int numNodes;
+  protected int usedNodeCapacity;
+  protected int availNodeCapacity;
+  protected int totalNodeCapacity;
+  protected int numContainers;
+
+  @XmlTransient
+  protected String qstateFormatted;
+
+  @XmlTransient
+  protected String qName;
+
+  public FifoSchedulerInfo() {
+  } // JAXB needs this
+
+  public FifoSchedulerInfo(final ResourceManager rm) {
+
+    RMContext rmContext = rm.getRMContext();
+
+    FifoScheduler fs = (FifoScheduler) rm.getResourceScheduler();
+    qName = fs.getQueueInfo("", false, false).getQueueName();
+    QueueInfo qInfo = fs.getQueueInfo(qName, true, true);
+
+    this.usedCapacity = qInfo.getCurrentCapacity();
+    this.capacity = qInfo.getCapacity();
+    this.minQueueMemoryCapacity = fs.getMinimumResourceCapability().getMemory();
+    this.maxQueueMemoryCapacity = fs.getMaximumResourceCapability().getMemory();
+    this.qstate = qInfo.getQueueState();
+
+    this.numNodes = rmContext.getRMNodes().size();
+    this.usedNodeCapacity = 0;
+    this.availNodeCapacity = 0;
+    this.totalNodeCapacity = 0;
+    this.numContainers = 0;
+
+    for (RMNode ni : rmContext.getRMNodes().values()) {
+      SchedulerNodeReport report = fs.getNodeReport(ni.getNodeID());
+      this.usedNodeCapacity += report.getUsedResource().getMemory();
+      this.availNodeCapacity += report.getAvailableResource().getMemory();
+      this.totalNodeCapacity += ni.getTotalCapability().getMemory();
+      this.numContainers += fs.getNodeReport(ni.getNodeID()).getNumContainers();
+    }
+  }
+
+  public int getNumNodes() {
+    return this.numNodes;
+  }
+
+  public int getUsedNodeCapacity() {
+    return this.usedNodeCapacity;
+  }
+
+  public int getAvailNodeCapacity() {
+    return this.availNodeCapacity;
+  }
+
+  public int getTotalNodeCapacity() {
+    return this.totalNodeCapacity;
+  }
+
+  public int getNumContainers() {
+    return this.numContainers;
+  }
+
+  public String getState() {
+    return this.qstate.toString();
+  }
+
+  public String getQueueName() {
+    return this.qName;
+  }
+
+  public int getMinQueueMemoryCapacity() {
+    return this.minQueueMemoryCapacity;
+  }
+
+  public int getMaxQueueMemoryCapacity() {
+    return this.maxQueueMemoryCapacity;
+  }
+
+  public float getCapacity() {
+    return this.capacity;
+  }
+
+  public float getUsedCapacity() {
+    return this.usedCapacity;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeState;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport;
+
+@XmlRootElement(name = "node")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class NodeInfo {
+
+  protected String rack;
+  protected RMNodeState state;
+  protected String id;
+  protected String nodeHostName;
+  protected String nodeHTTPAddress;
+  protected String healthStatus;
+  protected long lastHealthUpdate;
+  protected String healthReport;
+  protected int numContainers;
+  protected long usedMemoryMB;
+  protected long availMemoryMB;
+
+  @XmlTransient
+  protected boolean healthy;
+
+  public NodeInfo() {
+  } // JAXB needs this
+
+  public NodeInfo(RMNode ni, ResourceScheduler sched) {
+    NodeId id = ni.getNodeID();
+    SchedulerNodeReport report = sched.getNodeReport(id);
+    NodeHealthStatus health = ni.getNodeHealthStatus();
+    this.numContainers = 0;
+    this.usedMemoryMB = 0;
+    this.availMemoryMB = 0;
+    if (report != null) {
+      this.numContainers = report.getNumContainers();
+      this.usedMemoryMB = report.getUsedResource().getMemory();
+      this.availMemoryMB = report.getAvailableResource().getMemory();
+    }
+    this.id = id.toString();
+    this.rack = ni.getRackName();
+    this.nodeHostName = ni.getHostName();
+    this.state = ni.getState();
+    this.nodeHTTPAddress = ni.getHttpAddress();
+    this.healthy = health.getIsNodeHealthy();
+    this.healthStatus = health.getIsNodeHealthy() ? "Healthy" : "Unhealthy";
+    this.lastHealthUpdate = health.getLastHealthReportTime();
+    this.healthReport = String.valueOf(health.getHealthReport());
+  }
+
+  public boolean isHealthy() {
+    return this.healthy;
+  }
+
+  public String getRack() {
+    return this.rack;
+  }
+
+  public String getState() {
+    return String.valueOf(this.state);
+  }
+
+  public String getNodeId() {
+    return this.id;
+  }
+
+  public String getNodeHTTPAddress() {
+    return this.nodeHTTPAddress;
+  }
+
+  public String getHealthStatus() {
+    return this.healthStatus;
+  }
+
+  public long getLastHealthUpdate() {
+    return this.lastHealthUpdate;
+  }
+
+  public String getHealthReport() {
+    return this.healthReport;
+  }
+
+  public int getNumContainers() {
+    return this.numContainers;
+  }
+
+  public long getUsedMemory() {
+    return this.usedMemoryMB;
+  }
+
+  public long getAvailableMemory() {
+    return this.availMemoryMB;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodesInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodesInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodesInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodesInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "nodes")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class NodesInfo {
+
+  protected ArrayList<NodeInfo> node = new ArrayList<NodeInfo>();
+
+  public NodesInfo() {
+  } // JAXB needs this
+
+  public void add(NodeInfo nodeinfo) {
+    node.add(nodeinfo);
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+@XmlRootElement
+@XmlSeeAlso({ CapacitySchedulerInfo.class, FifoSchedulerInfo.class })
+public class SchedulerInfo {
+
+  public SchedulerInfo() {
+  } // JAXB needs this
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerTypeInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerTypeInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerTypeInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerTypeInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "scheduler")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class SchedulerTypeInfo {
+  protected SchedulerInfo schedulerInfo;
+
+  public SchedulerTypeInfo() {
+  } // JAXB needs this
+
+  public SchedulerTypeInfo(final SchedulerInfo scheduler) {
+    this.schedulerInfo = scheduler;
+  }
+
+}

Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/UserMetricsInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/UserMetricsInfo.java?rev=1213975&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/UserMetricsInfo.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/UserMetricsInfo.java Tue Dec 13 23:05:56 2011
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+
+@XmlRootElement(name = "userMetrics")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class UserMetricsInfo {
+
+  private static final long MB_IN_GB = 1024;
+
+  protected int appsSubmitted;
+  protected int runningContainers;
+  protected int pendingContainers;
+  protected int reservedContainers;
+  protected long reservedMB;
+  protected long pendingMB;
+  protected long allocatedMB;
+
+  @XmlTransient
+  protected boolean userMetricsAvailable;
+
+  public UserMetricsInfo() {
+  } // JAXB needs this
+
+  public UserMetricsInfo(final ResourceManager rm, final RMContext rmContext,
+      final String user) {
+    ResourceScheduler rs = rm.getResourceScheduler();
+    QueueMetrics metrics = rs.getRootQueueMetrics();
+    QueueMetrics userMetrics = metrics.getUserMetrics(user);
+    this.userMetricsAvailable = false;
+
+    if (userMetrics != null) {
+      this.userMetricsAvailable = true;
+      this.appsSubmitted = userMetrics.getAppsSubmitted();
+      this.runningContainers = userMetrics.getAllocatedContainers();
+      this.pendingContainers = userMetrics.getPendingContainers();
+      this.reservedContainers = userMetrics.getReservedContainers();
+      this.reservedMB = userMetrics.getReservedGB() * MB_IN_GB;
+      this.pendingMB = userMetrics.getPendingGB() * MB_IN_GB;
+      this.allocatedMB = userMetrics.getAllocatedGB() * MB_IN_GB;
+    }
+  }
+
+  public boolean metricsAvailable() {
+    return userMetricsAvailable;
+  }
+
+  public int getAppsSubmitted() {
+    return this.appsSubmitted;
+  }
+
+  public long getReservedMB() {
+    return this.reservedMB;
+  }
+
+  public long getAllocatedMB() {
+    return this.allocatedMB;
+  }
+
+  public long getPendingMB() {
+    return this.pendingMB;
+  }
+
+  public int getReservedContainers() {
+    return this.reservedContainers;
+  }
+
+  public int getRunningContainers() {
+    return this.runningContainers;
+  }
+
+  public int getPendingContainers() {
+    return this.pendingContainers;
+  }
+}

Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java?rev=1213975&r1=1213974&r2=1213975&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java Tue Dec 13 23:05:56 2011
@@ -30,7 +30,9 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
+import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.event.Dispatcher;
 import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncherEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFactory;
@@ -40,12 +42,16 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptLaunchFailedEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeState;
 import org.apache.hadoop.yarn.util.Records;
 import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 
-
 public class MockRM extends ResourceManager {
 
   public MockRM() {
@@ -59,48 +65,50 @@ public class MockRM extends ResourceMana
     rootLogger.setLevel(Level.DEBUG);
   }
 
-  public void waitForState(ApplicationId appId, RMAppState finalState) 
+  public void waitForState(ApplicationId appId, RMAppState finalState)
       throws Exception {
     RMApp app = getRMContext().getRMApps().get(appId);
     Assert.assertNotNull("app shouldn't be null", app);
     int timeoutSecs = 0;
-    while (!finalState.equals(app.getState()) &&
-        timeoutSecs++ < 20) {
-      System.out.println("App State is : " + app.getState() +
-          " Waiting for state : " + finalState);
+    while (!finalState.equals(app.getState()) && timeoutSecs++ < 20) {
+      System.out.println("App State is : " + app.getState()
+          + " Waiting for state : " + finalState);
       Thread.sleep(500);
     }
     System.out.println("App State is : " + app.getState());
-    Assert.assertEquals("App state is not correct (timedout)",
-        finalState, app.getState());
+    Assert.assertEquals("App state is not correct (timedout)", finalState,
+        app.getState());
   }
-  
-  // get new application id 
+
+  // get new application id
   public GetNewApplicationResponse getNewAppId() throws Exception {
     ClientRMProtocol client = getClientRMService();
-    return client.getNewApplication(Records.newRecord(GetNewApplicationRequest.class));	  
+    return client.getNewApplication(Records
+        .newRecord(GetNewApplicationRequest.class));
   }
 
-  //client
+  // client
   public RMApp submitApp(int masterMemory) throws Exception {
     ClientRMProtocol client = getClientRMService();
-    GetNewApplicationResponse resp = client.getNewApplication(Records.newRecord(GetNewApplicationRequest.class));
+    GetNewApplicationResponse resp = client.getNewApplication(Records
+        .newRecord(GetNewApplicationRequest.class));
     ApplicationId appId = resp.getApplicationId();
-    
-    SubmitApplicationRequest req = Records.newRecord(SubmitApplicationRequest.class);
-    ApplicationSubmissionContext sub = 
-        Records.newRecord(ApplicationSubmissionContext.class);
+
+    SubmitApplicationRequest req = Records
+        .newRecord(SubmitApplicationRequest.class);
+    ApplicationSubmissionContext sub = Records
+        .newRecord(ApplicationSubmissionContext.class);
     sub.setApplicationId(appId);
     sub.setApplicationName("");
     sub.setUser("");
-    ContainerLaunchContext clc = 
-        Records.newRecord(ContainerLaunchContext.class);
-    Resource capability = Records.newRecord(Resource.class);    
+    ContainerLaunchContext clc = Records
+        .newRecord(ContainerLaunchContext.class);
+    Resource capability = Records.newRecord(Resource.class);
     capability.setMemory(masterMemory);
     clc.setResource(capability);
     sub.setAMContainerSpec(clc);
     req.setApplicationSubmissionContext(sub);
-    
+
     client.submitApplication(req);
     // make sure app is immediately available after submit
     waitForState(appId, RMAppState.ACCEPTED);
@@ -113,28 +121,54 @@ public class MockRM extends ResourceMana
     return nm;
   }
 
+  public void sendNodeStarted(MockNM nm) throws Exception {
+    RMNodeImpl node = (RMNodeImpl) getRMContext().getRMNodes().get(
+        nm.getNodeId());
+    node.handle(new RMNodeEvent(nm.getNodeId(), RMNodeEventType.STARTED));
+  }
+
+  public void NMwaitForState(NodeId nodeid, RMNodeState finalState)
+      throws Exception {
+    RMNode node = getRMContext().getRMNodes().get(nodeid);
+    Assert.assertNotNull("node shouldn't be null", node);
+    int timeoutSecs = 0;
+    while (!finalState.equals(node.getState()) && timeoutSecs++ < 20) {
+      System.out.println("Node State is : " + node.getState()
+          + " Waiting for state : " + finalState);
+      Thread.sleep(500);
+    }
+    System.out.println("Node State is : " + node.getState());
+    Assert.assertEquals("Node state is not correct (timedout)", finalState,
+        node.getState());
+  }
+
   public void killApp(ApplicationId appId) throws Exception {
     ClientRMProtocol client = getClientRMService();
-    KillApplicationRequest req = Records.newRecord(KillApplicationRequest.class);
+    KillApplicationRequest req = Records
+        .newRecord(KillApplicationRequest.class);
     req.setApplicationId(appId);
     client.forceKillApplication(req);
   }
 
-  //from AMLauncher
-  public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId) throws Exception {
+  // from AMLauncher
+  public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId)
+      throws Exception {
     MockAM am = new MockAM(getRMContext(), masterService, appAttemptId);
     am.waitForState(RMAppAttemptState.ALLOCATED);
-    getRMContext().getDispatcher().getEventHandler().handle(
-        new RMAppAttemptEvent(appAttemptId, RMAppAttemptEventType.LAUNCHED));
+    getRMContext()
+        .getDispatcher()
+        .getEventHandler()
+        .handle(
+            new RMAppAttemptEvent(appAttemptId, RMAppAttemptEventType.LAUNCHED));
     return am;
   }
 
-  
-  public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId) throws Exception {
+  public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId)
+      throws Exception {
     MockAM am = new MockAM(getRMContext(), masterService, appAttemptId);
     am.waitForState(RMAppAttemptState.ALLOCATED);
-    getRMContext().getDispatcher().getEventHandler().handle(
-        new RMAppAttemptLaunchFailedEvent(appAttemptId, "Failed"));
+    getRMContext().getDispatcher().getEventHandler()
+        .handle(new RMAppAttemptLaunchFailedEvent(appAttemptId, "Failed"));
   }
 
   @Override
@@ -143,8 +177,9 @@ public class MockRM extends ResourceMana
         rmAppManager, applicationACLsManager) {
       @Override
       public void start() {
-        //override to not start rpc handler
+        // override to not start rpc handler
       }
+
       @Override
       public void stop() {
         // don't do anything
@@ -155,11 +190,12 @@ public class MockRM extends ResourceMana
   @Override
   protected ResourceTrackerService createResourceTrackerService() {
     return new ResourceTrackerService(getRMContext(), nodesListManager,
-        this.nmLivelinessMonitor, this.containerTokenSecretManager){
+        this.nmLivelinessMonitor, this.containerTokenSecretManager) {
       @Override
       public void start() {
-        //override to not start rpc handler
+        // override to not start rpc handler
       }
+
       @Override
       public void stop() {
         // don't do anything
@@ -173,8 +209,9 @@ public class MockRM extends ResourceMana
         this.appTokenSecretManager, scheduler) {
       @Override
       public void start() {
-        //override to not start rpc handler
+        // override to not start rpc handler
       }
+
       @Override
       public void stop() {
         // don't do anything
@@ -184,17 +221,18 @@ public class MockRM extends ResourceMana
 
   @Override
   protected ApplicationMasterLauncher createAMLauncher() {
-    return new ApplicationMasterLauncher(
-        this.appTokenSecretManager, this.clientToAMSecretManager,
-        getRMContext()) {
+    return new ApplicationMasterLauncher(this.appTokenSecretManager,
+        this.clientToAMSecretManager, getRMContext()) {
       @Override
       public void start() {
-        //override to not start rpc handler
+        // override to not start rpc handler
       }
+
       @Override
-      public void  handle(AMLauncherEvent appEvent) {
-        //don't do anything
+      public void handle(AMLauncherEvent appEvent) {
+        // don't do anything
       }
+
       @Override
       public void stop() {
         // don't do anything
@@ -203,31 +241,31 @@ public class MockRM extends ResourceMana
   }
 
   @Override
-  protected AdminService createAdminService(
-      ClientRMService clientRMService, 
+  protected AdminService createAdminService(ClientRMService clientRMService,
       ApplicationMasterService applicationMasterService,
       ResourceTrackerService resourceTrackerService) {
-    return new AdminService(
-        getConfig(), scheduler, getRMContext(), this.nodesListManager,
-        clientRMService, applicationMasterService, resourceTrackerService){
+    return new AdminService(getConfig(), scheduler, getRMContext(),
+        this.nodesListManager, clientRMService, applicationMasterService,
+        resourceTrackerService) {
       @Override
       public void start() {
-        //override to not start rpc handler
+        // override to not start rpc handler
       }
+
       @Override
       public void stop() {
         // don't do anything
       }
     };
   }
-  
+
   public NodesListManager getNodesListManager() {
     return this.nodesListManager;
   }
 
   @Override
   protected void startWepApp() {
-    //override to disable webapp
+    // override to disable webapp
   }
 
 }

Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java?rev=1213975&r1=1213974&r2=1213975&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java Tue Dec 13 23:05:56 2011
@@ -284,6 +284,11 @@ public abstract class MockAsm extends Mo
       public FinalApplicationStatus getFinalApplicationStatus() {
         return FinalApplicationStatus.UNDEFINED;
       }
+
+      @Override
+      public RMAppAttempt getCurrentAppAttempt() {
+        return null;
+      }
       
     };
   }



Mime
View raw message