@Test(timeout = 40000)
  public void testDeadlockWhileMappingHosts() throws Exception {
    Provider<ClustersHostMapperThread> clustersHostMapperThreadFactory =
        new Provider<ClustersHostMapperThread>() {

      @Override
      public ClustersHostMapperThread get() {
        return new ClustersHostMapperThread();
      }
    };

    doLoadTest(new ClusterReaderThreadFactory(),
               clustersHostMapperThreadFactory,
               NUMBER_OF_THREADS,
               writerStoppedSignal,
               readerStoppedSignal);

    Assert.assertEquals(NUMBER_OF_THREADS * NUMBER_OF_HOSTS,
        clusters.getHostsForCluster(CLUSTER_NAME).size());
  }
Tests that no deadlock exists when adding hosts while reading from the
cluster.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java