Skip to content

Commit

Permalink
correct errmsg format for Preconditions.check... (apache#12327)
Browse files Browse the repository at this point in the history
  • Loading branch information
klsince authored Jan 26, 2024
1 parent 5a382f2 commit 2acf8ea
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ public Set<String> getServers(String tableNameWithType, String segmentName) {
throw new IllegalStateException("Ideal state does not exist for table: " + tableNameWithType);
}
Map<String, String> 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<String> servers = new TreeSet<>();
for (Map.Entry<String, String> entry : instanceStateMap.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void retryRebalanceTable(String tableNameWithType, Map<String, Map<String, Strin
// Get tableConfig only when the table needs to retry rebalance, and get it before submitting rebalance to another
// thread, in order to avoid unnecessary ZK reads and making too many ZK reads in a short time.
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);
_executorService.submit(() -> {
// Retry rebalance in another thread as rebalance can take time.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ BlockingQueue<String> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<PinotTaskConfig> generateTasks(List<TableConfig> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public List<PinotTaskConfig> generateTasks(List<TableConfig> tableConfigs) {
TableTaskConfig tableTaskConfig = tableConfig.getTaskConfig();
Preconditions.checkState(tableTaskConfig != null);
Map<String, String> 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public List<PinotTaskConfig> generateTasks(List<TableConfig> tableConfigs) {
Preconditions.checkNotNull(tableTaskConfig);
Map<String, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public AggregateNode(int planFragmentId) {
public AggregateNode(int planFragmentId, DataSchema dataSchema, List<AggregateCall> aggCalls,
List<RexExpression> groupSet, List<RelHint> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 2acf8ea

Please sign in to comment.