hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1127765 - in /hadoop/mapreduce/branches/MR-279: ./ yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/ yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodem...
Date Thu, 26 May 2011 03:00:11 GMT
Author: mahadev
Date: Thu May 26 03:00:10 2011
New Revision: 1127765

URL: http://svn.apache.org/viewvc?rev=1127765&view=rev
Log:
MAPREDUCE-2532. Metrics for NodeManager (Luke Lu via mahadev)

Added:
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/NodeManagerMetrics.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java
Modified:
    hadoop/mapreduce/branches/MR-279/.gitignore
    hadoop/mapreduce/branches/MR-279/CHANGES.txt
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/DummyContainerManager.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java
    hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java

Modified: hadoop/mapreduce/branches/MR-279/.gitignore
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/.gitignore?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/.gitignore (original)
+++ hadoop/mapreduce/branches/MR-279/.gitignore Thu May 26 03:00:10 2011
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 *~
+.eclipse.templates/
 .classpath
 .project
 .launches

Modified: hadoop/mapreduce/branches/MR-279/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/CHANGES.txt?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/CHANGES.txt (original)
+++ hadoop/mapreduce/branches/MR-279/CHANGES.txt Thu May 26 03:00:10 2011
@@ -4,6 +4,8 @@ Trunk (unreleased changes)
 
   MAPREDUCE-279
 
+    MAPREDUCE-2532. Metrics for NodeManager (Luke Lu via mahadev)
+
     MAPREDUCE-2527. Metrics for MRAppMaster (Luke lu via mahadev)
 
     Add debug config for delaying delete of local files. (cdouglas)

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java Thu May 26 03:00:10 2011
@@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentSk
 
 import org.apache.hadoop.NodeHealthCheckerService;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.yarn.YarnException;
@@ -43,11 +44,13 @@ import org.apache.hadoop.yarn.server.api
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.ContainerManagerImpl;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.server.nodemanager.webapp.WebServer;
 import org.apache.hadoop.yarn.service.CompositeService;
 import org.apache.hadoop.yarn.service.Service;
 
 public class NodeManager extends CompositeService {
+  protected final NodeManagerMetrics metrics = NodeManagerMetrics.create();
 
   public NodeManager() {
     super(NodeManager.class.getName());
@@ -55,7 +58,8 @@ public class NodeManager extends Composi
 
   protected NodeStatusUpdater createNodeStatusUpdater(Context context,
       Dispatcher dispatcher, NodeHealthCheckerService healthChecker) {
-    return new NodeStatusUpdaterImpl(context, dispatcher, healthChecker);
+    return new NodeStatusUpdaterImpl(context, dispatcher, healthChecker,
+                                     metrics);
   }
 
   protected NodeResourceMonitor createNodeResourceMonitor() {
@@ -65,7 +69,8 @@ public class NodeManager extends Composi
   protected ContainerManagerImpl createContainerManager(Context context,
       ContainerExecutor exec, DeletionService del,
       NodeStatusUpdater nodeStatusUpdater) {
-    return new ContainerManagerImpl(context, exec, del, nodeStatusUpdater);
+    return new ContainerManagerImpl(context, exec, del, nodeStatusUpdater,
+                                    metrics);
   }
 
   protected WebServer createWebServer(Context nmContext,
@@ -125,6 +130,9 @@ public class NodeManager extends Composi
             NodeManager.this.stop();
           }
         });
+
+    DefaultMetricsSystem.initialize("NodeManager");
+
     super.init(conf);
     // TODO add local dirs to del
   }
@@ -139,6 +147,12 @@ public class NodeManager extends Composi
     super.start();
   }
 
+  @Override
+  public void stop() {
+    super.stop();
+    DefaultMetricsSystem.shutdown();
+  }
+
   public static class NMContext implements Context {
 
     private final ConcurrentMap<ApplicationId, Application> applications =

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeStatusUpdaterImpl.java Thu May 26 03:00:10 2011
@@ -55,6 +55,7 @@ import org.apache.hadoop.yarn.server.api
 import org.apache.hadoop.yarn.server.api.records.NodeStatus;
 import org.apache.hadoop.yarn.server.api.records.RegistrationResponse;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.service.AbstractService;
 
 public class NodeStatusUpdaterImpl extends AbstractService implements
@@ -82,13 +83,15 @@ public class NodeStatusUpdaterImpl exten
   private RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
 
   private final NodeHealthCheckerService healthChecker;
+  private final NodeManagerMetrics metrics;
 
   public NodeStatusUpdaterImpl(Context context, Dispatcher dispatcher,
-      NodeHealthCheckerService healthChecker) {
+      NodeHealthCheckerService healthChecker, NodeManagerMetrics metrics) {
     super(NodeStatusUpdaterImpl.class.getName());
     this.healthChecker = healthChecker;
     this.context = context;
     this.dispatcher = dispatcher;
+    this.metrics = metrics;
   }
 
   @Override
@@ -99,9 +102,10 @@ public class NodeStatusUpdaterImpl exten
     this.heartBeatInterval =
         conf.getLong(NMConfig.HEARTBEAT_INTERVAL,
             NMConfig.DEFAULT_HEARTBEAT_INTERVAL);
-    int memory = conf.getInt(NMConfig.NM_VMEM_GB, 8);
+    int memory = conf.getInt(NMConfig.NM_VMEM_GB, NMConfig.DEFAULT_NM_VMEM_GB);
     this.totalResource = recordFactory.newRecordInstance(Resource.class);
     this.totalResource.setMemory(memory * 1024);
+    metrics.addResource(totalResource);
     super.init(conf);
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java Thu May 26 03:00:10 2011
@@ -87,6 +87,7 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitor;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorEventType;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
 import org.apache.hadoop.yarn.service.CompositeService;
 import org.apache.hadoop.yarn.service.Service;
@@ -105,22 +106,25 @@ public class ContainerManagerImpl extend
   private final ResourceLocalizationService rsrcLocalizationSrvc;
   private final ContainersLauncher containersLauncher;
   private final AuxServices auxiluaryServices;
+  private final NodeManagerMetrics metrics;
 
   private final NodeStatusUpdater nodeStatusUpdater;
   private ContainerTokenSecretManager containerTokenSecretManager;
 
   private final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
-  protected AsyncDispatcher dispatcher;
+  protected final AsyncDispatcher dispatcher;
 
   private final DeletionService deletionService;
 
   public ContainerManagerImpl(Context context, ContainerExecutor exec,
-      DeletionService deletionContext, NodeStatusUpdater nodeStatusUpdater) {
+      DeletionService deletionContext, NodeStatusUpdater nodeStatusUpdater,
+      NodeManagerMetrics metrics) {
     super(ContainerManagerImpl.class.getName());
     this.context = context;
     dispatcher = new AsyncDispatcher();
     this.deletionService = deletionContext;
+    this.metrics = metrics;
 
     rsrcLocalizationSrvc =
         createResourceLocalizationService(exec, deletionContext);
@@ -261,7 +265,7 @@ public class ContainerManagerImpl extend
     }
 
     Container container =
-        new ContainerImpl(this.dispatcher, launchContext, credentials);
+        new ContainerImpl(this.dispatcher, launchContext, credentials, metrics);
     ContainerId containerID = launchContext.getContainerId();
     ApplicationId applicationID = containerID.getAppId();
     if (context.getContainers().putIfAbsent(containerID, container) != null) {
@@ -281,6 +285,8 @@ public class ContainerManagerImpl extend
     // TODO: Validate the request
     dispatcher.getEventHandler().handle(new ApplicationInitEvent(container));
     StartContainerResponse response = recordFactory.newRecordInstance(StartContainerResponse.class);
+    metrics.launchedContainer();
+    metrics.allocateContainer(launchContext.getResource());
     return response;
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java Thu May 26 03:00:10 2011
@@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation.event.LogAggregatorContainerFinishedEvent;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainerStartMonitoringEvent;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainerStopMonitoringEvent;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.state.InvalidStateTransitonException;
 import org.apache.hadoop.yarn.state.MultipleArcTransition;
 import org.apache.hadoop.yarn.state.SingleArcTransition;
@@ -66,6 +67,7 @@ public class ContainerImpl implements Co
   private final Lock writeLock;
   private final Dispatcher dispatcher;
   private final Credentials credentials;
+  private final NodeManagerMetrics metrics;
   private final ContainerLaunchContext launchContext;
   private String exitCode = "NA";
   private final StringBuilder diagnostics;
@@ -78,11 +80,13 @@ public class ContainerImpl implements Co
     new HashMap<Path,String>();
 
   public ContainerImpl(Dispatcher dispatcher,
-      ContainerLaunchContext launchContext, Credentials creds) {
+      ContainerLaunchContext launchContext, Credentials creds,
+      NodeManagerMetrics metrics) {
     this.dispatcher = dispatcher;
     this.launchContext = launchContext;
     this.diagnostics = new StringBuilder();
     this.credentials = creds;
+    this.metrics = metrics;
 
     ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
     this.readLock = readWriteLock.readLock();
@@ -342,6 +346,39 @@ public class ContainerImpl implements Co
     }
   }
 
+  @SuppressWarnings("fallthrough")
+  private void finished() {
+    switch (getContainerState()) {
+      case EXITED_WITH_SUCCESS:
+        metrics.endRunningContainer();
+        metrics.completedContainer();
+        break;
+      case EXITED_WITH_FAILURE:
+        metrics.endRunningContainer();
+        // fall through
+      case LOCALIZATION_FAILED:
+        metrics.failedContainer();
+        break;
+      case CONTAINER_CLEANEDUP_AFTER_KILL:
+        metrics.endRunningContainer();
+        // fall through
+      case NEW:
+        metrics.killedContainer();
+    }
+
+    metrics.releaseContainer(getLaunchContext().getResource());
+
+    // Inform the application
+    ContainerId containerID = getContainerID();
+    EventHandler eventHandler = dispatcher.getEventHandler();
+    eventHandler.handle(new ApplicationContainerFinishedEvent(containerID));
+    // Remove the container from the resource-monitor
+    eventHandler.handle(new ContainerStopMonitoringEvent(containerID));
+    // Tell the logService too
+    eventHandler.handle(new LogAggregatorContainerFinishedEvent(
+        containerID, exitCode));
+  }
+
   static class ContainerTransition implements
       SingleArcTransition<ContainerImpl, ContainerEvent> {
 
@@ -359,6 +396,7 @@ public class ContainerImpl implements Co
     public ContainerState transition(ContainerImpl container,
         ContainerEvent event) {
       final ContainerLaunchContext ctxt = container.getLaunchContext();
+      container.metrics.initingContainer();
 
       // Inform the AuxServices about the opaque serviceData
       Map<String,ByteBuffer> csd = ctxt.getAllServiceData();
@@ -411,6 +449,7 @@ public class ContainerImpl implements Co
           container.dispatcher.getEventHandler().handle(
               new ContainerLocalizationEvent(
                LocalizationEventType.CLEANUP_CONTAINER_RESOURCES, container));
+          container.metrics.endInitingContainer();
           return ContainerState.LOCALIZATION_FAILED;
         }
         if (!publicRsrc.isEmpty()) {
@@ -433,6 +472,7 @@ public class ContainerImpl implements Co
         container.dispatcher.getEventHandler().handle(
             new ContainersLauncherEvent(container,
                 ContainersLauncherEventType.LAUNCH_CONTAINER));
+        container.metrics.endInitingContainer();
         return ContainerState.LOCALIZED;
       }
     }
@@ -460,6 +500,7 @@ public class ContainerImpl implements Co
       container.dispatcher.getEventHandler().handle(
           new ContainersLauncherEvent(container,
               ContainersLauncherEventType.LAUNCH_CONTAINER));
+      container.metrics.endInitingContainer();
       return ContainerState.LOCALIZED;
     }
   }
@@ -476,6 +517,7 @@ public class ContainerImpl implements Co
       container.dispatcher.getEventHandler().handle(
           new ContainerStartMonitoringEvent(container.getContainerID(),
               vmemBytes, -1));
+      container.metrics.runningContainer();
     }
   }
 
@@ -521,7 +563,7 @@ public class ContainerImpl implements Co
       container.dispatcher.getEventHandler().handle(
           new ContainerLocalizationEvent(
             LocalizationEventType.CLEANUP_CONTAINER_RESOURCES, container));
-
+      container.metrics.endInitingContainer();
     }
   }
 
@@ -558,15 +600,7 @@ public class ContainerImpl implements Co
       SingleArcTransition<ContainerImpl, ContainerEvent> {
     @Override
     public void transition(ContainerImpl container, ContainerEvent event) {
-      // Inform the application
-      ContainerId containerID = container.getContainerID();
-      EventHandler eventHandler = container.dispatcher.getEventHandler();
-      eventHandler.handle(new ApplicationContainerFinishedEvent(containerID));
-      // Remove the container from the resource-monitor
-      eventHandler.handle(new ContainerStopMonitoringEvent(containerID));
-      // Tell the logService too
-      eventHandler.handle(new LogAggregatorContainerFinishedEvent(
-          containerID, container.exitCode));
+      container.finished();
     }
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java Thu May 26 03:00:10 2011
@@ -39,8 +39,8 @@ public class ContainersMonitorImpl exten
   private long monitoringInterval;
   private MonitoringThread monitoringThread;
 
-  List<ContainerId> containersToBeRemoved;
-  Map<ContainerId, ProcessTreeInfo> containersToBeAdded;
+  final List<ContainerId> containersToBeRemoved;
+  final Map<ContainerId, ProcessTreeInfo> containersToBeAdded;
   Map<ContainerId, ProcessTreeInfo> trackingContainers =
       new HashMap<ContainerId, ProcessTreeInfo>();
 
@@ -308,7 +308,7 @@ public class ContainersMonitorImpl exten
 
         // Print the processTrees for debugging.
         if (LOG.isDebugEnabled()) {
-          StringBuffer tmp = new StringBuffer("[ ");
+          StringBuilder tmp = new StringBuilder("[ ");
           for (ProcessTreeInfo p : trackingContainers.values()) {
             tmp.append(p.getPID());
             tmp.append(" ");

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/NodeManagerMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/NodeManagerMetrics.java?rev=1127765&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/NodeManagerMetrics.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/metrics/NodeManagerMetrics.java Thu May 26 03:00:10 2011
@@ -0,0 +1,102 @@
+/*
+ * 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.nodemanager.metrics;
+
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.annotation.Metric;
+import org.apache.hadoop.metrics2.annotation.Metrics;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.lib.MutableCounterInt;
+import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
+import org.apache.hadoop.metrics2.source.JvmMetrics;
+import org.apache.hadoop.yarn.api.records.Resource;
+
+@Metrics(about="Metrics for node manager", context="yarn")
+public class NodeManagerMetrics {
+  @Metric MutableCounterInt containersLaunched;
+  @Metric MutableCounterInt containersCompleted;
+  @Metric MutableCounterInt containersFailed;
+  @Metric MutableCounterInt containersKilled;
+  @Metric("# of initializing containers")
+      MutableGaugeInt containersIniting;
+  @Metric MutableGaugeInt containersRunning;
+  @Metric("Current allocated memory in GB")
+      MutableGaugeInt allocatedGB;
+  @Metric("Current # of allocated containers")
+      MutableGaugeInt allocatedContainers;
+  @Metric MutableGaugeInt availableGB;
+
+  public static NodeManagerMetrics create() {
+    return create(DefaultMetricsSystem.instance());
+  }
+
+  static NodeManagerMetrics create(MetricsSystem ms) {
+    JvmMetrics.create("NodeManager", null, ms);
+    return ms.register(new NodeManagerMetrics());
+  }
+
+  // Potential instrumentation interface methods
+
+  public void launchedContainer() {
+    containersLaunched.incr();
+  }
+
+  public void completedContainer() {
+    containersCompleted.incr();
+  }
+
+  public void failedContainer() {
+    containersFailed.incr();
+  }
+
+  public void killedContainer() {
+    containersKilled.incr();
+  }
+
+  public void initingContainer() {
+    containersIniting.incr();
+  }
+
+  public void endInitingContainer() {
+    containersIniting.decr();
+  }
+
+  public void runningContainer() {
+    containersRunning.incr();
+  }
+
+  public void endRunningContainer() {
+    containersRunning.decr();
+  }
+
+  public void allocateContainer(Resource res) {
+    allocatedContainers.incr();
+    allocatedGB.incr(res.getMemory() / 1024);
+    availableGB.decr(res.getMemory() / 1024);
+  }
+
+  public void releaseContainer(Resource res) {
+    allocatedContainers.decr();
+    allocatedGB.decr(res.getMemory() / 1024);
+    availableGB.incr(res.getMemory() / 1024);
+  }
+
+  public void addResource(Resource res) {
+    availableGB.incr(res.getMemory() / 1024);
+  }
+}

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/DummyContainerManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/DummyContainerManager.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/DummyContainerManager.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/DummyContainerManager.java Thu May 26 03:00:10 2011
@@ -46,6 +46,7 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.LocalizationEvent;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation.LogAggregationService;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.logaggregation.event.LogAggregatorEvent;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 
 public class DummyContainerManager extends ContainerManagerImpl {
 
@@ -55,8 +56,9 @@ public class DummyContainerManager exten
   private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
   public DummyContainerManager(Context context, ContainerExecutor exec,
-      DeletionService deletionContext, NodeStatusUpdater nodeStatusUpdater) {
-    super(context, exec, deletionContext, nodeStatusUpdater);
+      DeletionService deletionContext, NodeStatusUpdater nodeStatusUpdater,
+      NodeManagerMetrics metrics) {
+    super(context, exec, deletionContext, nodeStatusUpdater, metrics);
   }
 
   @Override

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java Thu May 26 03:00:10 2011
@@ -42,6 +42,7 @@ import org.apache.hadoop.yarn.factory.pr
 import org.apache.hadoop.yarn.server.api.ResourceTracker;
 import org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.BaseContainerManagerTest;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.junit.Test;
 
 public class TestEventFlow {
@@ -81,8 +82,9 @@ public class TestEventFlow {
     DeletionService del = new DeletionService(exec);
     Dispatcher dispatcher = new AsyncDispatcher();
     NodeHealthCheckerService healthChecker = null;
+    NodeManagerMetrics metrics = NodeManagerMetrics.create();
     NodeStatusUpdater nodeStatusUpdater =
-        new NodeStatusUpdaterImpl(context, dispatcher, healthChecker) {
+        new NodeStatusUpdaterImpl(context, dispatcher, healthChecker, metrics) {
       @Override
       protected ResourceTracker getRMClient() {
         return new LocalRMInterface();
@@ -96,7 +98,7 @@ public class TestEventFlow {
     };
 
     DummyContainerManager containerManager =
-        new DummyContainerManager(context, exec, del, nodeStatusUpdater);
+        new DummyContainerManager(context, exec, del, nodeStatusUpdater, metrics);
     containerManager.init(conf);
     containerManager.start();
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java Thu May 26 03:00:10 2011
@@ -48,6 +48,7 @@ import org.apache.hadoop.yarn.server.api
 import org.apache.hadoop.yarn.server.api.records.RegistrationResponse;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerImpl;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.service.Service.STATE;
 import org.junit.After;
 import org.junit.Assert;
@@ -114,7 +115,7 @@ public class TestNodeStatusUpdater {
         launchContext.setContainerId(firstContainerID);
         launchContext.setResource(recordFactory.newRecordInstance(Resource.class));
         launchContext.getResource().setMemory(2);
-        Container container = new ContainerImpl(null, launchContext, null);
+        Container container = new ContainerImpl(null, launchContext, null, null);
         this.context.getContainers().put(firstContainerID, container);
       } else if (heartBeatID == 2) {
         // Checks on the RM end
@@ -140,7 +141,7 @@ public class TestNodeStatusUpdater {
         launchContext.setContainerId(secondContainerID);
         launchContext.setResource(recordFactory.newRecordInstance(Resource.class));
         launchContext.getResource().setMemory(3);
-        Container container = new ContainerImpl(null, launchContext, null);
+        Container container = new ContainerImpl(null, launchContext, null, null);
         this.context.getContainers().put(secondContainerID, container);
       } else if (heartBeatID == 3) {
         // Checks on the RM end
@@ -174,8 +175,8 @@ public class TestNodeStatusUpdater {
     private Context context;
 
     public MyNodeStatusUpdater(Context context, Dispatcher dispatcher,
-        NodeHealthCheckerService healthChecker) {
-      super(context, dispatcher, healthChecker);
+        NodeHealthCheckerService healthChecker, NodeManagerMetrics metrics) {
+      super(context, dispatcher, healthChecker, metrics);
       this.context = context;
     }
 
@@ -202,7 +203,8 @@ public class TestNodeStatusUpdater {
       @Override
       protected NodeStatusUpdater createNodeStatusUpdater(Context context,
           Dispatcher dispatcher, NodeHealthCheckerService healthChecker) {
-        return new MyNodeStatusUpdater(context, dispatcher, healthChecker);
+        return new MyNodeStatusUpdater(context, dispatcher, healthChecker,
+                                       metrics);
       }
     };
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java Thu May 26 03:00:10 2011
@@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.service.Service.STATE;
 import org.junit.After;
 import org.junit.Before;
@@ -61,9 +62,6 @@ public abstract class BaseContainerManag
 
   protected static RecordFactory recordFactory = RecordFactoryProvider
       .getRecordFactory(null);
-  static {
-    DefaultMetricsSystem.setMiniClusterMode(true);
-  }
 
   protected static FileContext localFS;
   protected static File localDir;
@@ -71,6 +69,8 @@ public abstract class BaseContainerManag
   protected static File remoteLogDir;
   protected static File tmpDir;
 
+  protected final NodeManagerMetrics metrics = NodeManagerMetrics.create();
+
   public BaseContainerManagerTest() throws UnsupportedFileSystemException {
     localFS = FileContext.getLocalFSFileContext();
     localDir =
@@ -95,7 +95,7 @@ public abstract class BaseContainerManag
   protected String user = "nobody";
 
   protected NodeStatusUpdater nodeStatusUpdater = new NodeStatusUpdaterImpl(
-      context, new AsyncDispatcher(), null) {
+      context, new AsyncDispatcher(), null, metrics) {
     @Override
     protected ResourceTracker getRMClient() {
       return new LocalRMInterface();
@@ -147,7 +147,8 @@ public abstract class BaseContainerManag
 
     exec = createContainerExecutor();
     containerManager =
-        new ContainerManagerImpl(context, exec, delSrvc, nodeStatusUpdater);
+        new ContainerManagerImpl(context, exec, delSrvc, nodeStatusUpdater,
+                                 metrics);
     containerManager.init(conf);
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java Thu May 26 03:00:10 2011
@@ -264,8 +264,8 @@ public class TestContainerManager extend
       IOException {
     // Real del service
     delSrvc = new DeletionService(exec);
-    containerManager =
-        new ContainerManagerImpl(context, exec, delSrvc, nodeStatusUpdater);
+    containerManager = new ContainerManagerImpl(context, exec, delSrvc,
+        nodeStatusUpdater, metrics);
     containerManager.init(conf);
     containerManager.start();
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java Thu May 26 03:00:10 2011
@@ -17,6 +17,8 @@
 */
 package org.apache.hadoop.yarn.server.nodemanager.containermanager.container;
 
+import org.apache.hadoop.yarn.event.Dispatcher;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import java.net.URISyntaxException;
 
 import java.nio.ByteBuffer;
@@ -40,6 +42,7 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.event.DrainDispatcher;
 import org.apache.hadoop.yarn.event.EventHandler;
+import org.apache.hadoop.yarn.server.nodemanager.NodeManager;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServicesEvent;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServicesEventType;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainersLauncherEvent;
@@ -57,6 +60,8 @@ import static org.mockito.Mockito.*;
 
 public class TestContainer {
 
+  final NodeManagerMetrics metrics = NodeManagerMetrics.create();
+
   /**
    * Verify correct container request events sent to localizer.
    */
@@ -83,7 +88,7 @@ public class TestContainer {
       final Map<String,LocalResource> localResources = createLocalResources(r);
       when(ctxt.getAllLocalResources()).thenReturn(localResources);
 
-      final Container c = new ContainerImpl(dispatcher, ctxt, null);
+      final Container c = newContainer(dispatcher, ctxt);
       assertEquals(ContainerState.NEW, c.getContainerState());
 
       // Verify request for public/private resources to localizer
@@ -135,8 +140,7 @@ public class TestContainer {
       System.out.println("testLocalizationLaunch seed: " + seed);
       final Map<String,LocalResource> localResources = createLocalResources(r);
       when(ctxt.getAllLocalResources()).thenReturn(localResources);
-
-      final Container c = new ContainerImpl(dispatcher, ctxt, null);
+      final Container c = newContainer(dispatcher, ctxt);
       assertEquals(ContainerState.NEW, c.getContainerState());
 
       c.handle(new ContainerEvent(cId, ContainerEventType.INIT_CONTAINER));
@@ -208,7 +212,7 @@ public class TestContainer {
       final Map<String,ByteBuffer> serviceData = createServiceData(r);
       when(ctxt.getAllServiceData()).thenReturn(serviceData);
 
-      final Container c = new ContainerImpl(dispatcher, ctxt, null);
+      final Container c = newContainer(dispatcher, ctxt);
       assertEquals(ContainerState.NEW, c.getContainerState());
 
       // Verify propagation of service data to AuxServices
@@ -331,4 +335,7 @@ public class TestContainer {
     return serviceData;
   }
 
+  Container newContainer(Dispatcher disp, ContainerLaunchContext ctx) {
+    return new ContainerImpl(disp, ctx, null, metrics);
+  }
 }

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java?rev=1127765&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/metrics/TestNodeManagerMetrics.java Thu May 26 03:00:10 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.nodemanager.metrics;
+
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+import static org.apache.hadoop.test.MetricsAsserts.*;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.util.Records;
+
+import org.junit.Test;
+
+public class TestNodeManagerMetrics {
+  static final int GiB = 1024; // MiB
+
+  @Test public void testNames() {
+    NodeManagerMetrics metrics = NodeManagerMetrics.create();
+    Resource total = Records.newRecord(Resource.class);
+    total.setMemory(8*GiB);
+    Resource resource = Records.newRecord(Resource.class);
+    resource.setMemory(1*GiB);
+
+    metrics.addResource(total);
+
+    for (int i = 5; i-- > 0;) {
+      metrics.launchedContainer();
+      metrics.allocateContainer(resource);
+    }
+
+    metrics.initingContainer();
+    metrics.endInitingContainer();
+    metrics.runningContainer();
+    metrics.endRunningContainer();
+    metrics.completedContainer();
+    metrics.releaseContainer(resource);
+
+    metrics.failedContainer();
+    metrics.releaseContainer(resource);
+
+    metrics.killedContainer();
+    metrics.releaseContainer(resource);
+
+    metrics.initingContainer();
+    metrics.runningContainer();
+
+    checkMetrics(5, 1, 1, 1, 1, 1, 2, 2, 6);
+  }
+
+  private void checkMetrics(int launched, int completed, int failed, int killed,
+                            int initing, int running, int allocatedGB,
+                            int allocatedContainers, int availableGB) {
+    MetricsRecordBuilder rb = getMetrics("NodeManagerMetrics");
+    assertCounter("ContainersLaunched", launched, rb);
+    assertCounter("ContainersCompleted", completed, rb);
+    assertCounter("ContainersFailed", failed, rb);
+    assertCounter("ContainersKilled", killed, rb);
+    assertGauge("ContainersIniting", initing, rb);
+    assertGauge("ContainersRunning", running, rb);
+    assertGauge("AllocatedGB", allocatedGB, rb);
+    assertGauge("AllocatedContainers", allocatedContainers, rb);
+    assertGauge("AvailableGB", availableGB, rb);
+  }
+}

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java Thu May 26 03:00:10 2011
@@ -22,15 +22,11 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
-import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.event.AsyncDispatcher;
 import org.apache.hadoop.yarn.event.Dispatcher;
 import org.apache.hadoop.yarn.factories.RecordFactory;
@@ -43,6 +39,7 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerImpl;
 import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState;
+import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
 import org.apache.hadoop.yarn.util.BuilderUtils;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.junit.Before;
@@ -51,8 +48,8 @@ import static org.mockito.Mockito.*;
 
 public class TestNMWebServer {
 
-  private static final File testRootDir = new File("target-"
-      + TestNMWebServer.class.getName());
+  private static final File testRootDir = new File("target",
+      TestNMWebServer.class.getSimpleName());
 
   @Before
   public void setup() {
@@ -94,6 +91,7 @@ public class TestNMWebServer {
         BuilderUtils.newContainerId(recordFactory, appId, 0);
     ContainerId container2 =
         BuilderUtils.newContainerId(recordFactory, appId, 1);
+    NodeManagerMetrics metrics = mock(NodeManagerMetrics.class);
     for (ContainerId containerId : new ContainerId[] { container1,
         container2}) {
       // TODO: Use builder utils
@@ -101,7 +99,9 @@ public class TestNMWebServer {
           recordFactory.newRecordInstance(ContainerLaunchContext.class);
       launchContext.setContainerId(containerId);
       launchContext.setUser(user);
-      Container container = new ContainerImpl(dispatcher, launchContext, null) {
+      Container container =
+          new ContainerImpl(dispatcher, launchContext, null, metrics) {
+        @Override
         public ContainerState getContainerState() {
           return ContainerState.RUNNING;
         };

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java?rev=1127765&r1=1127764&r2=1127765&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java Thu May 26 03:00:10 2011
@@ -168,7 +168,7 @@ public class MiniYARNCluster extends Com
           protected NodeStatusUpdater createNodeStatusUpdater(Context context,
               Dispatcher dispatcher, NodeHealthCheckerService healthChecker) {
             return new NodeStatusUpdaterImpl(context, dispatcher,
-                healthChecker) {
+                healthChecker, metrics) {
               @Override
               protected ResourceTracker getRMClient() {
                 // For in-process communication without RPC



Mime
View raw message