use of com.linkedin.pinot.controller.helix.core.realtime.PinotLLCRealtimeSegmentManager in project pinot by linkedin.
the class PinotTableIdealStateBuilder method buildLowLevelRealtimeIdealStateFor.
public static void buildLowLevelRealtimeIdealStateFor(String realtimeTableName, AbstractTableConfig realtimeTableConfig, HelixAdmin helixAdmin, String helixClusterName, IdealState idealState) {
String realtimeServerTenant = ControllerTenantNameBuilder.getRealtimeTenantNameForTenant(realtimeTableConfig.getTenantConfig().getServer());
final List<String> realtimeInstances = helixAdmin.getInstancesInClusterWithTag(helixClusterName, realtimeServerTenant);
boolean create = false;
final String replicasPerPartitionStr = realtimeTableConfig.getValidationConfig().getReplicasPerPartition();
if (replicasPerPartitionStr == null || replicasPerPartitionStr.isEmpty()) {
throw new RuntimeException("Null or empty value for replicasPerPartition, expected a number");
}
final int nReplicas;
try {
nReplicas = Integer.valueOf(replicasPerPartitionStr);
} catch (NumberFormatException e) {
throw new RuntimeException("Invalid value for replicasPerPartition, expected a number: " + replicasPerPartitionStr, e);
}
if (idealState == null) {
idealState = buildEmptyKafkaConsumerRealtimeIdealStateFor(realtimeTableName, nReplicas);
create = true;
}
LOGGER.info("Assigning partitions to instances for simple consumer for table {}", realtimeTableName);
final KafkaStreamMetadata kafkaMetadata = new KafkaStreamMetadata(realtimeTableConfig.getIndexingConfig().getStreamConfigs());
final String topicName = kafkaMetadata.getKafkaTopicName();
final PinotLLCRealtimeSegmentManager segmentManager = PinotLLCRealtimeSegmentManager.getInstance();
final int nPartitions = getPartitionCount(kafkaMetadata);
LOGGER.info("Assigning {} partitions to instances for simple consumer for table {}", nPartitions, realtimeTableName);
segmentManager.setupHelixEntries(topicName, realtimeTableName, nPartitions, realtimeInstances, nReplicas, kafkaMetadata.getKafkaConsumerProperties().get(Helix.DataSource.Realtime.Kafka.AUTO_OFFSET_RESET), kafkaMetadata.getBootstrapHosts(), idealState, create, PinotLLCRealtimeSegmentManager.getRealtimeTableFlushSize(realtimeTableConfig));
}
Aggregations