From 2acf8ea354b30e2e8415cb763bae34f37cf26c6a Mon Sep 17 00:00:00 2001 From: Xiaobing <61892277+klsince@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:49:09 -0800 Subject: [PATCH] correct errmsg format for Preconditions.check... (#12327) --- .../pinot/common/tier/FixedTierSegmentSelector.java | 2 +- .../controller/helix/core/PinotHelixResourceManager.java | 2 +- .../controller/helix/core/rebalance/RebalanceChecker.java | 2 +- .../helix/core/relocation/SegmentRelocator.java | 2 +- .../data/manager/realtime/RealtimeTableDataManager.java | 4 ++-- .../batch/hadoop/HadoopSegmentCreationMapper.java | 2 +- .../plugin/minion/tasks/purge/PurgeTaskGenerator.java | 2 +- .../RealtimeToOfflineSegmentsTaskGenerator.java | 2 +- .../SegmentGenerationAndPushTaskGenerator.java | 2 +- .../pinot/query/planner/plannode/AggregateNode.java | 2 +- .../index/converter/SegmentV1V2ToV3FormatConverter.java | 8 ++++---- .../local/upsert/BasePartitionUpsertMetadataManager.java | 4 ++-- .../pinot/segment/spi/creator/SegmentGeneratorConfig.java | 2 +- .../org/apache/pinot/spi/data/DateTimeFormatSpec.java | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pinot-common/src/main/java/org/apache/pinot/common/tier/FixedTierSegmentSelector.java b/pinot-common/src/main/java/org/apache/pinot/common/tier/FixedTierSegmentSelector.java index 19ac10c91e2a..5e87b3e6d83c 100644 --- a/pinot-common/src/main/java/org/apache/pinot/common/tier/FixedTierSegmentSelector.java +++ b/pinot-common/src/main/java/org/apache/pinot/common/tier/FixedTierSegmentSelector.java @@ -61,7 +61,7 @@ public boolean selectSegment(String tableNameWithType, String segmentName) { SegmentZKMetadata segmentZKMetadata = ZKMetadataProvider.getSegmentZKMetadata(_helixManager.getHelixPropertyStore(), tableNameWithType, segmentName); - Preconditions.checkNotNull(segmentZKMetadata, "Could not find zk metadata for segment: {} of table: {}", + Preconditions.checkNotNull(segmentZKMetadata, "Could not find zk metadata for segment: %s of table: %s", segmentName, tableNameWithType); return segmentZKMetadata.getStatus().isCompleted(); } diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java index 35c942aba680..36a55bef8a97 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java @@ -2765,7 +2765,7 @@ public Set getServers(String tableNameWithType, String segmentName) { throw new IllegalStateException("Ideal state does not exist for table: " + tableNameWithType); } Map instanceStateMap = idealState.getInstanceStateMap(segmentName); - Preconditions.checkState(instanceStateMap != null, "Segment: {} does not exist in the ideal state of table: {}", + Preconditions.checkState(instanceStateMap != null, "Segment: %s does not exist in the ideal state of table: %s", segmentName, tableNameWithType); Set servers = new TreeSet<>(); for (Map.Entry entry : instanceStateMap.entrySet()) { diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/RebalanceChecker.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/RebalanceChecker.java index ddd7a0df13a0..b9705e8ecc93 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/RebalanceChecker.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/RebalanceChecker.java @@ -151,7 +151,7 @@ void retryRebalanceTable(String tableNameWithType, Map { // Retry rebalance in another thread as rebalance can take time. try { diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java index b2a3b7148580..a37beaa3c95c 100644 --- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java +++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java @@ -146,7 +146,7 @@ BlockingQueue getWaitingQueue() { private void rebalanceTable(String tableNameWithType) { TableConfig tableConfig = _pinotHelixResourceManager.getTableConfig(tableNameWithType); - Preconditions.checkState(tableConfig != null, "Failed to find table config for table: {}", tableNameWithType); + Preconditions.checkState(tableConfig != null, "Failed to find table config for table: %s", tableNameWithType); boolean relocate = false; if (TierConfigUtils.shouldRelocateToTiers(tableConfig)) { diff --git a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java index 2ddc0f7eb58b..37e9d88f6839 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeTableDataManager.java @@ -170,7 +170,7 @@ protected void doInit() { File consumerDir = new File(consumerDirPath); if (consumerDir.exists()) { File[] segmentFiles = consumerDir.listFiles((dir, name) -> !name.equals(STATS_FILE_NAME)); - Preconditions.checkState(segmentFiles != null, "Failed to list segment files from consumer dir: {} for table: {}", + Preconditions.checkState(segmentFiles != null, "Failed to list segment files from consumer dir: %s for table: %s", consumerDirPath, _tableNameWithType); for (File file : segmentFiles) { if (file.delete()) { @@ -680,7 +680,7 @@ public void replaceLLSegment(String segmentName, IndexLoadingConfig indexLoading File indexDir = new File(_indexDir, segmentName); // Use the latest table config and schema to load the segment TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, _tableNameWithType); - Preconditions.checkState(tableConfig != null, "Failed to get table config for table: {}", _tableNameWithType); + Preconditions.checkState(tableConfig != null, "Failed to get table config for table: %s", _tableNameWithType); Schema schema = ZKMetadataProvider.getTableSchema(_propertyStore, tableConfig); // Construct a new indexLoadingConfig with the updated tableConfig and schema. diff --git a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java index 3fb658faae24..778276434006 100644 --- a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java +++ b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentCreationMapper.java @@ -108,7 +108,7 @@ public void setup(Context context) protected void map(LongWritable key, Text value, Context context) { try { String[] splits = StringUtils.split(value.toString(), ' '); - Preconditions.checkState(splits.length == 2, "Illegal input value: {}", value); + Preconditions.checkState(splits.length == 2, "Illegal input value: %s", value); String path = splits[0]; int idx = Integer.valueOf(splits[1]); diff --git a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/purge/PurgeTaskGenerator.java b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/purge/PurgeTaskGenerator.java index 02b9a472837a..e1f10b065b6b 100644 --- a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/purge/PurgeTaskGenerator.java +++ b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/purge/PurgeTaskGenerator.java @@ -67,7 +67,7 @@ public List generateTasks(List tableConfigs) { continue; } taskConfigs = tableTaskConfig.getConfigsForTaskType(MinionConstants.PurgeTask.TASK_TYPE); - Preconditions.checkNotNull(taskConfigs, "Task config shouldn't be null for Table: {}", tableName); + Preconditions.checkNotNull(taskConfigs, "Task config shouldn't be null for Table: %s", tableName); String deltaTimePeriod = taskConfigs.getOrDefault(MinionConstants.PurgeTask.LAST_PURGE_TIME_THREESOLD_PERIOD, diff --git a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/realtimetoofflinesegments/RealtimeToOfflineSegmentsTaskGenerator.java b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/realtimetoofflinesegments/RealtimeToOfflineSegmentsTaskGenerator.java index 750cb15416c4..c9654dd2a7ae 100644 --- a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/realtimetoofflinesegments/RealtimeToOfflineSegmentsTaskGenerator.java +++ b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/realtimetoofflinesegments/RealtimeToOfflineSegmentsTaskGenerator.java @@ -132,7 +132,7 @@ public List generateTasks(List tableConfigs) { TableTaskConfig tableTaskConfig = tableConfig.getTaskConfig(); Preconditions.checkState(tableTaskConfig != null); Map taskConfigs = tableTaskConfig.getConfigsForTaskType(taskType); - Preconditions.checkState(taskConfigs != null, "Task config shouldn't be null for table: {}", realtimeTableName); + Preconditions.checkState(taskConfigs != null, "Task config shouldn't be null for table: %s", realtimeTableName); // Get the bucket size and buffer String bucketTimePeriod = diff --git a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentgenerationandpush/SegmentGenerationAndPushTaskGenerator.java b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentgenerationandpush/SegmentGenerationAndPushTaskGenerator.java index 1b3f5c5df13f..d8f279ee58a8 100644 --- a/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentgenerationandpush/SegmentGenerationAndPushTaskGenerator.java +++ b/pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/segmentgenerationandpush/SegmentGenerationAndPushTaskGenerator.java @@ -109,7 +109,7 @@ public List generateTasks(List tableConfigs) { Preconditions.checkNotNull(tableTaskConfig); Map taskConfigs = tableTaskConfig.getConfigsForTaskType(MinionConstants.SegmentGenerationAndPushTask.TASK_TYPE); - Preconditions.checkNotNull(taskConfigs, "Task config shouldn't be null for Table: {}", tableNameWithType); + Preconditions.checkNotNull(taskConfigs, "Task config shouldn't be null for Table: %s", tableNameWithType); // Get max number of tasks for this table int tableMaxNumTasks; diff --git a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/plannode/AggregateNode.java b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/plannode/AggregateNode.java index 00dac34ebf64..4b31b53d1cfa 100644 --- a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/plannode/AggregateNode.java +++ b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/plannode/AggregateNode.java @@ -50,7 +50,7 @@ public AggregateNode(int planFragmentId) { public AggregateNode(int planFragmentId, DataSchema dataSchema, List aggCalls, List groupSet, List relHints) { super(planFragmentId, dataSchema); - Preconditions.checkState(areHintsValid(relHints), "invalid sql hint for agg node: {}", relHints); + Preconditions.checkState(areHintsValid(relHints), "invalid sql hint for agg node: %s", relHints); _aggCalls = aggCalls.stream().map(RexExpressionUtils::fromAggregateCall).collect(Collectors.toList()); _filterArgIndices = aggCalls.stream().map(c -> c.filterArg).collect(Collectors.toList()); _groupSet = groupSet; diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/converter/SegmentV1V2ToV3FormatConverter.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/converter/SegmentV1V2ToV3FormatConverter.java index a61a3acc8af3..ece4daf604d2 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/converter/SegmentV1V2ToV3FormatConverter.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/converter/SegmentV1V2ToV3FormatConverter.java @@ -76,11 +76,11 @@ public void convert(File v2SegmentDirectory) // check existing segment version SegmentMetadataImpl v2Metadata = new SegmentMetadataImpl(v2SegmentDirectory); SegmentVersion oldVersion = v2Metadata.getVersion(); - Preconditions.checkState(oldVersion != SegmentVersion.v3, "Segment {} is already in v3 format but at wrong path", + Preconditions.checkState(oldVersion != SegmentVersion.v3, "Segment %s is already in v3 format but at wrong path", v2Metadata.getName()); Preconditions.checkArgument(oldVersion == SegmentVersion.v1 || oldVersion == SegmentVersion.v2, - "Can not convert segment version: {} at path: {} ", oldVersion, v2SegmentDirectory); + "Can not convert segment version: %s at path: %s ", oldVersion, v2SegmentDirectory); deleteStaleConversionDirectories(v2SegmentDirectory); @@ -303,8 +303,8 @@ public static void main(String[] args) System.exit(1); } File tableDirectory = new File(args[0]); - Preconditions.checkState(tableDirectory.exists(), "Directory: {} does not exist", tableDirectory); - Preconditions.checkState(tableDirectory.isDirectory(), "Path: {} is not a directory", tableDirectory); + Preconditions.checkState(tableDirectory.exists(), "Directory: %s does not exist", tableDirectory); + Preconditions.checkState(tableDirectory.isDirectory(), "Path: %s is not a directory", tableDirectory); File[] files = tableDirectory.listFiles(); SegmentFormatConverter converter = new SegmentV1V2ToV3FormatConverter(); diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java index aca199659d9e..fa3c0842b27f 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java @@ -265,7 +265,7 @@ protected void updatePrimaryKeyGauge() { @Override public void preloadSegment(ImmutableSegment segment) { String segmentName = segment.getSegmentName(); - Preconditions.checkArgument(_enableSnapshot, "Snapshot must be enabled to preload segment: {}, table: {}", + Preconditions.checkArgument(_enableSnapshot, "Snapshot must be enabled to preload segment: %s, table: %s", segmentName, _tableNameWithType); // Note that EmptyIndexSegment should not reach here either, as it doesn't have validDocIds snapshot. Preconditions.checkArgument(segment instanceof ImmutableSegmentImpl, @@ -292,7 +292,7 @@ protected void doPreloadSegment(ImmutableSegmentImpl segment) { MutableRoaringBitmap validDocIds = segment.loadValidDocIdsFromSnapshot(); Preconditions.checkState(validDocIds != null, - "Snapshot of validDocIds is required to preload segment: {}, table: {}", segmentName, _tableNameWithType); + "Snapshot of validDocIds is required to preload segment: %s, table: %s", segmentName, _tableNameWithType); if (validDocIds.isEmpty()) { _logger.info("Skip preloading segment: {} without valid doc, current primary key count: {}", segment.getSegmentName(), getNumPrimaryKeys()); diff --git a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/SegmentGeneratorConfig.java b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/SegmentGeneratorConfig.java index 963af07a5cea..52abf41ea172 100644 --- a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/SegmentGeneratorConfig.java +++ b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/SegmentGeneratorConfig.java @@ -373,7 +373,7 @@ public String getInputFilePath() { public void setInputFilePath(String inputFilePath) { Preconditions.checkNotNull(inputFilePath); File inputFile = new File(inputFilePath); - Preconditions.checkState(inputFile.exists(), "Input path {} does not exist.", inputFilePath); + Preconditions.checkState(inputFile.exists(), "Input path %s does not exist.", inputFilePath); _inputFilePath = inputFile.getAbsolutePath(); } diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java index a4f47c93996d..a20250eff821 100644 --- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java +++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java @@ -215,7 +215,7 @@ public static DateTimeFormatSpec forEpoch(String timeUnit) { } public static DateTimeFormatSpec forEpoch(int size, String timeUnit) { - Preconditions.checkArgument(size > 0, "Invalid size: {}, must be positive", size); + Preconditions.checkArgument(size > 0, "Invalid size: %s, must be positive", size); Preconditions.checkArgument(timeUnit != null, "Must provide time unit"); return new DateTimeFormatSpec(size, new DateTimeFormatUnitSpec(timeUnit), DateTimeFormatPatternSpec.EPOCH); }