QueueMetrics implements MetricsSource { public synchronized static QueueMetrics forQueue(String queueName, Queue parent, boolean enableUserMetrics, Configuration conf) { return forQueue(DefaultMetricsSystem.instance(), queueName, parent, enableUserMetrics, conf); } QueueMetrics(MetricsSystem ms, String queueName, Queue parent,
      boolean enableUserMetrics, Configuration conf); synchronized static QueueMetrics forQueue(String queueName,
      Queue parent, boolean enableUserMetrics, Configuration conf); @Private synchronized static void clearQueueMetrics(); static Map<String, QueueMetrics> getQueueMetrics(); synchronized static QueueMetrics forQueue(MetricsSystem ms,
      String queueName, Queue parent, boolean enableUserMetrics,
      Configuration conf); synchronized QueueMetrics getUserMetrics(String userName); synchronized QueueMetrics getPartitionQueueMetrics(String partition); void getMetrics(MetricsCollector collector, boolean all); void submitApp(String user); void submitAppAttempt(String user); void runAppAttempt(ApplicationId appId, String user); void finishAppAttempt(
      ApplicationId appId, boolean isPending, String user); void finishApp(String user, RMAppState rmAppFinalState); void moveAppFrom(AppSchedulingInfo app); void moveAppTo(AppSchedulingInfo app); void setAvailableResourcesToQueue(String partition, Resource limit); void setAvailableResources(Resource limit); void setAvailableResourcesToQueue(Resource limit); void setAvailableResourcesToUser(String partition, String user,
      Resource limit); void incrPendingResources(String partition, String user,
      int containers, Resource res); void internalIncrPendingResources(String partition, String user,
      int containers, Resource res); void decrPendingResources(String partition, String user,
      int containers, Resource res); void incrNodeTypeAggregations(String user, NodeType type); void allocateResources(String partition, String user, int containers,
      Resource res, boolean decrPending); void internalAllocateResources(String partition, String user,
      int containers, Resource res, boolean decrPending); void allocateResources(String partition, String user, Resource res); void releaseResources(String partition, String user, int containers,
      Resource res); void internalReleaseResources(String partition, String user,
      int containers, Resource res); void preemptContainer(); void updatePreemptedMemoryMBSeconds(long mbSeconds); void updatePreemptedVcoreSeconds(long vcoreSeconds); void updatePreemptedResources(Resource res); void updatePreemptedForCustomResources(Resource res); void updatePreemptedSecondsForCustomResources(Resource res,
          long seconds); void reserveResource(String partition, String user, Resource res); void incrReserveResources(Resource res); void unreserveResource(String partition, String user, Resource res); void decrReserveResource(Resource res); void incrActiveUsers(); void decrActiveUsers(); void activateApp(String user); void deactivateApp(String user); void addAppAttemptFirstContainerAllocationDelay(long latency); int getAppsSubmitted(); int getAppsRunning(); int getAppsPending(); int getAppsCompleted(); int getAppsKilled(); int getAppsFailed(); Resource getAllocatedResources(); Resource getAvailableResources(); Resource getPendingResources(); Resource getReservedResources(); @VisibleForTesting QueueMetricsCustomResource getAggregatedPreemptedSecondsResources(); @VisibleForTesting MutableCounterLong getAggregateMemoryMBSecondsPreempted(); @VisibleForTesting MutableCounterLong getAggregateVcoreSecondsPreempted(); @VisibleForTesting long getAggregateMemoryMBPreempted(); @VisibleForTesting long getAggregateVcoresPreempted(); long getAllocatedMB(); int getAllocatedVirtualCores(); int getAllocatedContainers(); long getAvailableMB(); int getAvailableVirtualCores(); long getPendingMB(); int getPendingVirtualCores(); int getPendingContainers(); long getReservedMB(); int getReservedVirtualCores(); int getReservedContainers(); int getActiveUsers(); int getActiveApps(); MetricsSystem getMetricsSystem(); long getAggregateAllocatedContainers(); long getAggregateNodeLocalContainersAllocated(); long getAggregateRackLocalContainersAllocated(); long getAggregateOffSwitchContainersAllocated(); long getAggegatedReleasedContainers(); long getAggregatePreemptedContainers(); void fillInValuesFromAvailableResources(Resource fromResource,
      Resource targetResource); @VisibleForTesting QueueMetricsForCustomResources getQueueMetricsForCustomResources(); void setQueueMetricsForCustomResources(
      QueueMetricsForCustomResources metrics); void setParent(QueueMetrics parent); Queue getParentQueue(); static final String DEFAULT_PARTITION; static final String DEFAULT_PARTITION_JMX_STR; static final String METRIC_NAME_DELIMITER; }
@Test public void testCollectAllMetrics() { String queueName = "single"; QueueMetrics.forQueue(ms, queueName, null, false, conf); MetricsSource queueSource = queueSource(ms, queueName); AppMetricsChecker.create() .checkAgainst(queueSource, true); try { AppMetricsChecker.create() .checkAgainst(queueSource, false); Assert.fail(); } catch (AssertionError e) { Assert.assertTrue( e.getMessage().contains("Expected exactly one metric for name ")); } AppMetricsChecker.create() .checkAgainst(queueSource, true); }