Package com.linkedin.helix.TestHelper

Examples of com.linkedin.helix.TestHelper.StartCMResult


      if (testInfo._startCMResultMap.containsKey(instanceName))
      {
        LOG.warn("Dummy participant:" + instanceName + " has already started; skip starting it");
      } else
      {
        StartCMResult result = TestHelper.startDummyProcess(ZK_ADDR, clusterName, instanceName);
        testInfo._startCMResultMap.put(instanceName, result);
        // testInfo._instanceStarted.countDown();
      }
    }
  }
View Full Code Here


      if (testInfo._startCMResultMap.containsKey(controllerName))
      {
        LOG.warn("Controller:" + controllerName + " has already started; skip starting it");
      } else
      {
        StartCMResult result = TestHelper.startController(clusterName, controllerName, ZK_ADDR,
            HelixControllerMain.STANDALONE);
        testInfo._startCMResultMap.put(controllerName, result);
      }
    }
  }
View Full Code Here

    TestInfo testInfo = _testInfoMap.get(uniqClusterName);
    // String clusterName = testInfo._clusterName;

    String failHost = PARTICIPANT_PREFIX + "_" + (START_PORT + instanceId);
    StartCMResult result = testInfo._startCMResultMap.remove(failHost);

    // TODO need sync
    if (result == null || result._manager == null || result._thread == null)
    {
      String errMsg = "Dummy participant:" + failHost + " seems not running";
View Full Code Here

        LOG.error("fail to start particpant:" + instanceName
            + "(participant with same name already exists)");
      }
      else
      {
        StartCMResult result =
            TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, instanceName);
        _startCMResultMap.put(instanceName, result);
      }
    }

    // start controller
    String controllerName = CONTROLLER_PREFIX + "_0";
    StartCMResult startResult =
        TestHelper.startController(CLUSTER_NAME,
                                   controllerName,
                                   ZK_ADDR,
                                   HelixControllerMain.STANDALONE);
    _startCMResultMap.put(controllerName, startResult);
View Full Code Here

  @Test
  public void testMasterSelectionBySCN() throws Exception
  {
    String controllerName = CONTROLLER_PREFIX + "_0";
    StartCMResult startResult =
    _startCMResultMap.get(controllerName);
    HelixDataAccessor accessor = startResult._manager.getHelixDataAccessor();

    IdealState idealState = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, TEST_DB);
    Map<String, ZNRecord> scnTableMap = new HashMap<String, ZNRecord>();
    for (int i = 0; i < NODE_NR; i++)
    {
      String instance = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
      ZNRecord scnRecord = new ZNRecord("scnTable");
      scnRecord.setSimpleField("instance", instance);
      scnTableMap.put(instance, scnRecord);
    }
    String instanceDead = PARTICIPANT_PREFIX + "_" + (START_PORT + 0);
    for(int j = 0; j < _PARTITIONS; j++)
    {
      int seq = 50;
      String partition = TEST_DB + "_" + j;
      List<String> idealStatePrefList =
          idealState.getPreferenceList(partition);
      String idealStateMaster = idealStatePrefList.get(0);
      // Switch the scn order of the partitions mastered on instanceDead
      if(idealStateMaster.equals(instanceDead))
      {
        for(int x = 0; x < idealStatePrefList.size(); x++)
        {
          String instance = idealStatePrefList.get(x);
          ZNRecord scnRecord = scnTableMap.get(instance);
          if(!scnRecord.getMapFields().containsKey(partition))
          {
            scnRecord.setMapField(partition, new HashMap<String, String>());
          }
          Map<String, String> scnDetails = scnRecord.getMapField(partition);
          scnDetails.put("gen", "4");
          if(x > 0)
          {
            scnDetails.put("seq", "" + (seq - 22 + 11 *(x)));
          }
          else
          {
            scnDetails.put("seq", "100");
          }
        }
      }
    }

    for(String instanceName : scnTableMap.keySet())
    {
      Builder kb = accessor.keyBuilder();
      accessor.setProperty(kb.healthReport(instanceName, "scnTable"), new HealthStat(scnTableMap.get(instanceName)));
    }

    // kill a node, after a while the master should be the last one in the ideal state pref list
   
    _startCMResultMap.get(instanceDead)._manager.disconnect();
    _startCMResultMap.get(instanceDead)._thread.interrupt();
   
    Thread.sleep(1000);
   
    boolean verifyResult =
        ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR,
                                                                              CLUSTER_NAME));
    Assert.assertTrue(verifyResult);
    Builder kb = accessor.keyBuilder();
    ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
    for(String partitionName : idealState.getPartitionSet())
    {
      List<String> prefList = idealState.getPreferenceList(partitionName);
      if(prefList.get(0).equals(instanceDead))
      {
        String last = prefList.get(prefList.size() - 1);
        Assert.assertTrue(ev.getStateMap(partitionName).get(last).equals("MASTER"));
      }
    }
   
    // Bring up the previous dead node, but as the SCN is the last for all the
    // master partitions on it, the master partitions should be still on the last if the prefList
    StartCMResult result =
        TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, instanceDead);
    _startCMResultMap.put(instanceDead, result);

    Thread.sleep(1000);
    verifyResult =
View Full Code Here

    {
      e.printStackTrace();
      exception = true;
    }
    Assert.assertFalse(exception);
    StartCMResult result2 =
        TestHelper.startDummyProcess(ZK_ADDR, CLUSTER_NAME, instanceName2);
    _startCMResultMap.put(instanceName2, result2);
   
    result = ClusterStateVerifier.verifyByPolling(
        new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME));
View Full Code Here

        LOG.error("fail to start participant:" + instanceName
                     + "(participant with the same name already running");
      }
      else
      {
        StartCMResult result = TestHelper.startDummyProcess(ZK_ADDR, firstCluster,
                                                            instanceName);
        _startCMResultMap.put(instanceName, result);
      }
    }

    // start distributed cluster controllers
    for (int i = 0; i < 5; i++)
    {
      String controllerName = CONTROLLER_PREFIX + "_" + i;
      if (_startCMResultMap.get(controllerName) != null)
      {
        LOG.error("fail to start controller:" + controllerName
                     + "(controller with the same name already running");
      }
      else
      {
        StartCMResult result = TestHelper.startController(CONTROLLER_CLUSTER,
                                                                 controllerName,
                                                                 ZK_ADDR,
                                                                 HelixControllerMain.DISTRIBUTED);
        _startCMResultMap.put(controllerName, result);
      }
View Full Code Here

     *   3) disconnect leader/disconnect participant
     */
    String leader = getCurrentLeader(_gZkClient, CONTROLLER_CLUSTER);
    // pauseController(_startCMResultMap.get(leader)._manager.getDataAccessor());

    StartCMResult result;

    Iterator<Entry<String, StartCMResult>> it = _startCMResultMap.entrySet().iterator();

    while (it.hasNext())
    {
View Full Code Here

                            true);        // do rebalance

    // enableHealthCheck(clusterName);


    StartCMResult cmResult = TestHelper.startController(clusterName,
                               "controller_0",
                               ZK_ADDR,
                               HelixControllerMain.STANDALONE);
    cmResult._manager.startTimerTasks();
    _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr);
View Full Code Here

                            "MasterSlave",
                            true);        // do rebalance

    // enableHealthCheck(clusterName);

    StartCMResult cmResult = TestHelper.startController(clusterName,
                               "controller_0",
                               ZK_ADDR,
                               HelixControllerMain.STANDALONE);
    cmResult._manager.stopTimerTasks();
   
View Full Code Here

TOP

Related Classes of com.linkedin.helix.TestHelper.StartCMResult

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.