Package org.apache.helix

Examples of org.apache.helix.ZkHelixTestManager


    // start participants
    for (int i = 0; i < 5; i++)
    {
      String instanceName = "localhost_" + (12918 + i);
      ZkHelixTestManager manager =
          new ZkHelixTestManager(clusterName,
                                 instanceName,
                                 InstanceType.PARTICIPANT,
                                 ZK_ADDR);
      participants[i] = new MockParticipant(manager, new SessionExpiryTransition());
      participants[i].syncStart();
View Full Code Here


    private final AtomicBoolean _done = new AtomicBoolean();

    @Override
    public void doTransition(Message message, NotificationContext context)
    {
      ZkHelixTestManager manager = (ZkHelixTestManager)context.getManager();
    
      String instance = message.getTgtName();
      String partition = message.getPartitionName();
      if (instance.equals("localhost_12918")
          && partition.equals("TestDB0_1"// TestDB0_1 is SLAVE on localhost_12918
          && _done.getAndSet(true) == false)
      {
        try
        {
          ZkTestHelper.expireSession(manager.getZkClient());
        }
        catch (Exception e)
        {
          // TODO Auto-generated catch block
          e.printStackTrace();
View Full Code Here

    MockParticipant[] participants = new MockParticipant[5];
    for (int i = 0; i < 5; i++)
    {
      String instanceName = "localhost_" + (12918 + i);
      ZkHelixTestManager manager =
          new ZkHelixTestManager(clusterName,
                                 instanceName,
                                 InstanceType.PARTICIPANT,
                                 ZK_ADDR);
      participants[i] = new MockParticipant(manager, null);
      participants[i].syncStart();
    }

    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);

    // participant session expiry
    ZkHelixTestManager participantToExpire = (ZkHelixTestManager)participants[1].getManager();

    System.out.println("Expire participant session");
    String oldSessionId = participantToExpire.getSessionId();
   
    ZkTestHelper.expireSession(participantToExpire.getZkClient());
    String newSessionId = participantToExpire.getSessionId();
    System.out.println("oldSessionId: " + oldSessionId + ", newSessionId: " + newSessionId);
    Assert.assertTrue(newSessionId.compareTo(oldSessionId) > 0, "Session id should be increased after expiry");

    ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
    setupTool.addResourceToCluster(clusterName, "TestDB1", 10, "MasterSlave");
View Full Code Here

  {
    _clusterName = clusterName;
    _instanceName = instanceName;
    _msModelFactory = new MockMSModelFactory(transition);

    _manager = new ZkHelixTestManager(_clusterName, _instanceName, InstanceType.PARTICIPANT, zkAddr);
    _job = job;
  }
View Full Code Here

  {
    _clusterName = clusterName;
    _instanceName = instanceName;
    _msModelFactory = factory;

    _manager = new ZkHelixTestManager(_clusterName, _instanceName, InstanceType.PARTICIPANT, zkAddr);
    _job = job;
  }
View Full Code Here

    _controllerMode = controllerMode;
    _zkAddr = zkAddr;

    if (_controllerMode.equals(HelixControllerMain.STANDALONE.toString()))
    {
      _manager = new ZkHelixTestManager(clusterName, controllerName, InstanceType.CONTROLLER, zkAddr);
    }
    else if (_controllerMode.equals(HelixControllerMain.DISTRIBUTED.toString()))
    {
      _manager = new ZkHelixTestManager(clusterName, controllerName, InstanceType.CONTROLLER_PARTICIPANT, zkAddr);
    }
    else
    {
      throw new IllegalArgumentException("Controller mode: " + controllerMode
          + " NOT recoginized");
View Full Code Here

                            "MasterSlave",
                            true); // do rebalance
   
   
      String instanceName = "localhost_" + (12918 + 0);
      ZkHelixTestManager manager =
          new ZkHelixTestManager(clusterName,
                                 instanceName,
                                 InstanceType.PARTICIPANT,
                                 ZK_ADDR);
      manager.connect();
      ZkClient zkClient = manager.getZkClient();
      ZkTestHelper.expireSession(zkClient);
      for(int i = 0;i < 4; i++)
      {
        ZkTestHelper.expireSession(zkClient);
        Thread.sleep(1000);
        if(i < 5)
        {
          //System.out.println(i);
          Assert.assertTrue(manager.isConnected());
        }
      }
      ZkTestHelper.disconnectSession(zkClient);
      for(int i = 0; i < 20; i++)
      {
        Thread.sleep(500);
        System.out.println(i);
        if(!manager.isConnected()) break;
      }
      Assert.assertFalse(manager.isConnected());
  }
View Full Code Here

   
   
      // flapping time window to 5 sec
      System.setProperty("helixmanager.flappingTimeWindow", "15000");
      System.setProperty("helixmanager.maxDisconnectThreshold", "7");
      ZkHelixTestManager manager2 =
          new ZkHelixTestManager(clusterName,
                                 instanceName,
                                 type,
                                 ZK_ADDR);
      manager2.connect();
      ZkClient zkClient = manager2.getZkClient();
      for(int i = 0;i < 3; i++)
      {
        ZkTestHelper.expireSession(zkClient);
        Thread.sleep(500);
        Assert.assertTrue(manager2.isConnected());
      }
      Thread.sleep(15000);
      // Old entries should be cleaned up
      for(int i = 0;i < 7; i++)
      {
        ZkTestHelper.expireSession(zkClient);
        Thread.sleep(1000);
        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());
  }
View Full Code Here

   
   
      // flapping time window to 5 sec
      System.setProperty("helixmanager.flappingTimeWindow", "5000");
      System.setProperty("helixmanager.maxDisconnectThreshold", "3");
      ZkHelixTestManager manager2 =
          new ZkHelixTestManager(clusterName,
                                 null,
                                 InstanceType.CONTROLLER,
                                 ZK_ADDR);
      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());
  }
View Full Code Here

    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

TOP

Related Classes of org.apache.helix.ZkHelixTestManager

Copyright © 2018 www.massapicom. 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.