@Test()
  public void testDeadlockBetweenImplementations() throws Exception {
    Service service = cluster.getService("HDFS");
    ServiceComponent nameNodeComponent = service.getServiceComponent("NAMENODE");
    ServiceComponent dataNodeComponent = service.getServiceComponent("DATANODE");

    ServiceComponentHost nameNodeSCH = createNewServiceComponentHost("HDFS",
        "NAMENODE", "c64-0");

    ServiceComponentHost dataNodeSCH = createNewServiceComponentHost("HDFS",
        "DATANODE", "c64-0");

    List<Thread> threads = new ArrayList<>();
    for (int i = 0; i < NUMBER_OF_THREADS; i++) {
      DeadlockExerciserThread thread = new DeadlockExerciserThread();
      thread.setCluster(cluster);
      thread.setService(service);
      thread.setDataNodeComponent(dataNodeComponent);
      thread.setNameNodeComponent(nameNodeComponent);
      thread.setNameNodeSCH(nameNodeSCH);
      thread.setDataNodeSCH(dataNodeSCH);
      thread.start();
      threads.add(thread);
    }

    DeadlockWarningThread wt = new DeadlockWarningThread(threads);

    while (true) {
      if(!wt.isAlive()) {
          break;
      }
    }
    if (wt.isDeadlocked()){
      Assert.assertFalse(wt.getErrorMessages().toString(), wt.isDeadlocked());
    } else {
      Assert.assertFalse(wt.isDeadlocked());
    }
  }
Tests that concurrent impl serialization and impl writing doesn't cause a
deadlock.

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