@Override public void init(Configuration configuration, TableConfig tableConfig, ZkHelixPropertyStore<ZNRecord> propertyStore, BrokerMetrics brokerMetrics) { super.init(configuration, tableConfig, propertyStore, brokerMetrics); _numReplicas = Integer.valueOf(tableConfig.getValidationConfig().getReplicasPerPartition()); }
when(mockTableConfig.getTableName()).thenReturn(tableName); SegmentsValidationAndRetentionConfig mockValidationConfig = mock(SegmentsValidationAndRetentionConfig.class); when(mockValidationConfig.getReplicasPerPartition()).thenReturn(Integer.toString(nReplicas)); when(mockValidationConfig.getReplicasPerPartitionNumber()).thenReturn(nReplicas); when(mockTableConfig.getValidationConfig()).thenReturn(mockValidationConfig);
when(mockTableConfig.getTableName()).thenReturn(tableName); SegmentsValidationAndRetentionConfig mockValidationConfig = mock(SegmentsValidationAndRetentionConfig.class); when(mockValidationConfig.getReplicasPerPartition()).thenReturn(Integer.toString(nReplicas)); when(mockValidationConfig.getReplicasPerPartitionNumber()).thenReturn(nReplicas); when(mockTableConfig.getValidationConfig()).thenReturn(mockValidationConfig);
public static void buildLowLevelRealtimeIdealStateFor(String realtimeTableName, TableConfig realtimeTableConfig, IdealState idealState, boolean enableBatchMessageMode) { // Validate replicasPerPartition here. 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 PinotHelixResourceManager.InvalidTableConfigException( "Invalid value for replicasPerPartition, expected a number: " + replicasPerPartitionStr, e); } if (idealState == null) { idealState = buildEmptyRealtimeIdealStateFor(realtimeTableName, nReplicas, enableBatchMessageMode); } final PinotLLCRealtimeSegmentManager segmentManager = PinotLLCRealtimeSegmentManager.getInstance(); try { segmentManager.setupNewTable(realtimeTableConfig, idealState); } catch (InvalidConfigException e) { throw new IllegalStateException("Caught exception when creating table " + realtimeTableName, e); } }
/** * If realtime table and includeConsuming=true, rebalance consuming segments. NewPartitionAssignment will be used only * in this case. Always rebalance completed (online) segments, NewPartitionAssignment unused in this case * @param idealState old ideal state * @param tableConfig table config of table tor rebalance * @param rebalanceUserConfig custom user configs for specific rebalance strategies * @param newPartitionAssignment new rebalanced partition assignments as part of the resource rebalance * @return */ @Override public IdealState getRebalancedIdealState(IdealState idealState, TableConfig tableConfig, Configuration rebalanceUserConfig, PartitionAssignment newPartitionAssignment) { String tableNameWithType = tableConfig.getTableName(); CommonConstants.Helix.TableType tableType = tableConfig.getTableType(); LOGGER.info("Rebalancing ideal state for table {}", tableNameWithType); // get target num replicas int targetNumReplicas; if (tableType.equals(CommonConstants.Helix.TableType.REALTIME)) { String replicasString = tableConfig.getValidationConfig().getReplicasPerPartition(); try { targetNumReplicas = Integer.parseInt(replicasString); } catch (Exception e) { throw new RuntimeException("Invalid value for replicasPerPartition:'" + replicasString + "'", e); } } else { targetNumReplicas = Integer.parseInt(tableConfig.getValidationConfig().getReplication()); } return rebalanceIdealState(idealState, tableConfig, targetNumReplicas, rebalanceUserConfig, newPartitionAssignment); }
String replicasPerPartitionStr = segmentsConfig.getReplicasPerPartition(); if (replicasPerPartitionStr == null) { throw new PinotHelixResourceManager.InvalidTableConfigException(
private PinotHelixResourceManager setupSegmentMetadata(TableConfig tableConfig, final long now, final int nSegments, List<String> segmentsToBeDeleted) { final int replicaCount = Integer.valueOf(tableConfig.getValidationConfig().getReplicasPerPartition());