ClusterMetrics() {
    assignCounterExecutor  = new ScheduledThreadPoolExecutor(1,
            new ThreadFactoryBuilder().
            setDaemon(true).setNameFormat("ContainerAssignmentCounterThread").
            build());
    assignCounterExecutor.scheduleAtFixedRate(new Runnable() {
      @Override
      public void run() {
        containerAssignedPerSecond.set(numContainersAssigned.getAndSet(0));
      }
    }, 1, 1, TimeUnit.SECONDS);
  }
@Test
  public void testClusterMetrics() throws Exception {
    Assert.assertTrue(!metrics.containerAssignedPerSecond.changed());
    metrics.incrNumContainerAssigned();
    metrics.incrNumContainerAssigned();
    GenericTestUtils.waitFor(new Supplier<Boolean>() {
      @Override
      public Boolean get() {
        return metrics.getContainerAssignedPerSecond() == 2;
      }
    }, 500, 5000);
  }