gpt4 book ai didi

org.apache.helix.store.zk.ZkHelixPropertyStore.get()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 09:16:49 27 4
gpt4 key购买 nike

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

ZkHelixPropertyStore.get介绍

暂无

代码示例

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

public ZNRecord get(String name) {
 return propertyStore.get(pathPrefix + "/" + name, null, AccessOption.PERSISTENT);
}

代码示例来源: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

@Nullable
public static Schema getSchema(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String schemaName) {
 try {
  ZNRecord schemaZNRecord =
    propertyStore.get(constructPropertyStorePathForSchema(schemaName), null, AccessOption.PERSISTENT);
  if (schemaZNRecord == null) {
   return null;
  }
  return SchemaUtils.fromZNRecord(schemaZNRecord);
 } catch (Exception e) {
  LOGGER.error("Caught exception while getting schema: {}", schemaName, e);
  return null;
 }
}

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

public LLCRealtimeSegmentZKMetadata getRealtimeSegmentZKMetadata(String realtimeTableName, String segmentName,
  Stat stat) {
 ZNRecord znRecord = _propertyStore
   .get(ZKMetadataProvider.constructPropertyStorePathForSegment(realtimeTableName, segmentName), stat,
     AccessOption.PERSISTENT);
 if (znRecord == null) {
  LOGGER.error("Segment metadata not found for table {}, segment {}. (can happen during table drop)",
    realtimeTableName, segmentName);
  throw new RuntimeException(
    "Segment metadata not found for table " + realtimeTableName + " segment " + segmentName);
 }
 return new LLCRealtimeSegmentZKMetadata(znRecord);
}

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

@Nullable
public static TableConfig getTableConfig(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore,
  @Nonnull String tableNameWithType) {
 ZNRecord znRecord = propertyStore
   .get(constructPropertyStorePathForResourceConfig(tableNameWithType), null, AccessOption.PERSISTENT);
 if (znRecord == null) {
  return null;
 }
 try {
  return TableConfig.fromZnRecord(znRecord);
 } catch (Exception e) {
  LOGGER.error("Caught exception while getting table configuration for table: {}", tableNameWithType, e);
  return null;
 }
}

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

@Nullable
public static OfflineSegmentZKMetadata getOfflineSegmentZKMetadata(
  @Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String tableName, @Nonnull String segmentName) {
 String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
 ZNRecord znRecord = propertyStore
   .get(constructPropertyStorePathForSegment(offlineTableName, segmentName), null, AccessOption.PERSISTENT);
 if (znRecord == null) {
  return null;
 }
 return new OfflineSegmentZKMetadata(znRecord);
}

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

public static InstanceZKMetadata getInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore,
  String instanceId) {
 ZNRecord znRecord = propertyStore
   .get(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceId), null, AccessOption.PERSISTENT);
 if (znRecord == null) {
  return null;
 }
 return new InstanceZKMetadata(znRecord);
}

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

private OfflineSegmentZKMetadata getOfflineSegmentMetadata(String tableName, String segmentName) {
  return new OfflineSegmentZKMetadata(
    _propertyStore.get(ZKMetadataProvider.constructPropertyStorePathForSegment(tableName, segmentName), null, 0));
 }
}

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

private TableConfig getTableConfig(String tableName)
  throws Exception {
 return TableConfig.fromZnRecord(
   _propertyStore.get(ZKMetadataProvider.constructPropertyStorePathForResourceConfig(tableName), null, 0));
}

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

private void validateSchema()
  throws Exception {
 List<String> schemaNames = getSchemaNames();
 LOGGER.info("Validating schemas: " + schemaNames);
 for (String schemaName : schemaNames) {
  LOGGER.info("  Validating schema: \"{}\"", schemaName);
  try {
   ZNRecord record = _helixPropertyStore.get(SCHEMA_PATH + "/" + schemaName, null, 0);
   Schema schema = SchemaUtils.fromZNRecord(record);
   if (!SchemaValidator.validate(schema)) {
    LOGGER.error("    Schema validation failed for schema: \"{}\"", schemaName);
   }
  } catch (Exception e) {
   LOGGER.error("    Caught exception while validating schema: \"{}\"", schemaName, e);
  }
 }
}

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

private void validateTableConfig()
  throws Exception {
 List<String> tableNames = getTableNames();
 LOGGER.info("Validating table config for tables: " + tableNames);
 for (String tableName : tableNames) {
  LOGGER.info("  Validating table config for table: \"{}\"", tableName);
  try {
   ZNRecord record = _helixPropertyStore.get(TABLE_CONFIG_PATH + "/" + tableName, null, 0);
   TableConfig tableConfig = TableConfig.fromZnRecord(record);
   if (!TableConfigValidator.validate(tableConfig)) {
    LOGGER.error("    Table config validation failed for table: \"{}\"", tableName);
   }
  } catch (Exception e) {
   LOGGER.error("    Caught exception while validating table config for table: \"{}\"", tableName, e);
  }
 }
}

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

@Nullable
public static ZNRecord getZnRecord(@Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String path) {
 Stat stat = new Stat();
 ZNRecord znRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT);
 if (znRecord != null) {
  znRecord.setCreationTime(stat.getCtime());
  znRecord.setModifiedTime(stat.getMtime());
  znRecord.setVersion(stat.getVersion());
 }
 return znRecord;
}

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

public static boolean getClusterTenantIsolationEnabled(ZkHelixPropertyStore<ZNRecord> propertyStore) {
  String controllerConfigPath = constructPropertyStorePathForControllerConfig(CLUSTER_TENANT_ISOLATION_ENABLED_KEY);
  if (propertyStore.exists(controllerConfigPath, AccessOption.PERSISTENT)) {
   ZNRecord znRecord = propertyStore.get(controllerConfigPath, null, AccessOption.PERSISTENT);
   if (znRecord.getSimpleFields().keySet().contains(CLUSTER_TENANT_ISOLATION_ENABLED_KEY)) {
    return znRecord.getBooleanField(CLUSTER_TENANT_ISOLATION_ENABLED_KEY, true);
   } else {
    return true;
   }
  } else {
   return true;
  }
 }
}

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

@Nullable
public static RealtimeSegmentZKMetadata getRealtimeSegmentZKMetadata(
  @Nonnull ZkHelixPropertyStore<ZNRecord> propertyStore, @Nonnull String tableName, @Nonnull String segmentName) {
 String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
 ZNRecord znRecord = propertyStore
   .get(constructPropertyStorePathForSegment(realtimeTableName, segmentName), null, AccessOption.PERSISTENT);
 // It is possible that the segment metadata has just been deleted due to retention.
 if (znRecord == null) {
  return null;
 }
 if (SegmentName.isHighLevelConsumerSegmentName(segmentName)) {
  return new RealtimeSegmentZKMetadata(znRecord);
 } else {
  return new LLCRealtimeSegmentZKMetadata(znRecord);
 }
}

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

/**
 * Read the segment merge lineage ZNRecord from the property store
 *
 * @param propertyStore a property store
 * @param tableNameWithType a table name with type
 * @return a ZNRecord of segment merge lineage, return null if znode does not exist
 */
public static ZNRecord getSegmentMergeLineageZNRecord(ZkHelixPropertyStore<ZNRecord> propertyStore,
  String tableNameWithType) {
 String path = ZKMetadataProvider.constructPropertyStorePathForSegmentMergeLineage(tableNameWithType);
 Stat stat = new Stat();
 ZNRecord segmentMergeLineageZNRecord = propertyStore.get(path, stat, AccessOption.PERSISTENT);
 if (segmentMergeLineageZNRecord != null) {
  segmentMergeLineageZNRecord.setVersion(stat.getVersion());
 }
 return segmentMergeLineageZNRecord;
}

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

private TableConfig getTableConfig(String tableName)
  throws IOException {
 ZNRecordSerializer serializer = new ZNRecordSerializer();
 String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, zkPath);
 ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<>(zkHost, serializer, path);
 ZNRecord tcZnRecord = propertyStore.get("/CONFIGS/TABLE/" + tableName, null, 0);
 TableConfig tableConfig = TableConfig.fromZnRecord(tcZnRecord);
 LOGGER.debug("Loaded table config");
 return tableConfig;
}

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

/**
 * Rebalances a table
 * @param tableName
 * @throws Exception
 */
public void rebalanceTable(String tableName)
  throws Exception {
 String tableConfigPath = "/CONFIGS/TABLE/" + tableName;
 Stat stat = new Stat();
 ZNRecord znRecord = propertyStore.get(tableConfigPath, stat, 0);
 TableConfig tableConfig = TableConfig.fromZnRecord(znRecord);
 String tenantName = tableConfig.getTenantConfig().getServer().replaceAll(TableType.OFFLINE.toString(), "")
   .replace(TableType.OFFLINE.toString(), "");
 rebalanceTable(tableName, tenantName);
}

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

/**
 * Read the replica group partition assignment from the property store
 * @param tableNameWithType a table name
 * @return Replica group partition assignment
 */
public ReplicaGroupPartitionAssignment getReplicaGroupPartitionAssignment(String tableNameWithType) {
 String path = ZKMetadataProvider.constructPropertyStorePathForInstancePartitions(tableNameWithType);
 ZNRecord replicaGroupPartitionAssignment = _propertyStore.get(path, null, AccessOption.PERSISTENT);
 ReplicaGroupPartitionAssignment partitionAssignment = null;
 if (replicaGroupPartitionAssignment != null) {
  partitionAssignment =
    new ReplicaGroupPartitionAssignment(tableNameWithType, replicaGroupPartitionAssignment.getListFields());
 }
 return partitionAssignment;
}

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

public static void setClusterTenantIsolationEnabled(ZkHelixPropertyStore<ZNRecord> propertyStore,
  boolean isSingleTenantCluster) {
 final ZNRecord znRecord;
 final String path = constructPropertyStorePathForControllerConfig(CLUSTER_TENANT_ISOLATION_ENABLED_KEY);
 if (!propertyStore.exists(path, AccessOption.PERSISTENT)) {
  znRecord = new ZNRecord(CLUSTER_TENANT_ISOLATION_ENABLED_KEY);
 } else {
  znRecord = propertyStore.get(path, null, AccessOption.PERSISTENT);
 }
 znRecord.setBooleanField(CLUSTER_TENANT_ISOLATION_ENABLED_KEY, isSingleTenantCluster);
 propertyStore.set(path, znRecord, AccessOption.PERSISTENT);
}

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

when(propertyStore.get("/SEGMENTS/myTable_OFFLINE/myTable_3", null, AccessOption.PERSISTENT))
  .thenReturn(znrecord);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com