コード例 #1
0
ファイル: TestAutoRebalance.java プロジェクト: JyotsnaC/helix
  @Test()
  public void testAutoRebalanceDisablePartition() throws Exception {

    // kill 1 node

    String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + 3);
    HelixDataAccessor _accessor =
        _startCMResultMap.get(instanceName)._manager.getHelixDataAccessor();
    ExternalView ev = _accessor.getProperty(_accessor.keyBuilder().externalView(TEST_DB));

    for (int i = 0; i < 3; i++) {
      String partitionName = TEST_DB + "_" + i;
      List<String> list = new ArrayList<String>();
      list.add(partitionName);
      String host = (String) (ev.getStateMap(partitionName).keySet().toArray()[0]);
      _startCMResultMap
          .get(instanceName)
          ._manager
          .getClusterManagmentTool()
          .enablePartition(false, CLUSTER_NAME, host, TEST_DB, list);
    }

    Thread.sleep(10000);

    ev = _accessor.getProperty(_accessor.keyBuilder().externalView(TEST_DB));
    for (int i = 0; i < 3; i++) {
      String partitionName = TEST_DB + "_" + i;
      List<String> list = new ArrayList<String>();
      list.add(partitionName);
      String host = (String) (ev.getStateMap(partitionName).keySet().toArray()[0]);
      Assert.assertTrue(ev.getStateMap(partitionName).get(host).equalsIgnoreCase("offline"));
      Assert.assertEquals(ev.getStateMap(partitionName).size(), 1);
    }
  }
コード例 #2
0
ファイル: TestAutoRebalance.java プロジェクト: JyotsnaC/helix
 @Override
 public boolean verify() {
   HelixDataAccessor accessor =
       new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor(_client));
   Builder keyBuilder = accessor.keyBuilder();
   int numberOfPartitions =
       accessor
           .getProperty(keyBuilder.idealStates(_resourceName))
           .getRecord()
           .getListFields()
           .size();
   ClusterDataCache cache = new ClusterDataCache();
   cache.refresh(accessor);
   String masterValue =
       cache
           .getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
           .getStatesPriorityList()
           .get(0);
   int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
   return verifyBalanceExternalView(
       accessor.getProperty(keyBuilder.externalView(_resourceName)).getRecord(),
       numberOfPartitions,
       masterValue,
       replicas,
       cache.getLiveInstances().size());
 }