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); }
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); }
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); } }
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; }
/** * 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); }
public long getCrc() { return Long.valueOf(getRecord().getSimpleField(SIMPLE_FIELD_CRC)); } }
/** * 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; } }
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(); }
String[] hostnameSplit = helixInstanceConfig.getHostName().split("_"); Preconditions.checkState(hostnameSplit.length >= 2); String adminPort = record.getSimpleField(CommonConstants.Helix.Instance.ADMIN_PORT_KEY);
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); }
previousInstanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS); String isShuttingDown = currentInstanceConfig.getRecord().getSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS);
@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"); } }
tableInfo.tag = idealState.getRecord().getSimpleField("INSTANCE_GROUP_TAG"); String rawTableName = stripTypeFromName(tableInfo.tableName); String rawTagName = stripTypeFromName(tableInfo.tag);
/** * Get the value of a test field corresponding to a request count * @return the number of requests */ public String getTestField() { return _record.getSimpleField("requestCountStat"); }
/** * 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()); }
/** * Get cluster fault zone type. * * @return */ public String getFaultZoneType() { return _record.getSimpleField(ClusterConfigProperty.FAULT_ZONE_TYPE.name()); }
/** * 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()); }
/** * Get the resource group name * * @return */ public String getResourceGroupName() { return _record.getSimpleField(IdealStateProperty.RESOURCE_GROUP_NAME.toString()); }
/** * 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()); }
/** * Get the session that this current state corresponds to * @return String session identifier */ public String getSessionId() { return _record.getSimpleField(CurrentStateProperty.SESSION_ID.name()); }