/**
  * Create a single test client.
  *
  * @param id the client id
  * @return the client
  * @throws Exception
  */
 TestUpdateWrapper createTestClient(final int id, final TestOperationHandler handler)
     throws Exception {
   final TransactionalProtocolClient client = createClient();
   final MockController controller = transferQueue.take();
   controller.handler = handler;
   return new TestUpdateWrapper(id, client, controller);
 }
  // @Test
  public void testDisconnectFlappingWindowController() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    final String clusterName = className + "_" + methodName;

    TestHelper.setupCluster(
        clusterName,
        _zkaddr,
        12918, // participant port
        "localhost", // participant name prefix
        "TestDB", // resource name prefix
        1, // resources
        10, // partitions per resource
        5, // number of nodes
        3, // replicas
        "MasterSlave",
        true); // do rebalance

    // flapping time window to 5 sec
    System.setProperty("helixmanager.flappingTimeWindow", "5000");
    System.setProperty("helixmanager.maxDisconnectThreshold", "3");
    MockController manager2 = new MockController(_zkaddr, clusterName, null);
    manager2.connect();
    Thread.sleep(100);
    ZkClient zkClient = manager2.getZkClient();
    for (int i = 0; i < 2; i++) {
      ZkTestHelper.expireSession(zkClient);
      Thread.sleep(500);
      Assert.assertTrue(manager2.isConnected());
    }
    Thread.sleep(5000);
    // Old entries should be cleaned up
    for (int i = 0; i < 3; i++) {
      ZkTestHelper.expireSession(zkClient);
      Thread.sleep(500);
      Assert.assertTrue(manager2.isConnected());
    }
    ZkTestHelper.disconnectSession(zkClient);
    for (int i = 0; i < 20; i++) {
      Thread.sleep(500);
      if (!manager2.isConnected()) break;
    }
    Assert.assertFalse(manager2.isConnected());
  }
 OperationContext.ResultAction getResultAction() {
   return controller.getAction();
 }