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


Java ZNRecord.getSimpleField方法代码示例

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


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

示例1: OfflineSegmentZKMetadata

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public OfflineSegmentZKMetadata(ZNRecord znRecord) {
  super(znRecord);
  setSegmentType(SegmentType.OFFLINE);
  _downloadUrl = znRecord.getSimpleField(CommonConstants.Segment.Offline.DOWNLOAD_URL);
  _pushTime = znRecord.getLongField(CommonConstants.Segment.Offline.PUSH_TIME, Long.MIN_VALUE);
  _refreshTime = znRecord.getLongField(CommonConstants.Segment.Offline.REFRESH_TIME, Long.MIN_VALUE);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:8,代码来源:OfflineSegmentZKMetadata.java

示例2: SegmentZKMetadata

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public SegmentZKMetadata(ZNRecord znRecord) {
  _segmentName = znRecord.getSimpleField(CommonConstants.Segment.SEGMENT_NAME);
  _tableName = znRecord.getSimpleField(CommonConstants.Segment.TABLE_NAME);
  _segmentType = znRecord.getEnumField(CommonConstants.Segment.SEGMENT_TYPE, SegmentType.class, SegmentType.OFFLINE);
  _startTime = znRecord.getLongField(CommonConstants.Segment.START_TIME, -1);
  _endTime = znRecord.getLongField(CommonConstants.Segment.END_TIME, -1);
  if (znRecord.getSimpleFields().containsKey(CommonConstants.Segment.TIME_UNIT) &&
      !znRecord.getSimpleField(CommonConstants.Segment.TIME_UNIT).equals(NULL)) {
    _timeUnit = znRecord.getEnumField(CommonConstants.Segment.TIME_UNIT, TimeUnit.class, TimeUnit.DAYS);
  }
  _indexVersion = znRecord.getSimpleField(CommonConstants.Segment.INDEX_VERSION);
  _totalDocs = znRecord.getLongField(CommonConstants.Segment.TOTAL_DOCS, -1);
  _crc = znRecord.getLongField(CommonConstants.Segment.CRC, -1);
  _creationTime = znRecord.getLongField(CommonConstants.Segment.CREATION_TIME, -1);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:SegmentZKMetadata.java

示例3: getListFieldBound

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
private static int getListFieldBound(ZNRecord record) {
  int max = Integer.MAX_VALUE;
  if (record.getSimpleFields().containsKey(ZNRecord.LIST_FIELD_BOUND)) {
    String maxStr = record.getSimpleField(ZNRecord.LIST_FIELD_BOUND);
    try {
      max = Integer.parseInt(maxStr);
    } catch (Exception e) {
      LOG.error("IllegalNumberFormat for list field bound: " + maxStr);
    }
  }
  return max;
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ZNRecordStreamingSerializer.java

示例4: getListFieldBound

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
private static int getListFieldBound(ZNRecord record) {
  int max = Integer.MAX_VALUE;
  if (record.getSimpleFields().containsKey(ZNRecord.LIST_FIELD_BOUND)) {
    String maxStr = record.getSimpleField(ZNRecord.LIST_FIELD_BOUND);
    try {
      max = Integer.parseInt(maxStr);
    } catch (Exception e) {
      logger.error("IllegalNumberFormat for list field bound: " + maxStr);
    }
  }
  return max;
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ZNRecordSerializer.java

示例5: RebalanceConfig

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
/**
 * Instantiate from an znRecord
 *
 * @param znRecord
 */
public RebalanceConfig(ZNRecord znRecord) {
  _rebalanceDelay = znRecord.getLongField(RebalanceConfigProperty.REBALANCE_DELAY.name(), -1);
  _rebalanceMode = znRecord
      .getEnumField(RebalanceConfigProperty.REBALANCE_MODE.name(), RebalanceMode.class,
          RebalanceMode.NONE);
  _rebalancerClassName =
      znRecord.getSimpleField(RebalanceConfigProperty.REBALANCER_CLASS_NAME.name());
  _rebalanceStrategy = znRecord.getSimpleField(RebalanceConfigProperty.REBALANCE_STRATEGY.name());
  _delayRebalanceDisabled =
      znRecord.getBooleanField(RebalanceConfigProperty.DELAY_REBALANCE_DISABLED.name(), false);
  _rebalanceTimerPeriod =
      znRecord.getLongField(RebalanceConfigProperty.REBALANCE_TIMER_PERIOD.name(), -1);
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:RebalanceConfig.java

示例6: getSingleValue

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
private static String getSingleValue(ZNRecord record, ZnodePropertyType type, String key) {
  if (record == null || key == null) {
    return null;
  }

  String value = null;
  String keyParts[] = key.split("/");

  switch (type) {
  case SIMPLE:
    value = record.getSimpleField(key);
    break;
  case LIST:
    List<String> list = record.getListField(keyParts[0]);
    if (list == null) {
      logger.warn("invalid key for list field: " + key + ", map for key part-1 doesn't exist");
      return null;
    }
    int idx = Integer.parseInt(keyParts[1]);
    value = list.get(idx);
    break;
  case MAP:
    Map<String, String> map = record.getMapField(keyParts[0]);
    if (map == null) {
      logger.warn("invalid key for map field: " + key + ", map for key part-1 doesn't exist");
      return null;
    }
    value = map.get(keyParts[1]);
    break;
  default:
    break;
  }

  return value;
}
 
开发者ID:apache,项目名称:helix,代码行数:36,代码来源:TestExecutor.java

示例7: testUpdateConfigFields

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
@Test(dependsOnMethods = "testAddConfigFields")
public void testUpdateConfigFields() throws IOException {
  System.out.println("Start test :" + TestHelper.getTestMethodName());
  String cluster = _clusters.iterator().next();
  ClusterConfig config = getClusterConfigFromRest(cluster);

  ZNRecord record = config.getRecord();

  String key = record.getSimpleFields().keySet().iterator().next();
  String value = record.getSimpleField(key);
  record.getSimpleFields().clear();
  record.setSimpleField(key, value + "--updated");

  key = record.getListFields().keySet().iterator().next();
  List<String> list = record.getListField(key);
  list.remove(0);
  list.add("newValue--updated");
  record.getListFields().clear();
  record.setListField(key, list);

  key = record.getMapFields().keySet().iterator().next();
  Map<String, String> map = record.getMapField(key);
  Iterator it = map.entrySet().iterator();
  it.next();
  it.remove();
  map.put("newKey--updated", "newValue--updated");
  record.getMapFields().clear();
  record.setMapField(key, map);

  ClusterConfig prevConfig = getClusterConfigFromRest(cluster);
  updateClusterConfigFromRest(cluster, config, Command.update);
  ClusterConfig newConfig = getClusterConfigFromRest(cluster);

  prevConfig.getRecord().update(config.getRecord());
  Assert.assertEquals(newConfig, prevConfig,
      "cluster config from response: " + newConfig + " vs cluster config actually: " + prevConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:38,代码来源:TestClusterAccessor.java

示例8: testDeleteConfigFields

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
@Test (dependsOnMethods = "testUpdateConfigFields")
public void testDeleteConfigFields()
    throws IOException {
  System.out.println("Start test :" + TestHelper.getTestMethodName());
  String cluster = _clusters.iterator().next();
  ClusterConfig config = getClusterConfigFromRest(cluster);

  ZNRecord record = config.getRecord();

  String simpleKey = record.getSimpleFields().keySet().iterator().next();
  String value = record.getSimpleField(simpleKey);
  record.getSimpleFields().clear();
  record.setSimpleField(simpleKey, value);

  String listKey = record.getListFields().keySet().iterator().next();
  List<String> list = record.getListField(listKey);
  record.getListFields().clear();
  record.setListField(listKey, list);

  String mapKey = record.getMapFields().keySet().iterator().next();
  Map<String, String> map = record.getMapField(mapKey);
  record.getMapFields().clear();
  record.setMapField(mapKey, map);

  ClusterConfig prevConfig = getClusterConfigFromRest(cluster);
  updateClusterConfigFromRest(cluster, config, Command.delete);
  ClusterConfig newConfig = getClusterConfigFromRest(cluster);

  Assert.assertFalse(newConfig.getRecord().getSimpleFields().containsKey(simpleKey),
      "Failed to delete key " + simpleKey + " from cluster config");
  Assert.assertFalse(newConfig.getRecord().getListFields().containsKey(listKey),
      "Failed to delete key " + listKey + " from cluster config");
  Assert.assertFalse(newConfig.getRecord().getSimpleFields().containsKey(mapKey),
      "Failed to delete key " + mapKey + " from cluster config");

  prevConfig.getRecord().subtract(config.getRecord());
  Assert.assertEquals(newConfig, prevConfig,
      "cluster config from response: " + newConfig + " vs cluster config actually: "
          + prevConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:41,代码来源:TestClusterAccessor.java

示例9: getInstanceSessionId

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public static String getInstanceSessionId(ZkClient zkClient, String clusterName,
    String instanceName) {
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
  Builder keyBuilder = accessor.keyBuilder();

  ZNRecord liveInstance = accessor.getProperty(keyBuilder.liveInstance(instanceName)).getRecord();

  return liveInstance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString());
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:ClusterRepresentationUtil.java

示例10: getDataInstanceAdminEndpoints

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
/**
 * Provides admin endpoints for the provided data instances
 * @param instances instances for which to read endpoints
 * @return returns map of instances to their admin endpoints.
 * The return value is a bimap because admin instances are typically used for
 * http requests. So, on response, we need mapping from the endpoint to the
 * server instances. With BiMap, both mappings are easily available
 */
public @Nonnull
BiMap<String, String> getDataInstanceAdminEndpoints(@Nonnull Set<String> instances) {
  Preconditions.checkNotNull(instances);
  BiMap<String, String> endpointToInstance = HashBiMap.create(instances.size());
  for (String instance : instances) {
    InstanceConfig helixInstanceConfig = getHelixInstanceConfig(instance);
    ZNRecord record = helixInstanceConfig.getRecord();
    String[] hostnameSplit = helixInstanceConfig.getHostName().split("_");
    Preconditions.checkState(hostnameSplit.length >= 2);
    String port = record.getSimpleField(CommonConstants.Helix.Instance.ADMIN_PORT_KEY);
    endpointToInstance.put(instance, hostnameSplit[1] + ":" + port);
  }
  return endpointToInstance;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:23,代码来源:PinotHelixResourceManager.java

示例11: SegmentZKMetadata

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public SegmentZKMetadata(ZNRecord znRecord) {
  _segmentName = znRecord.getSimpleField(CommonConstants.Segment.SEGMENT_NAME);
  _tableName = znRecord.getSimpleField(CommonConstants.Segment.TABLE_NAME);
  _segmentType = znRecord.getEnumField(CommonConstants.Segment.SEGMENT_TYPE, SegmentType.class, SegmentType.OFFLINE);
  _startTime = znRecord.getLongField(CommonConstants.Segment.START_TIME, -1);
  _endTime = znRecord.getLongField(CommonConstants.Segment.END_TIME, -1);
  if (znRecord.getSimpleFields().containsKey(CommonConstants.Segment.TIME_UNIT) && !znRecord.getSimpleField(
      CommonConstants.Segment.TIME_UNIT).equals(NULL)) {
    setTimeUnit(znRecord.getEnumField(CommonConstants.Segment.TIME_UNIT, TimeUnit.class, TimeUnit.DAYS));
  }
  _indexVersion = znRecord.getSimpleField(CommonConstants.Segment.INDEX_VERSION);
  _totalRawDocs = znRecord.getLongField(CommonConstants.Segment.TOTAL_DOCS, -1);
  _crc = znRecord.getLongField(CommonConstants.Segment.CRC, -1);
  _creationTime = znRecord.getLongField(CommonConstants.Segment.CREATION_TIME, -1);

  try {
    String partitionMetadataJson = znRecord.getSimpleField(CommonConstants.Segment.PARTITION_METADATA);
    if (partitionMetadataJson != null) {
      _partitionMetadata = SegmentPartitionMetadata.fromJsonString(partitionMetadataJson);
    }
  } catch (IOException e) {
    LOGGER.error(
        "Exception caught while reading partition info from zk metadata for segment '{}', partition info dropped.",
        _segmentName, e);
  }
  _segmentUploadStartTime = znRecord.getLongField(CommonConstants.Segment.SEGMENT_UPLOAD_START_TIME, -1);
  _customMap = znRecord.getMapField(CommonConstants.Segment.CUSTOM_MAP);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:29,代码来源:SegmentZKMetadata.java

示例12: LLCRealtimeSegmentZKMetadata

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public LLCRealtimeSegmentZKMetadata(ZNRecord znRecord) {
  super(znRecord);
  _startOffset = Long.valueOf(znRecord.getSimpleField(START_OFFSET));
  _numReplicas = Integer.valueOf(znRecord.getSimpleField(NUM_REPLICAS));
  _endOffset = Long.valueOf(znRecord.getSimpleField(END_OFFSET));
  _downloadUrl = znRecord.getSimpleField(DOWNLOAD_URL);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:8,代码来源:LLCRealtimeSegmentZKMetadata.java

示例13: fromZNRecord

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
public static Schema fromZNRecord(ZNRecord record) throws JsonParseException, JsonMappingException, IOException {
  String schemaJSON = record.getSimpleField("schemaJSON");
  Schema schema = new ObjectMapper().readValue(record.getSimpleField("schemaJSON"), Schema.class);
  schema.setJSONSchema(schemaJSON);
  return schema;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:7,代码来源:Schema.java

示例14: main

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
/**
 * USAGE MySQLClusterClient zkAddress clusterName database partitionId Query
 * @param args
 * @throws Exception
 */
@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {

  Option zkServerOption =
      OptionBuilder.withLongOpt("zkAddress").withDescription("zookeeper address").create();
  zkServerOption.setArgs(1);
  zkServerOption.setRequired(true);
  zkServerOption.setArgName("zookeeperAddress(Required)");
  Option clusterNameOption =
      OptionBuilder.withLongOpt("cluster").withDescription("Cluster Name").create();
  clusterNameOption.setArgs(1);
  clusterNameOption.setRequired(true);
  clusterNameOption.setArgName("clusterName(Required)");
  Option dbNameOption =
      OptionBuilder.withLongOpt("database").withDescription("Database Name").create();
  dbNameOption.setArgs(1);
  dbNameOption.setRequired(true);
  dbNameOption.setArgName("databaseName(Required)");
  Option partitionOption =
      OptionBuilder.withLongOpt("partitionId").withDescription("Partition Id").create();
  partitionOption.setArgs(1);
  partitionOption.setRequired(true);
  partitionOption.setArgName("partitionId(Required)");
  Option queryOption = OptionBuilder.withLongOpt("sql").withDescription("sql").create();
  queryOption.setArgs(1);
  queryOption.setRequired(true);
  queryOption.setArgName("sql(Required)");

  Options options = new Options();
  options.addOption(zkServerOption);
  options.addOption(clusterNameOption);
  options.addOption(dbNameOption);
  options.addOption(partitionOption);
  options.addOption(queryOption);
  CommandLine cliParser = new GnuParser().parse(options, args);
  String zkAddress = cliParser.getOptionValue("zkAddress");
  String cluster = cliParser.getOptionValue("cluster");
  String database = cliParser.getOptionValue("database");
  String table = cliParser.getOptionValue("database");
  int partitionId = Integer.parseInt(cliParser.getOptionValue("partitionId"));
  String sql = cliParser.getOptionValue("sql");

  ConnectionURLProvider connectionURLProvider = new ConnectionURLProvider(zkAddress, cluster);
  connectionURLProvider.start();
  InstanceConfig instanceConfig = connectionURLProvider.getMaster(database, partitionId);
  String host = instanceConfig.getHostName();
  ZNRecord record = instanceConfig.getRecord();
  String port = record.getSimpleField(MySQLConstants.MYSQL_PORT);
  String userName = record.getSimpleField(MySQLConstants.MYSQL_SUPER_USER);
  String password = record.getSimpleField(MySQLConstants.MYSQL_SUPER_PASSWORD);
  Connection connection =
      DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "", userName, password);
  connection.setAutoCommit(true);
  connection.setCatalog(database +"_"+ partitionId);
  Statement statement = connection.createStatement();
  boolean execute = statement.execute(sql);
  if (execute) {
    ResultSet rs = statement.getResultSet();
    ResultSetMetaData rsmd = rs.getMetaData();
    int columnsNumber = rsmd.getColumnCount();
    StringBuilder sb = new StringBuilder();
    while (rs.next()) {
      for (int i = 1; i <= columnsNumber; i++) {
        if (i > 1)
          sb.append(",  ");
        String columnValue = rs.getString(i);
        sb.append(rsmd.getColumnName(i)+ " " + columnValue );
      }
      sb.append("\n");
    }
    LOG.info(sb);
  } else {
    LOG.info("Executed sql:" + sql + " on " + instanceConfig.getInstanceName());
  }
  connectionURLProvider.stop();
}
 
开发者ID:kishoreg,项目名称:fullmatix,代码行数:82,代码来源:MySQLClusterClient.java

示例15: testMsgTriggeredRebalance

import org.apache.helix.ZNRecord; //导入方法依赖的package包/类
@Test
public void testMsgTriggeredRebalance() throws Exception {
  String clusterName = "CLUSTER_" + _className + "_msgTrigger";
  System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));

  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  HelixManager manager = new DummyClusterManager(clusterName, accessor);
  ClusterEvent event = new ClusterEvent(ClusterEventType.Unknown);

  final String resourceName = "testResource_dup";
  String[] resourceGroups = new String[] {
    resourceName
  };

  TestHelper.setupEmptyCluster(_gZkClient, clusterName);

  // ideal state: node0 is MASTER, node1 is SLAVE
  // replica=2 means 1 master and 1 slave
  setupIdealState(clusterName, new int[] {
      0, 1
  }, resourceGroups, 1, 2);
  setupStateModel(clusterName);
  setupInstances(clusterName, new int[] {
      0, 1
  });
  setupLiveInstances(clusterName, new int[] {
      0, 1
  });

  ClusterControllerManager controller =
      new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
  controller.syncStart();

  // round1: controller sends O->S to both node0 and node1
  Thread.sleep(1000);

  Builder keyBuilder = accessor.keyBuilder();
  List<String> messages = accessor.getChildNames(keyBuilder.messages("localhost_0"));
  Assert.assertEquals(messages.size(), 1);
  messages = accessor.getChildNames(keyBuilder.messages("localhost_1"));
  Assert.assertEquals(messages.size(), 1);

  // round2: node0 and node1 update current states but not removing messages
  // controller's rebalance pipeline should be triggered but since messages are not
  // removed
  // no new messages will be sent
  setCurrentState(clusterName, "localhost_0", resourceName, resourceName + "_0", "session_0",
      "SLAVE");
  setCurrentState(clusterName, "localhost_1", resourceName, resourceName + "_0", "session_1",
      "SLAVE");
  Thread.sleep(1000);
  messages = accessor.getChildNames(keyBuilder.messages("localhost_0"));
  Assert.assertEquals(messages.size(), 1);

  messages = accessor.getChildNames(keyBuilder.messages("localhost_1"));
  Assert.assertEquals(messages.size(), 1);

  // round3: node0 removes message and controller's rebalance pipeline should be
  // triggered
  // and sends S->M to node0
  messages = accessor.getChildNames(keyBuilder.messages("localhost_0"));
  accessor.removeProperty(keyBuilder.message("localhost_0", messages.get(0)));
  Thread.sleep(1000);

  messages = accessor.getChildNames(keyBuilder.messages("localhost_0"));
  Assert.assertEquals(messages.size(), 1);
  ZNRecord msg =
      accessor.getProperty(keyBuilder.message("localhost_0", messages.get(0))).getRecord();
  String toState = msg.getSimpleField(Attributes.TO_STATE.toString());
  Assert.assertEquals(toState, "MASTER");

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

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


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