org.apache.helix.ZNRecord.getSimpleField()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.apache.helix.ZNRecord.getSimpleField()方法的一些代码示例,展示了ZNRecord.getSimpleField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZNRecord.getSimpleField()方法的具体详情如下:
包路径:org.apache.helix.ZNRecord
类名称:ZNRecord
方法名:getSimpleField

ZNRecord.getSimpleField介绍

[英]Get a single String field
[中]获取单个字符串字段

代码示例

代码示例来源:origin: apache/incubator-pinot

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);
}

代码示例来源:origin: apache/incubator-pinot

public SegmentZKMetadata(ZNRecord znRecord) {
 _segmentName = znRecord.getSimpleField(CommonConstants.Segment.SEGMENT_NAME);
 _tableName = znRecord.getSimpleField(CommonConstants.Segment.TABLE_NAME);
 _crypterName = znRecord.getSimpleField(CommonConstants.Segment.CRYPTER_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);
}

代码示例来源:origin: apache/incubator-pinot

public RealtimeSegmentZKMetadata(ZNRecord znRecord) {
 super(znRecord);
 setSegmentType(SegmentType.REALTIME);
 _status = Status.valueOf(znRecord.getSimpleField(CommonConstants.Segment.Realtime.STATUS));
 _sizeThresholdToFlushSegment = znRecord.getIntField(CommonConstants.Segment.FLUSH_THRESHOLD_SIZE, -1);
 String flushThresholdTime = znRecord.getSimpleField(CommonConstants.Segment.FLUSH_THRESHOLD_TIME);
 if (flushThresholdTime != null && !flushThresholdTime.equals(NULL)) {
  _timeThresholdToFlushSegment = znRecord.getSimpleField(CommonConstants.Segment.FLUSH_THRESHOLD_TIME);
 }
}

代码示例来源:origin: org.apache.helix/helix-core

public static List<ZNRecordRow> convertSimpleFields(ZNRecord record) {
 List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
 for (String key : record.getSimpleFields().keySet()) {
  ZNRecordRow row = new ZNRecordRow();
  row.putField(ZNRECORD_ID, record.getId());
  row.putField(SIMPLE_KEY, key);
  row.putField(SIMPLE_VALUE, record.getSimpleField(key));
  result.add(row);
 }
 return result;
}

代码示例来源:origin: apache/incubator-pinot

/**
 * Fetch {@link Schema} from a {@link ZNRecord}.
 */
public static Schema fromZNRecord(@Nonnull ZNRecord record)
  throws IOException {
 String schemaJSON = record.getSimpleField("schemaJSON");
 return Schema.fromString(schemaJSON);
}

代码示例来源:origin: apache/incubator-pinot

public long getCrc() {
  return Long.valueOf(getRecord().getSimpleField(SIMPLE_FIELD_CRC));
 }
}

代码示例来源:origin: apache/incubator-pinot

/**
  * Returns True iff:
  * - The given instance is disabled in Helix.
  * - The instance is being shutdown.
  * False otherwise
  *
  * @param instanceName Name of instance to check.
  * @return True if instance is disabled in helix, or is being shutdown, False otherwise.
  */
 public boolean isInactive(String instanceName) {
  InstanceConfig instanceConfig = _instanceConfigMap.get(instanceName);
  if (instanceConfig == null) {
   LOGGER.error("Instance config for instance '{}' does not exist", instanceName);
   return true;
  }

  if (!instanceConfig.getInstanceEnabled()) {
   LOGGER.info("Instance '{}' is disabled", instanceName);
   return true;
  }

  if (Boolean
    .parseBoolean(instanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS))) {
   LOGGER.info("Instance '{}' is shutting down", instanceName);
   return true;
  }

  return false;
 }
}

代码示例来源:origin: apache/incubator-pinot

private boolean isLargeCluster(ExternalView externalView) {
 // Check if the number of replicas is sufficient to treat it as a large cluster
 final String helixReplicaCount = externalView.getRecord().getSimpleField("REPLICAS");
 final int replicaCount;
 try {
  replicaCount = Integer.parseInt(helixReplicaCount);
 } catch (Exception e) {
  LOGGER.warn("Failed to parse the replica count ({}) from external view of table {}", helixReplicaCount,
    externalView.getResourceName());
  return false;
 }
 if (replicaCount < _minReplicaCountForLargeCluster) {
  return false;
 }
 // Check if the server count is high enough to count as a large cluster
 final Set<String> instanceSet = new HashSet<>();
 for (String partition : externalView.getPartitionSet()) {
  instanceSet.addAll(externalView.getStateMap(partition).keySet());
 }
 return _minServerCountForLargeCluster <= instanceSet.size();
}

代码示例来源:origin: apache/incubator-pinot

String[] hostnameSplit = helixInstanceConfig.getHostName().split("_");
Preconditions.checkState(hostnameSplit.length >= 2);
String adminPort = record.getSimpleField(CommonConstants.Helix.Instance.ADMIN_PORT_KEY);

代码示例来源:origin: apache/incubator-pinot

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);
}

代码示例来源:origin: apache/incubator-pinot

previousInstanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS);
String isShuttingDown =
  currentInstanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS);

代码示例来源:origin: apache/incubator-pinot

@Test
public void testSegmentFlushSize()
  throws Exception {
 String zkSegmentsPath = "/SEGMENTS/" + TableNameBuilder.REALTIME.tableNameWithType(getTableName());
 List<String> segmentNames = _propertyStore.getChildNames(zkSegmentsPath, 0);
 for (String segmentName : segmentNames) {
  ZNRecord znRecord = _propertyStore.get(zkSegmentsPath + "/" + segmentName, null, 0);
  Assert.assertEquals(znRecord.getSimpleField(CommonConstants.Segment.FLUSH_THRESHOLD_SIZE),
    Integer.toString(getRealtimeSegmentFlushSize() / getNumKafkaPartitions()),
    "Segment: " + segmentName + " does not have the expected flush size");
 }
}

代码示例来源:origin: apache/incubator-pinot

tableInfo.tag = idealState.getRecord().getSimpleField("INSTANCE_GROUP_TAG");
String rawTableName = stripTypeFromName(tableInfo.tableName);
String rawTagName = stripTypeFromName(tableInfo.tag);

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Get the value of a test field corresponding to a request count
 * @return the number of requests
 */
public String getTestField() {
 return _record.getSimpleField("requestCountStat");
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Check for a group tag of this resource
 * @return the group tag, or null if none is present
 */
public String getInstanceGroupTag() {
 return _record.getSimpleField(ExternalViewProperty.INSTANCE_GROUP_TAG.toString());
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Get cluster fault zone type.
 *
 * @return
 */
public String getFaultZoneType() {
 return _record.getSimpleField(ClusterConfigProperty.FAULT_ZONE_TYPE.name());
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Get the resource type
 * @return the resource type, or null if none is being set
 */
public String getResourceType() {
 return _record.getSimpleField(IdealStateProperty.RESOURCE_TYPE.toString());
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Get the resource group name
 *
 * @return
 */
public String getResourceGroupName() {
 return _record.getSimpleField(IdealStateProperty.RESOURCE_GROUP_NAME.toString());
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Check for a tag that will restrict assignment to instances with a matching tag
 * @return the group tag, or null if none is present
 */
public String getInstanceGroupTag() {
 return _record.getSimpleField(IdealStateProperty.INSTANCE_GROUP_TAG.toString());
}

代码示例来源:origin: org.apache.helix/helix-core

/**
 * Get the session that this current state corresponds to
 * @return String session identifier
 */
public String getSessionId() {
 return _record.getSimpleField(CurrentStateProperty.SESSION_ID.name());
}

相关文章