当前位置: 首页>>代码示例>>Java>>正文


Java IdealState.setPreferenceList方法代码示例

本文整理汇总了Java中org.apache.helix.model.IdealState.setPreferenceList方法的典型用法代码示例。如果您正苦于以下问题:Java IdealState.setPreferenceList方法的具体用法?Java IdealState.setPreferenceList怎么用?Java IdealState.setPreferenceList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.model.IdealState的用法示例。


在下文中一共展示了IdealState.setPreferenceList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeNewIdealState

import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
@Override
public IdealState computeNewIdealState(String resourceName, IdealState currentIdealState,
    CurrentStateOutput currentStateOutput, ClusterDataCache clusterData) {
  LOG.info(String
      .format("Start computing ideal state for resource %s in maintenance mode.", resourceName));
  Map<Partition, Map<String, String>> currentStateMap =
      currentStateOutput.getCurrentStateMap(resourceName);
  if (currentStateMap == null || currentStateMap.size() == 0) {
    LOG.warn(String
        .format("No new partition will be assigned for %s in maintenance mode", resourceName));
    currentIdealState.setPreferenceLists(Collections.EMPTY_MAP);
    return currentIdealState;
  }

  // One principal is to prohibit DROP -> OFFLINE and OFFLINE -> DROP state transitions.
  // Derived preference list from current state with state priority
  for (Partition partition : currentStateMap.keySet()) {
    Map<String, String> stateMap = currentStateMap.get(partition);
    List<String> preferenceList = new ArrayList<>(stateMap.keySet());
    Collections.sort(preferenceList, new PreferenceListNodeComparator(stateMap,
        clusterData.getStateModelDef(currentIdealState.getStateModelDefRef())));
    currentIdealState.setPreferenceList(partition.getPartitionName(), preferenceList);
  }
  LOG.info("End computing ideal state for resource %s in maintenance mode.");
  return currentIdealState;
}
 
开发者ID:apache,项目名称:helix,代码行数:27,代码来源:MaintenanceRebalancer.java

示例2: setupUnbalancedDB

import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
private void setupUnbalancedDB() throws InterruptedException {
  // Start with Full-Auto mode to create the partitions, Semi-Auto won't create partitions.
  _setupTool.addResourceToCluster(CLUSTER_NAME, UNBALANCED_DB_NAME, 50, MASTER_SLAVE_STATE_MODEL,
      IdealState.RebalanceMode.FULL_AUTO.toString());
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, UNBALANCED_DB_NAME, 1);

  // Set preference list to put all partitions to one instance.
  IdealState idealState = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME,
      UNBALANCED_DB_NAME);
  Set<String> partitions = idealState.getPartitionSet();
  for (String partition : partitions) {
    idealState.setPreferenceList(partition, Lists.newArrayList(_blockedParticipant.getInstanceName()));
  }
  idealState.setRebalanceMode(IdealState.RebalanceMode.SEMI_AUTO);

  _setupTool.getClusterManagementTool().setResourceIdealState(CLUSTER_NAME, UNBALANCED_DB_NAME, idealState);

  HelixClusterVerifier clusterVerifier =
      new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
  Assert.assertTrue(clusterVerifier.verify(10000));
}
 
开发者ID:apache,项目名称:helix,代码行数:22,代码来源:TestJobFailureTaskNotStarted.java

示例3: testEnableDisablePartitions

import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
@Test
public void testEnableDisablePartitions() throws InterruptedException {
  HelixAdmin admin = new ZKHelixAdmin(_gZkClient);
  admin.enablePartition(false, CLUSTER_NAME, (PARTICIPANT_PREFIX + "_" + _startPort),
      WorkflowGenerator.DEFAULT_TGT_DB, Arrays.asList(new String[] { "TestDB_0", "TestDB_2" }));

  IdealState idealState =
      admin.getResourceIdealState(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB);
  List<String> preferenceList =
      Arrays.asList(new String[] { "localhost_12919", "localhost_12918" });
  for (String partitionName : idealState.getPartitionSet()) {
    idealState.setPreferenceList(partitionName, preferenceList);
  }
  idealState.setRebalanceMode(IdealState.RebalanceMode.SEMI_AUTO);
  admin.setResourceIdealState(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, idealState);

  String workflowName = TestHelper.getTestMethodName();
  Workflow.Builder builder = new Workflow.Builder(workflowName);
  JobConfig.Builder jobBuilder =
      new JobConfig.Builder().setWorkflow(workflowName).setCommand(MockTask.TASK_COMMAND)
          .setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB)
          .setTargetPartitionStates(Collections.singleton("SLAVE"));
  builder.addJob("JOB", jobBuilder);
  _driver.start(builder.build());
  Thread.sleep(2000L);
  JobContext jobContext =
      _driver.getJobContext(TaskUtil.getNamespacedJobName(workflowName, "JOB"));
  Assert.assertEquals(jobContext.getPartitionState(0), null);
  Assert.assertEquals(jobContext.getPartitionState(1), TaskPartitionState.COMPLETED);
  Assert.assertEquals(jobContext.getPartitionState(2), null);
}
 
开发者ID:apache,项目名称:helix,代码行数:32,代码来源:TestZkHelixAdmin.java

示例4: createDBInSemiAuto

import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
protected void createDBInSemiAuto(ClusterSetup clusterSetup, String clusterName, String dbName,
    List<String> preferenceList, String stateModelDef, int numPartition, int replica) {
  clusterSetup.addResourceToCluster(clusterName, dbName, numPartition, stateModelDef,
      IdealState.RebalanceMode.SEMI_AUTO.toString());
  clusterSetup.rebalanceStorageCluster(clusterName, dbName, replica);

  IdealState is =
      _gSetupTool.getClusterManagementTool().getResourceIdealState(clusterName, dbName);
  for (String p : is.getPartitionSet()) {
    is.setPreferenceList(p, preferenceList);
  }
  clusterSetup.getClusterManagementTool().setResourceIdealState(clusterName, dbName, is);
}
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:ZkIntegrationTestBase.java


注:本文中的org.apache.helix.model.IdealState.setPreferenceList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。