Package org.apache.helix.manager.zk

Examples of org.apache.helix.manager.zk.MockMultiClusterController


    }

    // start controller nodes
    for (int i = 0; i < 2; i++) {
      controllers[i] =
          new MockMultiClusterController(_zkaddr, grandClusterName, "controller_900" + i);
      controllers[i].syncStart();
    }

    Thread.sleep(100);
  }
View Full Code Here


    // start multi-cluster controllers
    for (int i = 0; i < NODE_NR; i++) {
      String controllerName = "controller_" + i;
      _multiClusterControllers[i] =
          new MockMultiClusterController(_zkaddr, CONTROLLER_CLUSTER, controllerName);
      _multiClusterControllers[i].syncStart();
    }

    verifyClusters();
  }
View Full Code Here

    MockMultiClusterController[] multiClusterControllers = new MockMultiClusterController[n];

    for (int i = 0; i < n; i++) {
      String contrllerName = "localhost_" + (12918 + i);
      multiClusterControllers[i] =
          new MockMultiClusterController(_zkaddr, clusterName, contrllerName);
      multiClusterControllers[i].getStateMachineEngine().registerStateModelFactory(StateModelDefId.MasterSlave,
          new MockMSModelFactory());
      multiClusterControllers[i].connect();
    }
View Full Code Here

    CountDownLatch startCountdown = new CountDownLatch(1);
    CountDownLatch endCountdown = new CountDownLatch(1);

    for (int i = 0; i < n; i++) {
      String contrllerName = "localhost_" + (12918 + i);
      multiClusterControllers[i] = new MockMultiClusterController(_zkaddr, clusterName, contrllerName);
      multiClusterControllers[i].getStateMachineEngine().registerStateModelFactory(StateModelDefId.MasterSlave,
          new MockMSModelFactory());
      if (i == 0) {
        multiClusterControllers[i].addPreConnectCallback(new PreConnectTestCallback(contrllerName,
            startCountdown, endCountdown));
View Full Code Here

    // start controllers
    MockMultiClusterController[] controllers = new MockMultiClusterController[NUM_CONTROLLERS];
    for (int i = 0; i < NUM_CONTROLLERS; i++) {
      controllers[i] =
          new MockMultiClusterController(_zkaddr, controllerCluster, "controller_" + i);
      controllers[i].syncStart();
    }
    Thread.sleep(1000);

    // Ensure a balanced cluster
View Full Code Here

    // start multi-cluster controllers
    _controllers = new MockMultiClusterController[n + n];
    for (int i = 0; i < n; i++) {
      _controllers[i] =
          new MockMultiClusterController(_zkaddr, _controllerClusterName, "controller_" + i);
      _controllers[i].syncStart();
    }

    boolean result =
        ClusterStateVerifier.verifyByZkCallback(
            new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr, _controllerClusterName),
            30000);
    Assert.assertTrue(result, "Controller cluster NOT in ideal state");

    // start first cluster
    _participants = new MockParticipant[n];
    _firstClusterName = _clusterNamePrefix + "0_0";
    for (int i = 0; i < n; i++) {
      String instanceName = "localhost0_" + (12918 + i);
      _participants[i] = new MockParticipant(_zkaddr, _firstClusterName, instanceName);
      _participants[i].syncStart();
    }

    result =
        ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
            _firstClusterName));
    Assert.assertTrue(result, "first cluster NOT in ideal state");

    // add more controllers to controller cluster
    for (int i = 0; i < n; i++) {
      String controller = "controller_" + (n + i);
      _setupTool.addInstanceToCluster(_controllerClusterName, controller);
    }
    _setupTool.rebalanceStorageCluster(_controllerClusterName, _clusterNamePrefix + "0", 6);
    for (int i = n; i < 2 * n; i++) {
      _controllers[i] =
          new MockMultiClusterController(_zkaddr, _controllerClusterName, "controller_" + i);
      _controllers[i].syncStart();
    }

    // verify controller cluster
    result =
View Full Code Here

    HelixDataAccessor accessor = _participants[n - 1].getHelixDataAccessor();
    String firstControllerName =
        accessor.getProperty(accessor.keyBuilder().controllerLeader()).getId();

    MockMultiClusterController firstController = null;
    for (MockMultiClusterController controller : _controllers) {
      if (controller.getInstanceName().equals(firstControllerName)) {
        firstController = controller;
      }
    }
    firstController.disconnect();
    Thread.sleep(1000);

    // 1 cluster status monitor, 1 resource monitor, 5 instances
    // Unregister 1+4+1 per-instance resource mbean
    // Register 4 per-instance resource mbean
View Full Code Here

    // setup grand cluster
    final String grandClusterName = "GRAND_" + clusterName;
    TestHelper.setupCluster(grandClusterName, _zkaddr, 0, "controller", null, 0, 0, 1, 0, null,
        true);

    MockMultiClusterController multiClusterController =
        new MockMultiClusterController(_zkaddr, grandClusterName, "controller_0");
    multiClusterController.syncStart();

    // setup cluster
    _setupTool.addCluster(clusterName, true);
    _setupTool.activateCluster(clusterName, "GRAND_" + clusterName, true); // addCluster2

    boolean result;
    result =
        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
            _zkaddr, "GRAND_" + clusterName));
    Assert.assertTrue(result);

    // add node/resource, and do rebalance
    final int nodeNr = 2;
    for (int i = 0; i < nodeNr - 1; i++) {
      int port = 12918 + i;
      _setupTool.addInstanceToCluster(clusterName, "localhost_" + port);
    }

    _setupTool.addResourceToCluster(clusterName, "TestDB0", 1, "LeaderStandby");
    _setupTool.rebalanceStorageCluster(clusterName, "TestDB0", 1);

    MockParticipant[] participants = new MockParticipant[nodeNr];
    for (int i = 0; i < nodeNr - 1; i++) {
      String instanceName = "localhost_" + (12918 + i);
      participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
      participants[i].syncStart();
    }

    result =
        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
            _zkaddr, clusterName));
    Assert.assertTrue(result);

    // check if controller_0 has message listener for localhost_12918
    String msgPath =
        PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12918");
    int numberOfListeners = ZkTestHelper.numberOfListeners(_zkaddr, msgPath);
    // System.out.println("numberOfListeners(" + msgPath + "): " + numberOfListeners);
    Assert.assertEquals(numberOfListeners, 2); // 1 of participant, and 1 of controller

    _setupTool.addInstanceToCluster(clusterName, "localhost_12919");
    _setupTool.rebalanceStorageCluster(clusterName, "TestDB0", 2);

    participants[nodeNr - 1] = new MockParticipant(_zkaddr, clusterName, "localhost_12919");
    participants[nodeNr - 1].syncStart();
    result =
        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
            _zkaddr, clusterName));
    Assert.assertTrue(result);
    // check if controller_0 has message listener for localhost_12919
    msgPath = PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, "localhost_12919");
    numberOfListeners = ZkTestHelper.numberOfListeners(_zkaddr, msgPath);
    // System.out.println("numberOfListeners(" + msgPath + "): " + numberOfListeners);
    Assert.assertEquals(numberOfListeners, 2); // 1 of participant, and 1 of controller

    // clean up
    multiClusterController.syncStop();
    for (int i = 0; i < nodeNr; i++) {
      participants[i].syncStop();
    }

    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
View Full Code Here

    PropertyKey.Builder keyBuilder = accessor.keyBuilder();

    TestHelper.setupEmptyCluster(_zkclient, clusterName);

    String controllerName = "controller_0";
    MockMultiClusterController controller = new MockMultiClusterController(_zkaddr, clusterName, controllerName);
    GenericHelixController pipeline = new GenericHelixController();

    ZkHelixLeaderElection leader = new ZkHelixLeaderElection(controller.getController(), pipeline);
    NotificationContext context = new NotificationContext(controller);
    context.setType(NotificationContext.Type.CALLBACK);
    leader.onControllerChange(context);

    LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());

    // Start another controller, leader should remain unchanged
    MockMultiClusterController controller1 = new MockMultiClusterController(_zkaddr, clusterName, "controller_1");

    GenericHelixController pipeline1 = new GenericHelixController();
    ZkHelixLeaderElection leader1 = new ZkHelixLeaderElection(controller.getController(), pipeline1);
    context = new NotificationContext(controller);
    context.setType(NotificationContext.Type.CALLBACK);
    leader1.onControllerChange(context);
    liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());

    // clean up
    controller1.getConn().disconnect();
    controller.getConn().disconnect();
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
  }
View Full Code Here

    }

    // start controller nodes
    for (int i = 0; i < 2; i++) {
      String controllerName = "controller_900" + i;
      MockMultiClusterController multiClusterController =
          new MockMultiClusterController(_zkaddr, controllerClusterName, controllerName);
      multiClusterController.syncStart();
      multiClusterControllers.put(controllerName, multiClusterController);
    }

    String clusterUrl = getClusterUrl(clusterName);
View Full Code Here

TOP

Related Classes of org.apache.helix.manager.zk.MockMultiClusterController

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.