• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ZNRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ZNRecord类属于org.apache.helix包,在下文中一共展示了ZNRecord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildInitialRealtimeIdealStateFor

import org.apache.helix.ZNRecord; //导入依赖的package包/类
public static IdealState buildInitialRealtimeIdealStateFor(String realtimeTableName,
    AbstractTableConfig realtimeTableConfig, HelixAdmin helixAdmin, String helixClusterName,
    ZkHelixPropertyStore<ZNRecord> zkHelixPropertyStore) {
  KafkaStreamMetadata kafkaStreamMetadata =
      new KafkaStreamMetadata(realtimeTableConfig.getIndexingConfig().getStreamConfigs());
  String realtimeServerTenant =
      ControllerTenantNameBuilder.getRealtimeTenantNameForTenant(realtimeTableConfig.getTenantConfig().getServer());
  switch (kafkaStreamMetadata.getConsumerType()) {
    case highLevel:
      IdealState idealState =
          buildInitialKafkaHighLevelConsumerRealtimeIdealStateFor(realtimeTableName, helixAdmin, helixClusterName,
              zkHelixPropertyStore);
      List<String> realtimeInstances = helixAdmin.getInstancesInClusterWithTag(helixClusterName, realtimeServerTenant);
      if (realtimeInstances.size() % Integer.parseInt(realtimeTableConfig.getValidationConfig().getReplication()) != 0) {
        throw new RuntimeException("Number of instance in current tenant should be an integer multiples of the number of replications");
      }
      setupInstanceConfigForKafkaHighLevelConsumer(realtimeTableName, realtimeInstances.size(),
          Integer.parseInt(realtimeTableConfig.getValidationConfig().getReplication()), realtimeTableConfig
              .getIndexingConfig().getStreamConfigs(), zkHelixPropertyStore, realtimeInstances);
      return idealState;
    case simple:
    default:
      throw new UnsupportedOperationException("Not support kafka consumer type: "
          + kafkaStreamMetadata.getConsumerType());
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:27,代码来源:PinotTableIdealStateBuilder.java


示例2: HelixExternalViewBasedRouting

import org.apache.helix.ZNRecord; //导入依赖的package包/类
public HelixExternalViewBasedRouting(RoutingTableBuilder defaultOfflineRoutingTableBuilder,
    RoutingTableBuilder defaultRealtimeRoutingTableBuilder, Map<String, RoutingTableBuilder> routingTableBuilderMap,
    ZkHelixPropertyStore<ZNRecord> propertyStore) {
  _timeBoundaryService = new HelixExternalViewBasedTimeBoundaryService(propertyStore);
  if (defaultOfflineRoutingTableBuilder != null) {
    _defaultOfflineRoutingTableBuilder = defaultOfflineRoutingTableBuilder;
  } else {
    _defaultOfflineRoutingTableBuilder = new BalancedRandomRoutingTableBuilder();
  }
  if (defaultRealtimeRoutingTableBuilder != null) {
    _defaultRealtimeRoutingTableBuilder = defaultRealtimeRoutingTableBuilder;
  } else {
    _defaultRealtimeRoutingTableBuilder = new KafkaHighLevelConsumerBasedRoutingTableBuilder();
  }
  if (routingTableBuilderMap != null) {
    _routingTableBuilderMap = routingTableBuilderMap;
  } else {
    _routingTableBuilderMap = new HashMap<String, RoutingTableBuilder>();
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:HelixExternalViewBasedRouting.java


示例3: addingSegmentsToPropertyStore

import org.apache.helix.ZNRecord; //导入依赖的package包/类
private void addingSegmentsToPropertyStore(int numSegments, ZkHelixPropertyStore<ZNRecord> propertyStore,
    String tableName) {
  for (int i = 0; i < numSegments; ++i) {
    OfflineSegmentZKMetadata offlineSegmentZKMetadata = new OfflineSegmentZKMetadata();
    offlineSegmentZKMetadata.setSegmentName(tableName + "_" + System.currentTimeMillis() + "_" + i);
    offlineSegmentZKMetadata.setTimeUnit(TimeUnit.DAYS);
    offlineSegmentZKMetadata.setEndTime(i);
    offlineSegmentZKMetadata.setCrc(-1);
    offlineSegmentZKMetadata.setCreationTime(-1);
    offlineSegmentZKMetadata.setStartTime(i - 1);
    offlineSegmentZKMetadata.setIndexVersion("0");
    offlineSegmentZKMetadata.setPushTime(i + 5);
    offlineSegmentZKMetadata.setTableName(tableName);
    offlineSegmentZKMetadata.setSegmentType(SegmentType.OFFLINE);
    ZKMetadataProvider.setOfflineSegmentZKMetadata(_propertyStore, offlineSegmentZKMetadata);
  }
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:18,代码来源:TimeBoundaryServiceTest.java


示例4: getOfflineSegmentZKMetadataListForTable

import org.apache.helix.ZNRecord; //导入依赖的package包/类
public static List<OfflineSegmentZKMetadata> getOfflineSegmentZKMetadataListForTable(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {
  List<OfflineSegmentZKMetadata> resultList = new ArrayList<OfflineSegmentZKMetadata>();
  if (propertyStore == null) {
    return resultList;
  }
  String offlineTableName = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(tableName);
  if (propertyStore.exists(constructPropertyStorePathForResource(offlineTableName), AccessOption.PERSISTENT)) {
    List<ZNRecord> znRecordList = propertyStore.getChildren(constructPropertyStorePathForResource(offlineTableName), null, AccessOption.PERSISTENT);
    if (znRecordList != null) {
      for (ZNRecord record : znRecordList) {
        resultList.add(new OfflineSegmentZKMetadata(record));
      }
    }
  }
  return resultList;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:ZKMetadataProvider.java


示例5: getRealtimeSegmentZKMetadataListForTable

import org.apache.helix.ZNRecord; //导入依赖的package包/类
public static List<RealtimeSegmentZKMetadata> getRealtimeSegmentZKMetadataListForTable(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceName) {
  List<RealtimeSegmentZKMetadata> resultList = new ArrayList<RealtimeSegmentZKMetadata>();
  if (propertyStore == null) {
    return resultList;
  }
  String realtimeTableName = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(resourceName);
  if (propertyStore.exists(constructPropertyStorePathForResource(realtimeTableName), AccessOption.PERSISTENT)) {
    List<ZNRecord> znRecordList = propertyStore.getChildren(constructPropertyStorePathForResource(realtimeTableName), null, AccessOption.PERSISTENT);
    if (znRecordList != null) {
      for (ZNRecord record : znRecordList) {
        resultList.add(new RealtimeSegmentZKMetadata(record));
      }
    }
  }
  return resultList;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:ZKMetadataProvider.java


示例6: toZNRecord

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Override
public ZNRecord toZNRecord() {
  ZNRecord znRecord = new ZNRecord(_segmentName);
  znRecord.setSimpleField(CommonConstants.Segment.SEGMENT_NAME, _segmentName);
  znRecord.setSimpleField(CommonConstants.Segment.TABLE_NAME, _tableName);
  znRecord.setEnumField(CommonConstants.Segment.SEGMENT_TYPE, _segmentType);
  if (_timeUnit == null) {
    znRecord.setSimpleField(CommonConstants.Segment.TIME_UNIT, NULL);
  } else {
    znRecord.setEnumField(CommonConstants.Segment.TIME_UNIT, _timeUnit);
  }
  znRecord.setLongField(CommonConstants.Segment.START_TIME, _startTime);
  znRecord.setLongField(CommonConstants.Segment.END_TIME, _endTime);

  znRecord.setSimpleField(CommonConstants.Segment.INDEX_VERSION, _indexVersion);
  znRecord.setLongField(CommonConstants.Segment.TOTAL_DOCS, _totalDocs);
  znRecord.setLongField(CommonConstants.Segment.CRC, _crc);
  znRecord.setLongField(CommonConstants.Segment.CREATION_TIME, _creationTime);
  return znRecord;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:SegmentZKMetadata.java


示例7: getTestDoneRealtimeSegmentZNRecord

import org.apache.helix.ZNRecord; //导入依赖的package包/类
private ZNRecord getTestDoneRealtimeSegmentZNRecord() {
  String segmentName = "testTable_R_1000_2000_groupId0_part0";
  ZNRecord record = new ZNRecord(segmentName);
  record.setSimpleField(CommonConstants.Segment.SEGMENT_NAME, segmentName);
  record.setSimpleField(CommonConstants.Segment.TABLE_NAME, "testTable");
  record.setSimpleField(CommonConstants.Segment.INDEX_VERSION, "v1");
  record.setEnumField(CommonConstants.Segment.SEGMENT_TYPE, CommonConstants.Segment.SegmentType.REALTIME);
  record.setEnumField(CommonConstants.Segment.Realtime.STATUS, CommonConstants.Segment.Realtime.Status.DONE);
  record.setLongField(CommonConstants.Segment.START_TIME, 1000);
  record.setLongField(CommonConstants.Segment.END_TIME, 2000);
  record.setSimpleField(CommonConstants.Segment.TIME_UNIT, TimeUnit.HOURS.toString());
  record.setLongField(CommonConstants.Segment.TOTAL_DOCS, 10000);
  record.setLongField(CommonConstants.Segment.CRC, 1234);
  record.setLongField(CommonConstants.Segment.CREATION_TIME, 3000);
  return record;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:SegmentZKMetadataTest.java


示例8: getTestInProgressRealtimeSegmentZNRecord

import org.apache.helix.ZNRecord; //导入依赖的package包/类
private ZNRecord getTestInProgressRealtimeSegmentZNRecord() {
  String segmentName = "testTable_R_1000_groupId0_part0";
  ZNRecord record = new ZNRecord(segmentName);
  record.setSimpleField(CommonConstants.Segment.SEGMENT_NAME, segmentName);
  record.setSimpleField(CommonConstants.Segment.TABLE_NAME, "testTable");
  record.setSimpleField(CommonConstants.Segment.INDEX_VERSION, "v1");
  record.setEnumField(CommonConstants.Segment.SEGMENT_TYPE, CommonConstants.Segment.SegmentType.REALTIME);
  record.setEnumField(CommonConstants.Segment.Realtime.STATUS, CommonConstants.Segment.Realtime.Status.IN_PROGRESS);
  record.setLongField(CommonConstants.Segment.START_TIME, 1000);
  record.setLongField(CommonConstants.Segment.END_TIME, -1);
  record.setSimpleField(CommonConstants.Segment.TIME_UNIT, TimeUnit.HOURS.toString());
  record.setLongField(CommonConstants.Segment.TOTAL_DOCS, -1);
  record.setLongField(CommonConstants.Segment.CRC, -1);
  record.setLongField(CommonConstants.Segment.CREATION_TIME, 1000);
  return record;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:SegmentZKMetadataTest.java


示例9: getTestOfflineSegmentZNRecord

import org.apache.helix.ZNRecord; //导入依赖的package包/类
private ZNRecord getTestOfflineSegmentZNRecord() {
  String segmentName = "testTable_O_3000_4000";
  ZNRecord record = new ZNRecord(segmentName);
  record.setSimpleField(CommonConstants.Segment.SEGMENT_NAME, segmentName);
  record.setSimpleField(CommonConstants.Segment.TABLE_NAME, "testTable");
  record.setSimpleField(CommonConstants.Segment.INDEX_VERSION, "v1");
  record.setEnumField(CommonConstants.Segment.SEGMENT_TYPE, CommonConstants.Segment.SegmentType.OFFLINE);
  record.setLongField(CommonConstants.Segment.START_TIME, 1000);
  record.setLongField(CommonConstants.Segment.END_TIME, 2000);
  record.setSimpleField(CommonConstants.Segment.TIME_UNIT, TimeUnit.HOURS.toString());
  record.setLongField(CommonConstants.Segment.TOTAL_DOCS, 50000);
  record.setLongField(CommonConstants.Segment.CRC, 54321);
  record.setLongField(CommonConstants.Segment.CREATION_TIME, 1000);
  record.setSimpleField(CommonConstants.Segment.Offline.DOWNLOAD_URL, "http://localhost:8000/testTable_O_3000_4000");
  record.setLongField(CommonConstants.Segment.Offline.PUSH_TIME, 4000);
  record.setLongField(CommonConstants.Segment.Offline.REFRESH_TIME, 8000);
  return record;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:19,代码来源:SegmentZKMetadataTest.java


示例10: testSyncExist

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Test
public void testSyncExist() {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String testName = className + "_" + methodName;

  System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));

  String path = String.format("/%s/%s", testName, "msg_0");
  ZNRecord record = new ZNRecord("msg_0");
  ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);

  boolean success = accessor.exists(path, 0);
  Assert.assertFalse(success);

  success = accessor.create(path, record, AccessOption.EPHEMERAL);
  Assert.assertTrue(success);

  success = accessor.exists(path, 0);
  Assert.assertTrue(success);

  System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));

}
 
开发者ID:apache,项目名称:helix,代码行数:25,代码来源:TestZkBaseDataAccessor.java


示例11: scanPath

import org.apache.helix.ZNRecord; //导入依赖的package包/类
/**
 * Find paths of all leaf nodes under an ancestor path (exclusive)
 * @param accessor
 * @param ancestorPath
 * @return a list of paths
 */
static List<String> scanPath(BaseDataAccessor<ZNRecord> accessor, String ancestorPath) {
  List<String> queue = Lists.newLinkedList();
  queue.add(ancestorPath);

  // BFS
  List<String> leafPaths = Lists.newArrayList();
  while (!queue.isEmpty()) {
    String path = queue.remove(0);
    List<String> childNames = accessor.getChildNames(path, 0);
    if (childNames == null) {
      // path doesn't exist
      continue;
    }
    if (childNames.isEmpty() && !path.equals(ancestorPath)) {
      // leaf node, excluding ancestorPath
      leafPaths.add(path);
    }
    for (String childName : childNames) {
      String subPath = String.format("%s/%s", path, childName);
      queue.add(subPath);
    }
  }
  return leafPaths;
}
 
开发者ID:apache,项目名称:helix,代码行数:31,代码来源:ZKPathDataDumpTask.java


示例12: deepCopyZNRecord

import org.apache.helix.ZNRecord; //导入依赖的package包/类
/**
 * Return a deep copy of a ZNRecord.
 *
 * @return
 */
public ZNRecord deepCopyZNRecord(ZNRecord record) {
  ZNRecord copy = new ZNRecord(record.getId());

  copy.getSimpleFields().putAll(record.getSimpleFields());
  for (String mapKey : record.getMapFields().keySet()) {
    Map<String, String> mapField = record.getMapFields().get(mapKey);
    copy.getMapFields().put(mapKey, new TreeMap<String, String>(mapField));
  }

  for (String listKey : record.getListFields().keySet()) {
    copy.getListFields().put(listKey, new ArrayList<String>(record.getListFields().get(listKey)));
  }
  if (record.getRawPayload() != null) {
    byte[] rawPayload = new byte[record.getRawPayload().length];
    System.arraycopy(record.getRawPayload(), 0, rawPayload, 0, record.getRawPayload().length);
    copy.setRawPayload(rawPayload);
  }

  copy.setVersion(record.getVersion());
  copy.setCreationTime(record.getCreationTime());
  copy.setModifiedTime(record.getModifiedTime());

  return copy;
}
 
开发者ID:apache,项目名称:helix,代码行数:30,代码来源:TestResourceMonitor.java


示例13: getResourcesInClusterWithTag

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Override
public List<String> getResourcesInClusterWithTag(String clusterName, String tag) {
  List<String> resourcesWithTag = new ArrayList<String>();

  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
  Builder keyBuilder = accessor.keyBuilder();

  for (String resourceName : getResourcesInCluster(clusterName)) {
    IdealState is = accessor.getProperty(keyBuilder.idealStates(resourceName));
    if (is != null && is.getInstanceGroupTag() != null && is.getInstanceGroupTag().equals(tag)) {
      resourcesWithTag.add(resourceName);
    }
  }

  return resourcesWithTag;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:ZKHelixAdmin.java


示例14: addStateModelDef

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Override
public void addStateModelDef(String clusterName, String stateModelDef,
    StateModelDefinition stateModel, boolean recreateIfExists) {
  if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
    throw new HelixException("cluster " + clusterName + " is not setup yet");
  }
  String stateModelDefPath = PropertyPathBuilder.stateModelDef(clusterName);
  String stateModelPath = stateModelDefPath + "/" + stateModelDef;
  if (_zkClient.exists(stateModelPath)) {
    if (recreateIfExists) {
      logger.info(
          "Operation.State Model directory exists:" + stateModelPath + ", remove and recreate.");
      _zkClient.deleteRecursive(stateModelPath);
    } else {
      logger.info("Skip the operation. State Model directory exists:" + stateModelPath);
      return;
    }
  }

  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
  Builder keyBuilder = accessor.keyBuilder();
  accessor.setProperty(keyBuilder.stateModelDef(stateModelDef), stateModel);
}
 
开发者ID:apache,项目名称:helix,代码行数:25,代码来源:ZKHelixAdmin.java


示例15: dropCluster

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Override
public void dropCluster(String clusterName) {
  logger.info("Deleting cluster " + clusterName);
  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
  Builder keyBuilder = accessor.keyBuilder();

  String root = "/" + clusterName;
  if (accessor.getChildNames(keyBuilder.liveInstances()).size() > 0) {
    throw new HelixException(
        "There are still live instances in the cluster, shut them down first.");
  }

  if (accessor.getProperty(keyBuilder.controllerLeader()) != null) {
    throw new HelixException("There are still LEADER in the cluster, shut them down first.");
  }

  _zkClient.deleteRecursive(root);
}
 
开发者ID:apache,项目名称:helix,代码行数:20,代码来源:ZKHelixAdmin.java


示例16: testNoControllerLeader

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Test
public void testNoControllerLeader() {
  HelixManager helixManager = mock(HelixManager.class);
  HelixDataAccessor helixDataAccessor = mock(HelixDataAccessor.class);
  BaseDataAccessor<ZNRecord> baseDataAccessor = mock(BaseDataAccessor.class);

  when(helixManager.getHelixDataAccessor()).thenReturn(helixDataAccessor);
  when(helixDataAccessor.getBaseDataAccessor()).thenReturn(baseDataAccessor);
  when(baseDataAccessor.get(anyString(), (Stat) any(), anyInt())).thenThrow(new RuntimeException());

  // Create Controller Leader Locator
  FakeControllerLeaderLocator.create(helixManager);
  ControllerLeaderLocator controllerLeaderLocator = FakeControllerLeaderLocator.getInstance();

  Assert.assertEquals(controllerLeaderLocator.getControllerLeader(), null);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:17,代码来源:ControllerLeaderLocatorTest.java


示例17: get

import org.apache.helix.ZNRecord; //导入依赖的package包/类
public static ZNRecord get(Client client, String url) throws IOException {
  Reference resourceRef = new Reference(url);
  Request request = new Request(Method.GET, resourceRef);
  Response response = client.handle(request);
  Assert.assertEquals(response.getStatus(), Status.SUCCESS_OK);
  Representation result = response.getEntity();
  StringWriter sw = new StringWriter();
  result.write(sw);

  String responseStr = sw.toString();
  Assert.assertTrue(responseStr.toLowerCase().indexOf("error") == -1);
  Assert.assertTrue(responseStr.toLowerCase().indexOf("exception") == -1);
  ObjectMapper mapper = new ObjectMapper();
  ZNRecord record = mapper.readValue(new StringReader(responseStr), ZNRecord.class);
  return record;
}
 
开发者ID:apache,项目名称:helix,代码行数:17,代码来源:AdminTestHelper.java


示例18: addInstanceTag

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Override
public void addInstanceTag(String clusterName, String instanceName, String tag) {
  if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
    throw new HelixException("cluster " + clusterName + " is not setup yet");
  }

  if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
    throw new HelixException(
        "cluster " + clusterName + " instance " + instanceName + " is not setup yet");
  }
  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
  Builder keyBuilder = accessor.keyBuilder();

  InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
  config.addTag(tag);
  accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:ZKHelixAdmin.java


示例19: getStateModelsRepresentation

import org.apache.helix.ZNRecord; //导入依赖的package包/类
StringRepresentation getStateModelsRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);

  List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);

  ZNRecord modelDefinitions = new ZNRecord("modelDefinitions");
  modelDefinitions.setListField("models", models);

  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions),
          MediaType.APPLICATION_JSON);

  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:StateModelsResource.java


示例20: test

import org.apache.helix.ZNRecord; //导入依赖的package包/类
@Test public void test() {
  int nPartitions = 16;
  final String resourceName = "something";
  final List<String> instanceNames =
      Arrays.asList("node-1", "node-2", "node-3", "node-4"); // Initialize to 4 unique strings

  final int nReplicas = 3;

  List<String> partitions = new ArrayList<String>(nPartitions);
  for (int i = 0; i < nPartitions; i++) {
    partitions.add(Integer.toString(i));
  }

  LinkedHashMap<String, Integer> states = new LinkedHashMap<String, Integer>(2);
  states.put("OFFLINE", 0);
  states.put("ONLINE", nReplicas);

  AutoRebalanceStrategy strategy = new AutoRebalanceStrategy(resourceName, partitions, states);
  ZNRecord znRecord = strategy.computePartitionAssignment(instanceNames, instanceNames,
      new HashMap<String, Map<String, String>>(0), null);

  for (List p : znRecord.getListFields().values()) {
    Assert.assertEquals(p.size(), nReplicas);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:26,代码来源:TestAutoRebalanceStrategy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CharLiteral类代码示例发布时间:2022-05-23
下一篇:
Java ClipboardService类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap