Java Code Examples for org.apache.helix.store.zk.ZkHelixPropertyStore#getChildren()

The following examples show how to use org.apache.helix.store.zk.ZkHelixPropertyStore#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZKMetadataProvider.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * NOTE: this method is very expensive, use {@link #getSegments(ZkHelixPropertyStore, String)} instead if only segment
 * segment names are needed.
 */
public static List<OfflineSegmentZKMetadata> getOfflineSegmentZKMetadataListForTable(
    ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {
  String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
  String parentPath = constructPropertyStorePathForResource(offlineTableName);
  List<ZNRecord> znRecords = propertyStore.getChildren(parentPath, null, AccessOption.PERSISTENT);
  if (znRecords != null) {
    int numZNRecords = znRecords.size();
    List<OfflineSegmentZKMetadata> offlineSegmentZKMetadataList = new ArrayList<>(numZNRecords);
    for (ZNRecord znRecord : znRecords) {
      // NOTE: it is possible that znRecord is null if the record gets removed while calling this method
      if (znRecord != null) {
        offlineSegmentZKMetadataList.add(new OfflineSegmentZKMetadata(znRecord));
      }
    }
    int numNullZNRecords = numZNRecords - offlineSegmentZKMetadataList.size();
    if (numNullZNRecords > 0) {
      LOGGER.warn("Failed to read {}/{} offline segment ZK metadata under path: {}", numZNRecords - numNullZNRecords,
          numZNRecords, parentPath);
    }
    return offlineSegmentZKMetadataList;
  } else {
    LOGGER.warn("Path: {} does not exist", parentPath);
    return Collections.emptyList();
  }
}
 
Example 2
Source File: ZKMetadataProvider.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * NOTE: this method is very expensive, use {@link #getSegments(ZkHelixPropertyStore, String)} instead if only segment
 * segment names are needed.
 */
public static List<RealtimeSegmentZKMetadata> getRealtimeSegmentZKMetadataListForTable(
    ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {
  String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
  String parentPath = constructPropertyStorePathForResource(realtimeTableName);
  List<ZNRecord> znRecords = propertyStore.getChildren(parentPath, null, AccessOption.PERSISTENT);
  if (znRecords != null) {
    int numZNRecords = znRecords.size();
    List<RealtimeSegmentZKMetadata> realtimeSegmentZKMetadataList = new ArrayList<>(numZNRecords);
    for (ZNRecord znRecord : znRecords) {
      // NOTE: it is possible that znRecord is null if the record gets removed while calling this method
      if (znRecord != null) {
        realtimeSegmentZKMetadataList.add(new RealtimeSegmentZKMetadata(znRecord));
      }
    }
    int numNullZNRecords = numZNRecords - realtimeSegmentZKMetadataList.size();
    if (numNullZNRecords > 0) {
      LOGGER.warn("Failed to read {}/{} realtime segment ZK metadata under path: {}", numZNRecords - numNullZNRecords,
          numZNRecords, parentPath);
    }
    return realtimeSegmentZKMetadataList;
  } else {
    LOGGER.warn("Path: {} does not exist", parentPath);
    return Collections.emptyList();
  }
}
 
Example 3
Source File: ZKMetadataProvider.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * NOTE: this method is very expensive, use {@link #getLLCRealtimeSegments(ZkHelixPropertyStore, String)} instead if
 * only segment names are needed.
 */
public static List<LLCRealtimeSegmentZKMetadata> getLLCRealtimeSegmentZKMetadataListForTable(
    ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {
  String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
  String parentPath = constructPropertyStorePathForResource(realtimeTableName);
  List<ZNRecord> znRecords = propertyStore.getChildren(parentPath, null, AccessOption.PERSISTENT);
  if (znRecords != null) {
    int numZNRecords = znRecords.size();
    List<LLCRealtimeSegmentZKMetadata> llcRealtimeSegmentZKMetadataList = new ArrayList<>(numZNRecords);
    for (ZNRecord znRecord : znRecords) {
      // NOTE: it is possible that znRecord is null if the record gets removed while calling this method
      if (znRecord != null) {
        llcRealtimeSegmentZKMetadataList.add(new LLCRealtimeSegmentZKMetadata(znRecord));
      }
    }
    int numNullZNRecords = numZNRecords - llcRealtimeSegmentZKMetadataList.size();
    if (numNullZNRecords > 0) {
      LOGGER.warn("Failed to read {}/{} LLC realtime segment ZK metadata under path: {}",
          numZNRecords - numNullZNRecords, numZNRecords, parentPath);
    }
    return llcRealtimeSegmentZKMetadataList;
  } else {
    LOGGER.warn("Path: {} does not exist", parentPath);
    return Collections.emptyList();
  }
}