Examples of ZkHelixTestManager


Examples of org.apache.helix.ZkHelixTestManager

    Assert.assertFalse(liveInstance.getSessionId().equals("value"));
    Assert.assertFalse(liveInstance.getLiveInstance().equals("value"));
   
    ////////////////////////////////////
   
    ZkHelixTestManager manager2 = new ZkHelixTestManager(clusterName, "localhost_3",
        InstanceType.PARTICIPANT,
        ZK_ADDR);
    manager2.setLiveInstanceInfoProvider(new provider(true));
   
    manager2.connect();
    accessor = manager2.getHelixDataAccessor();
   
    liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance("localhost_3"));
    Assert.assertTrue(liveInstance.getRecord().getListFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getMapFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 5);
    Assert.assertFalse(liveInstance.getSessionId().equals("value"));
    Assert.assertFalse(liveInstance.getLiveInstance().equals("value"));
    String sessionId = liveInstance.getSessionId();
   
    ZkTestHelper.expireSession(manager2.getZkClient());
    Thread.sleep(1000);
   
    liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance("localhost_3"));
    Assert.assertTrue(liveInstance.getRecord().getListFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getMapFields().size() == 1);
View Full Code Here

Examples of org.apache.helix.ZkHelixTestManager

      String instanceName = "localhost_" + (12918 + i);
      participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR);
      new Thread(participants[i]).start();
    }

    ZkHelixTestManager controller =
        new ZkHelixTestManager(clusterName,
                                            "controller_0",
                                            InstanceType.CONTROLLER,
                                            ZK_ADDR);
    controller.connect();
    boolean result;
    result =
        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
                                                                                          clusterName));
    Assert.assertTrue(result);
    String msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
    result = checkHandlers(controller.getHandlers(), msgPath);
    Assert.assertTrue(result);

    _gSetupTool.addInstanceToCluster(clusterName, "localhost_12922");
    _gSetupTool.rebalanceStorageCluster(clusterName, "TestDB0", 3);

    participants[nodeNr - 1] =
        new MockParticipant(clusterName, "localhost_12922", ZK_ADDR);
    new Thread(participants[nodeNr - 1]).start();
    result =
        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
                                                                                          clusterName));
    Assert.assertTrue(result);
    msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12922");
    result = checkHandlers(controller.getHandlers(), msgPath);
    Assert.assertTrue(result);

    // clean up
//    controller.disconnect();
//    for (int i = 0; i < nodeNr; i++)
View Full Code Here

Examples of org.apache.helix.ZkHelixTestManager

  @Test
  public void testInstanceBounce() throws Exception
  {
    String controllerName = CONTROLLER_PREFIX + "_0";
    StartCMResult controllerResult = _startCMResultMap.get(controllerName);
    ZkHelixTestManager controller = (ZkHelixTestManager) controllerResult._manager;
    int handlerSize = controller.getHandlers().size();

    for (int i = 0; i < 2; i++)
    {
      String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
      // kill 2 participants
      _startCMResultMap.get(instanceName)._manager.disconnect();
      _startCMResultMap.get(instanceName)._thread.interrupt();
      try
      {
        Thread.sleep(1000);
      }
      catch (InterruptedException e)
      {
        e.printStackTrace();
      }
      // restart the participant
      StartCMResult result = TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, instanceName);
      _startCMResultMap.put(instanceName, result);
      Thread.sleep(100);
    }
    Thread.sleep(4000);

    boolean result = ClusterStateVerifier.verifyByPolling(
        new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME), 50 * 1000);
    Assert.assertTrue(result);

    // When a new live instance is created, we add current state listener to it
    // and we will remove current-state listener on expired session
    // so the number of callback handlers is unchanged
    for (int j = 0; j < 10; j++)
    {
      if(controller.getHandlers().size() == (handlerSize))
      {
        break;
      }
      Thread.sleep(400);
    }
    Assert.assertEquals( controller.getHandlers().size(), handlerSize);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.