diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannel.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannel.java index a2a6212fc0e5a..7061d515ad2d9 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannel.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannel.java @@ -57,7 +57,7 @@ public List fetch(final int batchSize, final long timeoutMillis) { long startMillis = System.currentTimeMillis(); int recordsCount = 0; do { - List records = queue.poll(Math.max(0, timeoutMillis - (System.currentTimeMillis() - startMillis)), TimeUnit.MILLISECONDS); + List records = queue.poll(Math.max(0L, timeoutMillis - (System.currentTimeMillis() - startMillis)), TimeUnit.MILLISECONDS); if (null == records || records.isEmpty()) { continue; } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckJobItemProgressContext.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckJobItemProgressContext.java index c493dc9afb9fb..dba540c9f7075 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckJobItemProgressContext.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckJobItemProgressContext.java @@ -48,7 +48,7 @@ public final class ConsistencyCheckJobItemProgressContext implements PipelineJob private volatile long recordsCount; - private final AtomicLong checkedRecordsCount = new AtomicLong(0); + private final AtomicLong checkedRecordsCount = new AtomicLong(0L); private final long checkBeginTimeMillis = System.currentTimeMillis(); diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java index 0aa0844db660e..f78eb54f97216 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java @@ -126,6 +126,6 @@ public static boolean isBigDecimalEquals(final BigDecimal one, final BigDecimal decimalTwo = another; } } - return decimalOne.equals(decimalTwo); + return 0 == decimalOne.compareTo(decimalTwo); } } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/TableDataConsistencyCheckResult.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/TableDataConsistencyCheckResult.java index 8d73495befa69..ebf462baea70f 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/TableDataConsistencyCheckResult.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/result/TableDataConsistencyCheckResult.java @@ -56,9 +56,6 @@ public boolean isIgnored() { * @return matched or not */ public boolean isMatched() { - if (null != ignoredType) { - return false; - } - return matched; + return null == ignoredType && matched; } } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java index abd1e1ecc0441..f9faf20e2ce10 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java @@ -62,7 +62,7 @@ public abstract class MatchingTableInventoryChecker implements TableInventoryChe @Override public TableDataConsistencyCheckResult checkSingleTableInventoryData() { ThreadFactory threadFactory = ExecutorThreadFactoryBuilder.build("job-" + getJobIdDigest(param.getJobId()) + "-matching-check-%d"); - ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2), threadFactory); + ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(2), threadFactory); try { return checkSingleTableInventoryData(param, executor); } finally { diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/sink/type/PipelineDataSourceSink.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/sink/type/PipelineDataSourceSink.java index 1cabadec3a880..8fdf6cfb94d93 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/sink/type/PipelineDataSourceSink.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/sink/type/PipelineDataSourceSink.java @@ -101,7 +101,7 @@ private void batchWrite(final Collection records) { if (i == importerConfig.getRetryTimes()) { throw new PipelineImporterJobWriteException(ex); } - Thread.sleep(Math.min(5 * 60 * 1000L, 1000L << i)); + Thread.sleep(Math.min(5L * 60L * 1000L, 1000L << i)); } } } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/UnsupportedKeyIngestPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/UnsupportedKeyIngestPosition.java index e589193eb452d..d8563ac1e4144 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/UnsupportedKeyIngestPosition.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/UnsupportedKeyIngestPosition.java @@ -36,7 +36,7 @@ public Void getEndValue() { @Override public Void convert(final String value) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(""); } @Override diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtils.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtils.java index 8972531cca2fa..459193309f3fa 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtils.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtils.java @@ -101,7 +101,7 @@ public static PipelineContextKey parseContextKey(final String jobId) { * @return ElasticJob configuration POJO */ public static JobConfigurationPOJO getElasticJobConfigurationPOJO(final String jobId) { - JobConfigurationPOJO result = PipelineAPIFactory.getJobConfigurationAPI(PipelineJobIdUtils.parseContextKey(jobId)).getJobConfiguration(jobId); + JobConfigurationPOJO result = PipelineAPIFactory.getJobConfigurationAPI(parseContextKey(jobId)).getJobConfiguration(jobId); ShardingSpherePreconditions.checkNotNull(result, () -> new PipelineJobNotFoundException(jobId)); return result; } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgress.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgress.java index 8d38f79fe0be5..56c18fa144c58 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgress.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgress.java @@ -70,7 +70,7 @@ private JobItemIncrementalTasksProgress getIncrementalTasksProgress(final Collec } private JobItemInventoryTasksProgress getInventoryTasksProgress(final Collection inventoryTasks) { - Map inventoryTaskProgressMap = new HashMap<>(); + Map inventoryTaskProgressMap = new HashMap<>(inventoryTasks.size(), 1F); for (PipelineTask each : inventoryTasks) { inventoryTaskProgressMap.put(each.getTaskId(), (InventoryTaskProgress) each.getTaskProgress()); } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistContext.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistContext.java index beafba57ba3bd..839950933e01d 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistContext.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistContext.java @@ -34,7 +34,7 @@ public final class PipelineJobProgressPersistContext { private final int shardingItem; - private final AtomicLong unhandledEventCount = new AtomicLong(0); + private final AtomicLong unhandledEventCount = new AtomicLong(0L); private final AtomicBoolean firstExceptionLogged = new AtomicBoolean(false); } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistService.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistService.java index e6bc68e054761..461efafcc9cb0 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistService.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/persist/PipelineJobProgressPersistService.java @@ -53,7 +53,7 @@ public final class PipelineJobProgressPersistService { private static final long DELAY_SECONDS = 1L; static { - JOB_PERSIST_EXECUTOR.scheduleWithFixedDelay(new PersistJobContextRunnable(), 0, DELAY_SECONDS, TimeUnit.SECONDS); + JOB_PERSIST_EXECUTOR.scheduleWithFixedDelay(new PersistJobContextRunnable(), 0L, DELAY_SECONDS, TimeUnit.SECONDS); } /** @@ -126,8 +126,8 @@ private static synchronized void persist(final String jobId, final int shardingI private static void persist0(final String jobId, final int shardingItem, final PipelineJobProgressPersistContext persistContext) { long currentUnhandledEventCount = persistContext.getUnhandledEventCount().get(); - ShardingSpherePreconditions.checkState(currentUnhandledEventCount >= 0, () -> new IllegalStateException("Current unhandled event count must be greater than or equal to 0")); - if (0 == currentUnhandledEventCount) { + ShardingSpherePreconditions.checkState(currentUnhandledEventCount >= 0L, () -> new IllegalStateException("Current unhandled event count must be greater than or equal to 0")); + if (0L == currentUnhandledEventCount) { return; } Optional jobItemContext = PipelineJobRegistry.getItemContext(jobId, shardingItem); diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/yaml/swapper/YamlJobItemInventoryTasksProgressSwapper.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/yaml/swapper/YamlJobItemInventoryTasksProgressSwapper.java index 914869491721c..e3c464b8f6695 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/yaml/swapper/YamlJobItemInventoryTasksProgressSwapper.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/progress/yaml/swapper/YamlJobItemInventoryTasksProgressSwapper.java @@ -75,7 +75,7 @@ public JobItemInventoryTasksProgress swapToObject(final YamlJobItemInventoryTask if (null == yamlProgress) { return new JobItemInventoryTasksProgress(Collections.emptyMap()); } - Map taskProgressMap = new LinkedHashMap<>(); + Map taskProgressMap = new LinkedHashMap<>(yamlProgress.getFinished().length + yamlProgress.getUnfinished().size(), 1F); taskProgressMap.putAll(Arrays.stream(yamlProgress.getFinished()).collect(Collectors.toMap(key -> key, value -> new InventoryTaskProgress(new IngestFinishedPosition())))); taskProgressMap.putAll(yamlProgress.getUnfinished().entrySet().stream().collect(Collectors.toMap(Entry::getKey, getInventoryTaskProgressFunction()))); return new JobItemInventoryTasksProgress(taskProgressMap); diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/TransmissionJobManager.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/TransmissionJobManager.java index 9dcd2cd4676d2..df81d4312cda7 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/TransmissionJobManager.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/service/TransmissionJobManager.java @@ -81,8 +81,8 @@ public static int getInventoryFinishedPercentage(final TransmissionJobItemProgre if (JobStatus.EXECUTE_INCREMENTAL_TASK == jobItemProgress.getStatus() || JobStatus.FINISHED == jobItemProgress.getStatus()) { return 100; } - if (0 != jobItemProgress.getProcessedRecordsCount() && 0 != jobItemProgress.getInventoryRecordsCount()) { - return (int) Math.min(100, jobItemProgress.getProcessedRecordsCount() * 100 / jobItemProgress.getInventoryRecordsCount()); + if (0L != jobItemProgress.getProcessedRecordsCount() && 0L != jobItemProgress.getInventoryRecordsCount()) { + return (int) Math.min(100L, jobItemProgress.getProcessedRecordsCount() * 100L / jobItemProgress.getInventoryRecordsCount()); } return 0; } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/StandardPipelineTableMetaDataLoader.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/StandardPipelineTableMetaDataLoader.java index 659777adb18f6..ac97df73d35bc 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/StandardPipelineTableMetaDataLoader.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/StandardPipelineTableMetaDataLoader.java @@ -89,7 +89,7 @@ private Map loadTableMetaData0 tableNames.add(tableName); } } - Map result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(tableNames.size(), 1F); for (String each : tableNames) { Set primaryKeys = loadPrimaryKeys(connection, schemaName, each); Map> uniqueKeys = loadUniqueIndexesOfTable(connection, schemaName, each); diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/PipelineJobDataSourcePreparer.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/PipelineJobDataSourcePreparer.java index b62427ccfea7e..20f71add9c07c 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/PipelineJobDataSourcePreparer.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/datasource/PipelineJobDataSourcePreparer.java @@ -69,7 +69,7 @@ public void prepareTargetSchemas(final PrepareTargetSchemasParameter param) thro } String defaultSchema = dialectDatabaseMetaData.getDefaultSchema().orElse(null); PipelinePrepareSQLBuilder pipelineSQLBuilder = new PipelinePrepareSQLBuilder(targetDatabaseType); - Collection createdSchemaNames = new HashSet<>(); + Collection createdSchemaNames = new HashSet<>(param.getCreateTableConfigurations().size(), 1F); for (CreateTableConfiguration each : param.getCreateTableConfigurations()) { String targetSchemaName = each.getTargetName().getSchemaName().toString(); if (null == targetSchemaName || targetSchemaName.equalsIgnoreCase(defaultSchema) || createdSchemaNames.contains(targetSchemaName)) { diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryRecordsCountCalculator.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryRecordsCountCalculator.java index 86c461ad110cd..0544ce606e576 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryRecordsCountCalculator.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryRecordsCountCalculator.java @@ -60,7 +60,7 @@ public static long getTableRecordsCount(final InventoryDumperContext dumperConte if (sql.isPresent()) { DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, dataSource.getDatabaseType().getType()); long result = getEstimatedCount(databaseType, dataSource, sql.get()); - return result > 0 ? result : getCount(dataSource, pipelineSQLBuilder.buildCountSQL(schemaName, actualTableName)); + return result > 0L ? result : getCount(dataSource, pipelineSQLBuilder.buildCountSQL(schemaName, actualTableName)); } return getCount(dataSource, pipelineSQLBuilder.buildCountSQL(schemaName, actualTableName)); } catch (final SQLException ex) { diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryTaskSplitter.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryTaskSplitter.java index cfe3c9e87d683..88a2f5536a5cd 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryTaskSplitter.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/InventoryTaskSplitter.java @@ -183,13 +183,13 @@ private Collection getInventoryPositions(final InventoryDumperCo private Collection getPositionByIntegerUniqueKeyRange(final InventoryDumperContext dumperContext, final long tableRecordsCount, final TransmissionJobItemContext jobItemContext, final PipelineDataSourceWrapper dataSource) { - if (0 == tableRecordsCount) { - return Collections.singletonList(new IntegerPrimaryKeyIngestPosition(0, 0)); + if (0L == tableRecordsCount) { + return Collections.singletonList(new IntegerPrimaryKeyIngestPosition(0L, 0L)); } Collection result = new LinkedList<>(); Range uniqueKeyValuesRange = getUniqueKeyValuesRange(jobItemContext, dataSource, dumperContext); int shardingSize = jobItemContext.getJobProcessContext().getProcessConfiguration().getRead().getShardingSize(); - long splitCount = tableRecordsCount / shardingSize + (tableRecordsCount % shardingSize > 0 ? 1 : 0); + long splitCount = tableRecordsCount / shardingSize + (tableRecordsCount % shardingSize > 0L ? 1 : 0); long interval = (uniqueKeyValuesRange.getMaximum() - uniqueKeyValuesRange.getMinimum()) / splitCount; IntervalToRangeIterator rangeIterator = new IntervalToRangeIterator(uniqueKeyValuesRange.getMinimum(), uniqueKeyValuesRange.getMaximum(), interval); while (rangeIterator.hasNext()) { diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registrycenter/repository/job/PipelineJobCheckGovernanceRepository.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registrycenter/repository/job/PipelineJobCheckGovernanceRepository.java index 4875f17983787..acaf37791396a 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registrycenter/repository/job/PipelineJobCheckGovernanceRepository.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/registrycenter/repository/job/PipelineJobCheckGovernanceRepository.java @@ -125,7 +125,7 @@ public void persistCheckJobResult(final String parentJobId, final String checkJo if (null == checkResultMap) { return; } - Map yamlCheckResultMap = new LinkedHashMap<>(); + Map yamlCheckResultMap = new LinkedHashMap<>(checkResultMap.size(), 1F); for (Entry entry : checkResultMap.entrySet()) { YamlTableDataConsistencyCheckResult yamlCheckResult = new YamlTableDataConsistencyCheckResultSwapper().swapToYamlConfiguration(entry.getValue()); yamlCheckResultMap.put(entry.getKey(), YamlEngine.marshal(yamlCheckResult)); diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineImportSQLBuilder.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineImportSQLBuilder.java index 735d6d266d366..d7c7e7861def7 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineImportSQLBuilder.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineImportSQLBuilder.java @@ -51,7 +51,7 @@ public final class PipelineImportSQLBuilder { public PipelineImportSQLBuilder(final DatabaseType databaseType) { dialectSQLBuilder = DatabaseTypedSPILoader.getService(DialectPipelineSQLBuilder.class, databaseType); sqlSegmentBuilder = new PipelineSQLSegmentBuilder(databaseType); - sqlCache = Caffeine.newBuilder().initialCapacity(16).maximumSize(1024).build(); + sqlCache = Caffeine.newBuilder().initialCapacity(16).maximumSize(1024L).build(); } /** diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/IntervalToRangeIterator.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/IntervalToRangeIterator.java index 2ac010aaaa7ba..ab8bbbfb7fa09 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/IntervalToRangeIterator.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/IntervalToRangeIterator.java @@ -40,12 +40,12 @@ public IntervalToRangeIterator(final long minimum, final long maximum, final lon if (minimum > maximum) { throw new IllegalArgumentException("minimum greater than maximum"); } - if (interval < 0) { + if (interval < 0L) { throw new IllegalArgumentException("interval is less than zero"); } this.maximum = maximum; this.interval = interval; - this.current = minimum; + current = minimum; } @Override @@ -56,11 +56,11 @@ public boolean hasNext() { @Override public Range next() { if (!hasNext()) { - throw new NoSuchElementException(); + throw new NoSuchElementException(""); } long upperLimit = Math.min(maximum, current + interval); Range result = Range.between(current, upperLimit); - current = upperLimit + 1; + current = upperLimit + 1L; return result; } } diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ShardingColumnsExtractor.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ShardingColumnsExtractor.java index 0d1773b5fd631..276b8581c7062 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ShardingColumnsExtractor.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ShardingColumnsExtractor.java @@ -55,7 +55,7 @@ public Map> getShardingColumnsMap(final C } Set defaultDatabaseShardingColumns = extractShardingColumns(shardingRuleConfig.get().getDefaultDatabaseShardingStrategy()); Set defaultTableShardingColumns = extractShardingColumns(shardingRuleConfig.get().getDefaultTableShardingStrategy()); - Map> result = new ConcurrentHashMap<>(); + Map> result = new ConcurrentHashMap<>(shardingRuleConfig.get().getTables().size(), 1F); for (ShardingTableRuleConfiguration each : shardingRuleConfig.get().getTables()) { CaseInsensitiveIdentifier logicTableName = new CaseInsensitiveIdentifier(each.getLogicTable()); if (!logicTableNames.contains(logicTableName)) { diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/MultiplexPipelineChannelTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/MultiplexPipelineChannelTest.java index 22e1292d10ebd..1d7f852b89b8a 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/MultiplexPipelineChannelTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/MultiplexPipelineChannelTest.java @@ -84,7 +84,7 @@ private void execute(final PipelineChannelAckCallback ackCallback, final int rec MultiplexPipelineChannel channel = new MultiplexPipelineChannel(CHANNEL_NUMBER, TypedSPILoader.getService(PipelineChannelCreator.class, "MEMORY"), 10000, ackCallback); fetchWithMultiThreads(channel, countDownLatch); channel.push(Arrays.asList(records)); - boolean awaitResult = countDownLatch.await(10, TimeUnit.SECONDS); + boolean awaitResult = countDownLatch.await(10L, TimeUnit.SECONDS); assertTrue(awaitResult, "await failed"); } diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckDataBuilder.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckDataBuilder.java index 9284bdff825cc..8174bc01255e4 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckDataBuilder.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/ConsistencyCheckDataBuilder.java @@ -33,7 +33,7 @@ public final class ConsistencyCheckDataBuilder { * @return built record */ public static Map buildFixedFullTypeRecord(final int id) { - Map result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(15, 1F); result.put("id", id); result.put("c_bool", true); result.put("c_int1", Byte.MAX_VALUE); @@ -97,13 +97,13 @@ private static Object getModifiedValue(final Object value) { return value + "-"; } if (value instanceof Time) { - return new Time(((Time) value).getTime() - 1); + return new Time(((Time) value).getTime() - 1L); } if (value instanceof Date) { - return new Date(((Date) value).getTime() - 1); + return new Date(((Date) value).getTime() - 1L); } if (value instanceof Timestamp) { - return new Timestamp(((Timestamp) value).getTime() - 1); + return new Timestamp(((Timestamp) value).getTime() - 1L); } if (value instanceof int[]) { int[] result = ((int[]) value).clone(); diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtilsTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtilsTest.java index 01676117059a8..7e2de6daa1852 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtilsTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtilsTest.java @@ -38,8 +38,8 @@ void assertIsIntegerEquals() { @Test void assertIsBigDecimalEquals() { - BigDecimal one = BigDecimal.valueOf(3322, 1); - BigDecimal another = BigDecimal.valueOf(33220, 2); + BigDecimal one = BigDecimal.valueOf(3322L, 1); + BigDecimal another = BigDecimal.valueOf(33220L, 2); assertTrue(DataConsistencyCheckUtils.isBigDecimalEquals(one, another)); } } diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32SingleTableInventoryCalculatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32SingleTableInventoryCalculatorTest.java index 04635829c2ea6..cf5b661cb6006 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32SingleTableInventoryCalculatorTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32SingleTableInventoryCalculatorTest.java @@ -93,7 +93,7 @@ private PreparedStatement mockPreparedStatement(final long expectedCRC32Result, @Test void assertCalculateFailed() throws SQLException { - when(connection.prepareStatement(anyString())).thenThrow(new SQLException()); + when(connection.prepareStatement(anyString())).thenThrow(new SQLException("")); assertThrows(PipelineTableDataConsistencyCheckLoadingFailedException.class, () -> new CRC32SingleTableInventoryCalculator().calculate(parameter)); } } diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java index 33750199d4609..2ae0b5792bb3a 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java @@ -35,7 +35,7 @@ class JobDataNodeLineConvertUtilsTest { @Test void assertConvertDataNodesToLines() { - Map> mockDataNodes = new LinkedHashMap<>(); + Map> mockDataNodes = new LinkedHashMap<>(2, 1F); List dataNodes = Arrays.asList(new DataNode("ds_0", "t_order_0"), new DataNode("ds_0", "t_order_1")); List itemDataNodes = Collections.singletonList(new DataNode("ds_0", "t_order_item_0")); mockDataNodes.put("t_order", dataNodes); @@ -51,10 +51,8 @@ void assertConvertDataNodesToLines() { @Test void assertConvertDataNodesToLinesWithMultipleDataSource() { - Map> mockDataNodes = new LinkedHashMap<>(); List dataNodes = Arrays.asList(new DataNode("ds_0", "t_order_0"), new DataNode("ds_0", "t_order_2"), new DataNode("ds_1", "t_order_1"), new DataNode("ds_1", "t_order_3")); - mockDataNodes.put("t_order", dataNodes); - List jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(mockDataNodes); + List jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(Collections.singletonMap("t_order", dataNodes)); assertThat(jobDataNodeLines.size(), is(2)); JobDataNodeEntry jobDataNodeEntry = jobDataNodeLines.get(0).getEntries().iterator().next(); assertThat(jobDataNodeEntry.getDataNodes().stream().map(DataNode::getTableName).collect(Collectors.toList()), is(Arrays.asList("t_order_0", "t_order_2"))); diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/IntegerPrimaryKeyIngestPositionTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/IntegerPrimaryKeyIngestPositionTest.java index 327d472ea9f02..9153d853bd212 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/IntegerPrimaryKeyIngestPositionTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/type/IntegerPrimaryKeyIngestPositionTest.java @@ -34,6 +34,6 @@ void assertInit() { @Test void assertToString() { - assertThat(new IntegerPrimaryKeyIngestPosition(1, 100).toString(), is("i,1,100")); + assertThat(new IntegerPrimaryKeyIngestPosition(1L, 100L).toString(), is("i,1,100")); } } diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/PipelineJobProgressDetectorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/PipelineJobProgressDetectorTest.java index fdbe2d2a88dab..9a3bfdd59711b 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/PipelineJobProgressDetectorTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/PipelineJobProgressDetectorTest.java @@ -24,15 +24,11 @@ import org.apache.shardingsphere.data.pipeline.core.ingest.position.type.finished.IngestFinishedPosition; import org.apache.shardingsphere.data.pipeline.core.ingest.position.type.placeholder.IngestPlaceholderPosition; import org.apache.shardingsphere.data.pipeline.core.task.InventoryTask; -import org.apache.shardingsphere.data.pipeline.core.task.PipelineTask; import org.apache.shardingsphere.data.pipeline.core.task.progress.InventoryTaskProgress; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -43,7 +39,7 @@ class PipelineJobProgressDetectorTest { @Test void assertAllInventoryTasksAreFinishedWhenCollectionIsEmpty() { - assertTrue(PipelineJobProgressDetector.isAllInventoryTasksFinished(new ArrayList<>())); + assertTrue(PipelineJobProgressDetector.isAllInventoryTasksFinished(Collections.emptyList())); } @Test @@ -52,10 +48,7 @@ void assertAllInventoryTasksAreFinishedWhenNotAllTasksAreFinished() { AtomicReference unfinishedPosition = new AtomicReference<>(new IngestPlaceholderPosition()); InventoryTask actualTask1 = new InventoryTask("foo_id_1", mock(ExecuteEngine.class), mock(ExecuteEngine.class), mock(Dumper.class), mock(Importer.class), finishedPosition); InventoryTask actualTask2 = new InventoryTask("foo_id_2", mock(ExecuteEngine.class), mock(ExecuteEngine.class), mock(Dumper.class), mock(Importer.class), unfinishedPosition); - Collection inventoryTaskArrayList = new ArrayList<>(); - inventoryTaskArrayList.add(actualTask1); - inventoryTaskArrayList.add(actualTask2); - assertFalse(PipelineJobProgressDetector.isAllInventoryTasksFinished(inventoryTaskArrayList)); + assertFalse(PipelineJobProgressDetector.isAllInventoryTasksFinished(Arrays.asList(actualTask1, actualTask2))); } @Test @@ -63,59 +56,42 @@ void assertAllInventoryTasksAreFinished() { AtomicReference finishedPosition = new AtomicReference<>(new IngestFinishedPosition()); InventoryTask actualTask1 = new InventoryTask("foo_id_1", mock(ExecuteEngine.class), mock(ExecuteEngine.class), mock(Dumper.class), mock(Importer.class), finishedPosition); InventoryTask actualTask2 = new InventoryTask("foo_id_2", mock(ExecuteEngine.class), mock(ExecuteEngine.class), mock(Dumper.class), mock(Importer.class), finishedPosition); - Collection inventoryTaskArrayList = new ArrayList<>(); - inventoryTaskArrayList.add(actualTask1); - inventoryTaskArrayList.add(actualTask2); - assertTrue(PipelineJobProgressDetector.isAllInventoryTasksFinished(inventoryTaskArrayList)); + assertTrue(PipelineJobProgressDetector.isAllInventoryTasksFinished(Arrays.asList(actualTask1, actualTask2))); } @Test void assertIsInventoryFinishedWhenCollectionElementIsNull() { TransmissionJobItemProgress jobItemProgress = null; - Collection jobItemProgresses = new ArrayList<>(); - jobItemProgresses.add(jobItemProgress); - assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, jobItemProgresses)); + assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, Collections.singleton(jobItemProgress))); } @Test void assertIsInventoryFinishedWhenJobCountDoesNotMatchJobItemProgresses() { TransmissionJobItemProgress transmissionJobItemProgress = new TransmissionJobItemProgress(); - List jobItemProgresses = new ArrayList<>(); - jobItemProgresses.add(transmissionJobItemProgress); - assertFalse(PipelineJobProgressDetector.isInventoryFinished(2, jobItemProgresses)); + assertFalse(PipelineJobProgressDetector.isInventoryFinished(2, Collections.singleton(transmissionJobItemProgress))); } @Test void assertIsInventoryFinishedWhenInventoryTaskProgressHasEmptyMap() { - JobItemInventoryTasksProgress jobItemInventoryTasksProgress = new JobItemInventoryTasksProgress(new HashMap<>()); + JobItemInventoryTasksProgress jobItemInventoryTasksProgress = new JobItemInventoryTasksProgress(Collections.emptyMap()); TransmissionJobItemProgress transmissionJobItemProgress = new TransmissionJobItemProgress(); transmissionJobItemProgress.setInventory(jobItemInventoryTasksProgress); - List jobItemProgresses = new ArrayList<>(); - jobItemProgresses.add(transmissionJobItemProgress); - assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, jobItemProgresses)); + assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, Collections.singleton(transmissionJobItemProgress))); } @Test void assertIsInventoryFinishedWhenNotAllInventoryTasksCompleted() { - Map progresses = new HashMap<>(); - progresses.put("TEST", new InventoryTaskProgress(new IngestPlaceholderPosition())); - JobItemInventoryTasksProgress inventoryTasksProgress = new JobItemInventoryTasksProgress(progresses); + JobItemInventoryTasksProgress inventoryTasksProgress = new JobItemInventoryTasksProgress(Collections.singletonMap("TEST", new InventoryTaskProgress(new IngestPlaceholderPosition()))); TransmissionJobItemProgress transmissionJobItemProgress = new TransmissionJobItemProgress(); transmissionJobItemProgress.setInventory(inventoryTasksProgress); - List jobItemProgresses = new ArrayList<>(); - jobItemProgresses.add(transmissionJobItemProgress); - assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, jobItemProgresses)); + assertFalse(PipelineJobProgressDetector.isInventoryFinished(1, Collections.singleton(transmissionJobItemProgress))); } @Test void assertIsInventoryFinished() { - Map progresses = new HashMap<>(); - progresses.put("TEST", new InventoryTaskProgress(new IngestFinishedPosition())); - JobItemInventoryTasksProgress inventoryTasksProgress = new JobItemInventoryTasksProgress(progresses); + JobItemInventoryTasksProgress inventoryTasksProgress = new JobItemInventoryTasksProgress(Collections.singletonMap("TEST", new InventoryTaskProgress(new IngestFinishedPosition()))); TransmissionJobItemProgress transmissionJobItemProgress = new TransmissionJobItemProgress(); transmissionJobItemProgress.setInventory(inventoryTasksProgress); - List jobItemProgresses = new ArrayList<>(); - jobItemProgresses.add(transmissionJobItemProgress); - assertTrue(PipelineJobProgressDetector.isInventoryFinished(1, jobItemProgresses)); + assertTrue(PipelineJobProgressDetector.isInventoryFinished(1, Collections.singleton(transmissionJobItemProgress))); } } diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java index 0831af6e1d8d6..6588d0bf8de6e 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java @@ -83,8 +83,8 @@ void assertGetIncrementalDataLatestActiveTimeMillis() { @Test void assertGetProgressesCorrectly() { - Map progresses = new HashMap<>(); - progresses.put("ds.order_item#0", new InventoryTaskProgress(new IntegerPrimaryKeyIngestPosition(1, 100))); + Map progresses = new HashMap<>(4, 1F); + progresses.put("ds.order_item#0", new InventoryTaskProgress(new IntegerPrimaryKeyIngestPosition(1L, 100L))); progresses.put("ds.order_item#1", new InventoryTaskProgress(new UnsupportedKeyIngestPosition())); progresses.put("ds.order#0", new InventoryTaskProgress(new IngestFinishedPosition())); progresses.put("ds.test_order#0", new InventoryTaskProgress(new StringPrimaryKeyIngestPosition("1", "100"))); diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNodeTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNodeTest.java index 2f2dd47479be0..7a0e9ce8467b0 100644 --- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNodeTest.java +++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNodeTest.java @@ -17,7 +17,6 @@ package org.apache.shardingsphere.data.pipeline.core.metadata.node; -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; @@ -37,7 +36,7 @@ class PipelineMetaDataNodeTest { @Test void assertGetMetaDataDataSourcesPath() { - MatcherAssert.assertThat(PipelineMetaDataNode.getMetaDataDataSourcesPath("FIXTURE"), is(migrationMetaDataRootPath + "/data_sources")); + assertThat(PipelineMetaDataNode.getMetaDataDataSourcesPath("FIXTURE"), is(migrationMetaDataRootPath + "/data_sources")); } @Test diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/GlobalTableMapEventMapping.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/GlobalTableMapEventMapping.java index 095bcc999a68e..78a215e80daa6 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/GlobalTableMapEventMapping.java +++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/GlobalTableMapEventMapping.java @@ -40,6 +40,6 @@ public final class GlobalTableMapEventMapping { * @return table map event map */ public static Map getTableMapEventMap(final String databaseURL) { - return TABLE_MAP_EVENT_MAPPING.computeIfAbsent(databaseURL, k -> new ConcurrentHashMap<>()); + return TABLE_MAP_EVENT_MAPPING.computeIfAbsent(databaseURL, key -> new ConcurrentHashMap<>()); } } diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java index 9ea0b0809b040..df60c00de2fc7 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java +++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java @@ -361,7 +361,7 @@ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cau private void reconnect() throws ExecutionException, InterruptedException, TimeoutException { Optional future = closeChannel(); if (future.isPresent()) { - future.get().get(1, TimeUnit.SECONDS); + future.get().get(1L, TimeUnit.SECONDS); } if (reconnectTimes.incrementAndGet() > 3) { log.warn("Exceeds the maximum number of retry times, last binlog event:{}", lastBinlogEvent); diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java index 1a88f402baca1..6691cc0207eb7 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java +++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java @@ -35,7 +35,7 @@ public Serializable handle(final Serializable value) { return null; } long longValue = (long) value; - return 0 > longValue ? BIGINT_MODULO.add(BigInteger.valueOf(longValue)) : longValue; + return 0L > longValue ? BIGINT_MODULO.add(BigInteger.valueOf(longValue)) : longValue; } @Override diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIngestPositionManagerTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIngestPositionManagerTest.java index eca2f990241e9..a6107d23c0b3c 100644 --- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIngestPositionManagerTest.java +++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIngestPositionManagerTest.java @@ -42,7 +42,7 @@ class MySQLIngestPositionManagerTest { private static final long LOG_POSITION = 4L; - private static final long SERVER_ID = 555555; + private static final long SERVER_ID = 555555L; @Mock(extraInterfaces = AutoCloseable.class) private DataSource dataSource; diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java index 5d7a31939a870..31ae65d93bcf1 100644 --- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java +++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java @@ -26,6 +26,6 @@ class BinlogPositionTest { @Test void assertToString() { - assertThat(new BinlogPosition("mysql-bin.000001", 4, 0L).toString(), is("mysql-bin.000001#4")); + assertThat(new BinlogPosition("mysql-bin.000001", 4L, 0L).toString(), is("mysql-bin.000001#4")); } } diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java index f117d8c680c2d..0485c7d65be6f 100644 --- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java +++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java @@ -100,7 +100,7 @@ void assertExecute() throws ReflectiveOperationException { @Test void assertExecuteUpdate() throws ReflectiveOperationException { - MySQLOKPacket expected = new MySQLOKPacket(10, 0, 0); + MySQLOKPacket expected = new MySQLOKPacket(10L, 0L, 0); Plugins.getMemberAccessor().set(MySQLOKPacket.class.getDeclaredField("affectedRows"), expected, 10L); mockChannelResponse(expected); Plugins.getMemberAccessor().set(MySQLClient.class.getDeclaredField("channel"), mysqlClient, channel); diff --git a/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java b/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java index bbed76a6b96ff..b50fcbc6eeede 100644 --- a/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java +++ b/kernel/data-pipeline/dialect/opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWALDumper.java @@ -95,7 +95,7 @@ public OpenGaussWALDumper(final IncrementalDumperContext dumperContext, final In this.channel = channel; walEventConverter = new WALEventConverter(dumperContext, metaDataLoader); logicalReplication = new OpenGaussLogicalReplication(); - this.decodeWithTX = dumperContext.isDecodeWithTX(); + decodeWithTX = dumperContext.isDecodeWithTX(); } @SneakyThrows(InterruptedException.class) diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/AbstractPostgreSQLDDLAdapter.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/AbstractPostgreSQLDDLAdapter.java index 1c0e88a6ca06e..de2ae2abc0b3a 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/AbstractPostgreSQLDDLAdapter.java +++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/AbstractPostgreSQLDDLAdapter.java @@ -65,8 +65,9 @@ private Collection> getRows(final ResultSet resultSet) throw ResultSetMetaData metaData = resultSet.getMetaData(); Collection> result = new LinkedList<>(); while (resultSet.next()) { - Map row = new LinkedHashMap<>(); - for (int i = 1; i <= metaData.getColumnCount(); i++) { + int columnCount = metaData.getColumnCount(); + Map row = new LinkedHashMap<>(columnCount); + for (int i = 1; i <= columnCount; i++) { row.put(metaData.getColumnName(i), resultSet.getObject(i)); } result.add(row); @@ -86,9 +87,10 @@ protected Map executeByTemplateForSingleRow(final Map getSingleRow(final ResultSet resultSet) throws SQLException { ResultSetMetaData metaData = resultSet.getMetaData(); - Map result = new LinkedHashMap<>(); + int columnCount = metaData.getColumnCount(); + Map result = new LinkedHashMap<>(columnCount); if (resultSet.next()) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { + for (int i = 1; i <= columnCount; i++) { result.put(metaData.getColumnName(i), resultSet.getObject(i)); } } @@ -102,7 +104,7 @@ protected void formatSecurityLabels(final Map data) throws SQLEx Collection> formatLabels = new LinkedList<>(); Collection securityLabels = Arrays.stream((String[]) ((Array) data.get("seclabels")).getArray()).collect(Collectors.toList()); for (String each : securityLabels) { - Map securityLabel = new LinkedHashMap<>(); + Map securityLabel = new LinkedHashMap<>(2, 1F); securityLabel.put("provider", each.substring(0, each.indexOf(SECURITY_LABEL_SPLIT))); securityLabel.put("label", each.substring(each.indexOf(SECURITY_LABEL_SPLIT) + 1)); formatLabels.add(securityLabel); diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnPropertiesAppender.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnPropertiesAppender.java index ea99972f0bd0d..4be24d07ca306 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnPropertiesAppender.java +++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnPropertiesAppender.java @@ -221,7 +221,7 @@ private String getFullDataType(final Map column) { name = name.substring(1, name.length() - 1); } Integer typmod = (Integer) column.get("atttypmod"); - String length = -1 != typmod ? checkTypmod(typmod, name) : ""; + String length = -1 == typmod ? "" : checkTypmod(typmod, name); return getFullTypeValue(name, schema, length, numdims == 1 ? "[]" : ""); } diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java index 649a20e900b4b..5fbf94c41e36b 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java +++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java @@ -44,7 +44,7 @@ public enum PostgreSQLColumnType { * @return value of column type */ public static PostgreSQLColumnType valueOf(final Long elemoid) { - if (0 == elemoid) { + if (0L == elemoid) { return UNKNOWN; } for (PostgreSQLColumnType each : values()) { diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWALDumper.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWALDumper.java index 5f7f2adac974d..2d1c5d9dff6bc 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWALDumper.java +++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWALDumper.java @@ -85,7 +85,7 @@ public PostgreSQLWALDumper(final IncrementalDumperContext dumperContext, final I this.channel = channel; walEventConverter = new WALEventConverter(dumperContext, metaDataLoader); logicalReplication = new PostgreSQLLogicalReplication(); - this.decodeWithTX = dumperContext.isDecodeWithTX(); + decodeWithTX = dumperContext.isDecodeWithTX(); } @SneakyThrows(InterruptedException.class) @@ -100,7 +100,7 @@ protected void runBlocking() { int times = reconnectTimes.incrementAndGet(); log.error("Connect failed, reconnect times={}", times, ex); if (isRunning()) { - Thread.sleep(5000); + Thread.sleep(5000L); } if (times >= 5) { throw new IngestException(ex); diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALEventConverterTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALEventConverterTest.java index fb1782907da69..8492f2756c740 100644 --- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALEventConverterTest.java +++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALEventConverterTest.java @@ -153,7 +153,7 @@ void assertConvertBeginTXEvent() { @Test void assertConvertCommitTXEvent() { - CommitTXEvent commitTXEvent = new CommitTXEvent(1, 3468L); + CommitTXEvent commitTXEvent = new CommitTXEvent(1L, 3468L); commitTXEvent.setLogSequenceNumber(new PostgreSQLLogSequenceNumber(logSequenceNumber)); Record record = walEventConverter.convert(commitTXEvent); assertInstanceOf(PlaceholderRecord.class, record); diff --git a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingJobStatusExecutor.java b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingJobStatusExecutor.java index ca408b4e353df..be7253f94fe5f 100644 --- a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingJobStatusExecutor.java +++ b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/distsql/handler/query/ShowStreamingJobStatusExecutor.java @@ -67,7 +67,7 @@ private LocalDataQueryResultRow getRow(final CDCJobItemInfo cdcJobItemInfo, fina } private static Optional getIncrementalIdleSeconds(final TransmissionJobItemProgress jobItemProgress, final TransmissionJobItemInfo transmissionJobItemInfo, final long currentTimeMillis) { - if (jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0) { + if (jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0L) { long latestActiveTimeMillis = Math.max(transmissionJobItemInfo.getStartTimeMillis(), jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis()); return Optional.of(TimeUnit.MILLISECONDS.toSeconds(currentTimeMillis - latestActiveTimeMillis)); } diff --git a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java index 83bf0bf39eea7..bb6e3553924a0 100644 --- a/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java +++ b/kernel/data-pipeline/distsql/handler/src/main/java/org/apache/shardingsphere/data/pipeline/migration/distsql/handler/query/ShowMigrationJobStatusExecutor.java @@ -60,7 +60,7 @@ private LocalDataQueryResultRow getRow(final TransmissionJobItemInfo jobItemInfo } private Optional getIncrementalIdleSeconds(final TransmissionJobItemProgress jobItemProgress, final TransmissionJobItemInfo jobItemInfo, final long currentTimeMillis) { - if (jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0) { + if (jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis() > 0L) { long latestActiveTimeMillis = Math.max(jobItemInfo.getStartTimeMillis(), jobItemProgress.getIncremental().getIncrementalLatestActiveTimeMillis()); return Optional.of(TimeUnit.MILLISECONDS.toSeconds(currentTimeMillis - latestActiveTimeMillis)); } diff --git a/kernel/data-pipeline/scenario/cdc/client/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/client/util/ProtobufAnyValueConverter.java b/kernel/data-pipeline/scenario/cdc/client/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/client/util/ProtobufAnyValueConverter.java index e1eebc88028ab..0a563cb3b0111 100644 --- a/kernel/data-pipeline/scenario/cdc/client/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/client/util/ProtobufAnyValueConverter.java +++ b/kernel/data-pipeline/scenario/cdc/client/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/client/util/ProtobufAnyValueConverter.java @@ -98,7 +98,7 @@ public static Object convertToObject(final Any any) throws InvalidProtocolBuffer } private static Timestamp converProtobufTimestamp(final com.google.protobuf.Timestamp timestamp) { - Timestamp result = new Timestamp(timestamp.getSeconds() * 1000); + Timestamp result = new Timestamp(timestamp.getSeconds() * 1000L); result.setNanos(timestamp.getNanos()); return result; } diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobType.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobType.java index 47fc27d3e94a4..eb97ea51f0c89 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobType.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobType.java @@ -72,7 +72,7 @@ public PipelineJobInfo getJobInfo(final String jobId) { @Override public PipelineDataConsistencyChecker buildDataConsistencyChecker(final PipelineJobConfiguration jobConfig, final TransmissionProcessContext processContext, final ConsistencyCheckJobItemProgressContext progressContext) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(""); } @Override diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java index 29e65fbfce1d7..b91a975f7a952 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java @@ -168,7 +168,7 @@ private YamlCDCJobConfiguration getYamlCDCJobConfiguration(final StreamDataParam } private ShardingSpherePipelineDataSourceConfiguration getDataSourceConfiguration(final ShardingSphereDatabase database) { - Map> dataSourcePoolProps = new HashMap<>(); + Map> dataSourcePoolProps = new HashMap<>(database.getResourceMetaData().getStorageUnits().size(), 1F); for (Entry entry : database.getResourceMetaData().getStorageUnits().entrySet()) { dataSourcePoolProps.put(entry.getKey(), dataSourceConfigSwapper.swapToMap(entry.getValue().getDataSourcePoolProperties())); } diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/context/CDCJobItemContext.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/context/CDCJobItemContext.java index dfb8b23d5b0a0..b721cc44b7b0b 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/context/CDCJobItemContext.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/context/CDCJobItemContext.java @@ -71,9 +71,9 @@ public final class CDCJobItemContext implements TransmissionJobItemContext { private final Collection incrementalTasks = new LinkedList<>(); - private final AtomicLong processedRecordsCount = new AtomicLong(0); + private final AtomicLong processedRecordsCount = new AtomicLong(0L); - private final AtomicLong inventoryRecordsCount = new AtomicLong(0); + private final AtomicLong inventoryRecordsCount = new AtomicLong(0L); private final LazyInitializer sourceDataSourceLazyInitializer = new LazyInitializer() { diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporter.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporter.java index ff130efc1a64f..2357fb41384e2 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporter.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporter.java @@ -71,7 +71,7 @@ public final class CDCImporter extends AbstractPipelineLifecycleRunnable impleme private final PriorityQueue csnRecordsQueue = new PriorityQueue<>(new CSNRecordsComparator()); - private final Cache>> ackCache = Caffeine.newBuilder().maximumSize(10000).expireAfterAccess(5, TimeUnit.MINUTES).build(); + private final Cache>> ackCache = Caffeine.newBuilder().maximumSize(10000L).expireAfterAccess(5L, TimeUnit.MINUTES).build(); @Override protected void runBlocking() { diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/handler/CDCBackendHandler.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/handler/CDCBackendHandler.java index 825e50df67a79..4baf8622e457f 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/handler/CDCBackendHandler.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/handler/CDCBackendHandler.java @@ -110,7 +110,7 @@ public CDCResponse streamData(final String requestId, final StreamDataRequestBod schemaTableNameMap = CDCSchemaTableUtils.parseTableExpressionWithSchema(database, requestBody.getSourceSchemaTableList()); // TODO if different schema have same table names, table name may be overwritten, because the table name at sharding rule not contain schema. tableNames = schemaTableNameMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); - schemaTableNameMap.forEach((k, v) -> v.forEach(tableName -> schemaTableNames.add(k.isEmpty() ? tableName : String.join(".", k, tableName)))); + schemaTableNameMap.forEach((key, value) -> value.forEach(tableName -> schemaTableNames.add(key.isEmpty() ? tableName : String.join(".", key, tableName)))); } else { schemaTableNames.addAll(CDCSchemaTableUtils.parseTableExpressionWithoutSchema(database, requestBody.getSourceSchemaTableList().stream().map(SchemaTable::getTable) .collect(Collectors.toList()))); diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCDataNodeUtils.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCDataNodeUtils.java index a7fab4f593ec4..2fc2d55845d58 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCDataNodeUtils.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCDataNodeUtils.java @@ -54,7 +54,7 @@ public static Map> buildDataNodesMap(final ShardingSphere Optional shardingRule = database.getRuleMetaData().findSingleRule(ShardingRule.class); Optional singleRule = database.getRuleMetaData().findSingleRule(SingleRule.class); Optional broadcastRule = database.getRuleMetaData().findSingleRule(BroadcastRule.class); - Map> result = new HashMap<>(); + Map> result = new HashMap<>(tableNames.size(), 1F); // TODO support virtual data source name for (String each : tableNames) { if (singleRule.isPresent() && singleRule.get().getAttributes().getAttribute(DataNodeRuleAttribute.class).getAllDataNodes().containsKey(each)) { diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtils.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtils.java index aaed4565c5818..be6fcb8150bb5 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtils.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtils.java @@ -77,7 +77,7 @@ public static Map> parseTableExpressionWithSchema(final Shar } private static Map> parseTableExpressionWithAllTables(final ShardingSphereDatabase database, final Collection systemSchemas) { - Map> result = new HashMap<>(database.getSchemas().size(), 1); + Map> result = new HashMap<>(database.getSchemas().size(), 1F); for (Entry entry : database.getSchemas().entrySet()) { if (!systemSchemas.contains(entry.getKey())) { entry.getValue().getAllTableNames().forEach(tableName -> result.computeIfAbsent(entry.getKey(), ignored -> new HashSet<>()).add(tableName)); @@ -88,7 +88,7 @@ private static Map> parseTableExpressionWithAllTables(final } private static Map> parseTableExpressionWithAllSchema(final ShardingSphereDatabase database, final Collection systemSchemas, final SchemaTable table) { - Map> result = new HashMap<>(); + Map> result = new HashMap<>(database.getSchemas().size(), 1F); for (Entry entry : database.getSchemas().entrySet()) { if (!systemSchemas.contains(entry.getKey())) { entry.getValue().getAllTableNames().stream().filter(tableName -> tableName.equals(table.getTable())).findFirst() @@ -99,11 +99,11 @@ private static Map> parseTableExpressionWithAllSchema(final } private static Map> parseTableExpressionWithAllTable(final ShardingSphereDatabase database, final SchemaTable each) { - Map> result = new HashMap<>(); DialectDatabaseMetaData dialectDatabaseMetaData = new DatabaseTypeRegistry(database.getProtocolType()).getDialectDatabaseMetaData(); String schemaName = each.getSchema().isEmpty() ? dialectDatabaseMetaData.getDefaultSchema().orElseThrow(() -> new IllegalStateException("Default schema should exist.")) : each.getSchema(); ShardingSphereSchema schema = database.getSchema(schemaName); ShardingSpherePreconditions.checkNotNull(schema, () -> new SchemaNotFoundException(each.getSchema())); + Map> result = new HashMap<>(schema.getAllTableNames().size(), 1F); schema.getAllTableNames().forEach(tableName -> result.computeIfAbsent(schemaName, ignored -> new HashSet<>()).add(tableName)); return result; } diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtils.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtils.java index 1f61502d80a07..0c200c8fc2f10 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtils.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtils.java @@ -135,11 +135,11 @@ public static Message convertToProtobufMessage(final Object object) { } if (object instanceof Clob) { Clob clob = (Clob) object; - return StringValue.of(clob.getSubString(1, (int) clob.length())); + return StringValue.of(clob.getSubString(1L, (int) clob.length())); } if (object instanceof Blob) { Blob blob = (Blob) object; - return BytesValue.of(ByteString.copyFrom(blob.getBytes(1, (int) blob.length()))); + return BytesValue.of(ByteString.copyFrom(blob.getBytes(1L, (int) blob.length()))); } return StringValue.newBuilder().setValue(object.toString()).build(); } @@ -147,9 +147,9 @@ public static Message convertToProtobufMessage(final Object object) { private static com.google.protobuf.Timestamp converToProtobufTimestamp(final Date timestamp) { if (timestamp instanceof Timestamp) { Timestamp value = (Timestamp) timestamp; - return com.google.protobuf.Timestamp.newBuilder().setSeconds(value.getTime() / 1000).setNanos(value.getNanos()).build(); + return com.google.protobuf.Timestamp.newBuilder().setSeconds(value.getTime() / 1000L).setNanos(value.getNanos()).build(); } long millis = timestamp.getTime(); - return com.google.protobuf.Timestamp.newBuilder().setSeconds(millis / 1000).setNanos((int) ((millis % 1000) * 1000000)).build(); + return com.google.protobuf.Timestamp.newBuilder().setSeconds(millis / 1000L).setNanos((int) ((millis % 1000L) * 1000000L)).build(); } } diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtilsTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtilsTest.java index 220be845acc2e..09ae021e0d7f5 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtilsTest.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/CDCSchemaTableUtilsTest.java @@ -42,13 +42,13 @@ class CDCSchemaTableUtilsTest { @Test void assertParseTableExpression() { - Map schemas = new HashMap<>(); + Map schemas = new HashMap<>(2, 1F); schemas.put("public", mockedPublicSchema()); schemas.put("test", mockedTestSchema()); ShardingSphereDatabase database = new ShardingSphereDatabase("sharding_db", TypedSPILoader.getService(DatabaseType.class, "openGauss"), null, null, schemas); List schemaTables = Arrays.asList(SchemaTable.newBuilder().setSchema("public").setTable("t_order").build(), SchemaTable.newBuilder().setSchema("test").setTable("*").build()); - Map> expected = new HashMap<>(); + Map> expected = new HashMap<>(2, 1F); expected.put("test", new HashSet<>(Arrays.asList("t_order_item", "t_order_item2"))); expected.put("public", Collections.singleton("t_order")); Map> actual = CDCSchemaTableUtils.parseTableExpressionWithSchema(database, schemaTables); @@ -59,8 +59,7 @@ void assertParseTableExpression() { assertThat(actual, is(expected)); schemaTables = Collections.singletonList(SchemaTable.newBuilder().setSchema("*").setTable("t_order").build()); actual = CDCSchemaTableUtils.parseTableExpressionWithSchema(database, schemaTables); - expected = new HashMap<>(); - expected.put("public", Collections.singleton("t_order")); + expected = Collections.singletonMap("public", Collections.singleton("t_order")); assertThat(actual, is(expected)); } diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtilsTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtilsTest.java index e9d33ef5d181a..86974d9597b46 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtilsTest.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/ColumnValueConvertUtilsTest.java @@ -110,7 +110,7 @@ void assertConvertToProtobufMessage() { @Test void assertTimeConvert() { - Time time = new Time(-3600 * 1000 - 1234); + Time time = new Time(-3600L * 1000L - 1234L); int nanos = new Timestamp(time.getTime()).getNanos(); Int64Value actualMessage = (Int64Value) ColumnValueConvertUtils.convertToProtobufMessage(time); assertThat(LocalTime.ofNanoOfDay(actualMessage.getValue()), is(time.toLocalTime().withNano(nanos))); diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/DataRecordResultConvertUtilsTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/DataRecordResultConvertUtilsTest.java index ffbb09e938b34..0f3c39146d509 100644 --- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/DataRecordResultConvertUtilsTest.java +++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/util/DataRecordResultConvertUtilsTest.java @@ -55,7 +55,7 @@ class DataRecordResultConvertUtilsTest { @Test void assertConvertDataRecordToRecord() throws InvalidProtocolBufferException, SQLException { - DataRecord dataRecord = new DataRecord(PipelineSQLOperationType.INSERT, "t_order", new IntegerPrimaryKeyIngestPosition(0, 1), 2); + DataRecord dataRecord = new DataRecord(PipelineSQLOperationType.INSERT, "t_order", new IntegerPrimaryKeyIngestPosition(0L, 1L), 2); dataRecord.addColumn(new Column("order_id", BigInteger.ONE, false, true)); dataRecord.addColumn(new Column("price", BigDecimal.valueOf(123), false, false)); dataRecord.addColumn(new Column("user_id", Long.MAX_VALUE, false, false)); diff --git a/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/api/ConsistencyCheckJobAPI.java b/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/api/ConsistencyCheckJobAPI.java index c22d89843c256..5726948ca1268 100644 --- a/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/api/ConsistencyCheckJobAPI.java +++ b/kernel/data-pipeline/scenario/consistencycheck/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/api/ConsistencyCheckJobAPI.java @@ -243,8 +243,8 @@ private void fillInJobItemInfoWithTimes(final ConsistencyCheckJobItemInfo result result.setDurationSeconds(duration.getSeconds()); result.setCheckEndTime(DateTimeFormatterFactory.getLongMillsFormatter().format(checkEndTime)); result.setInventoryRemainingSeconds(0L); - } else if (0 != recordsCount && 0 != checkedRecordsCount) { - result.setInventoryFinishedPercentage((int) (checkedRecordsCount * 100 / recordsCount)); + } else if (0L != recordsCount && 0L != checkedRecordsCount) { + result.setInventoryFinishedPercentage((int) (checkedRecordsCount * 100L / recordsCount)); LocalDateTime stopTime = jobConfigPOJO.isDisabled() ? LocalDateTime.from(DateTimeFormatterFactory.getStandardFormatter().parse(jobConfigPOJO.getProps().getProperty("stop_time"))) : null; long durationMillis = (null != stopTime ? Timestamp.valueOf(stopTime).getTime() : System.currentTimeMillis()) - jobItemProgress.getCheckBeginTimeMillis(); @@ -252,8 +252,8 @@ private void fillInJobItemInfoWithTimes(final ConsistencyCheckJobItemInfo result if (null != stopTime) { result.setCheckEndTime(jobConfigPOJO.getProps().getProperty("stop_time")); } - long remainingMills = Math.max(0, (long) ((recordsCount - checkedRecordsCount) * 1.0D / checkedRecordsCount * durationMillis)); - result.setInventoryRemainingSeconds(remainingMills / 1000); + long remainingMills = Math.max(0L, (long) ((recordsCount - checkedRecordsCount) * 1.0D / checkedRecordsCount * durationMillis)); + result.setInventoryRemainingSeconds(remainingMills / 1000L); } } diff --git a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java index 5e2ff9914d07c..ba4e11f69de0e 100644 --- a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java +++ b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/api/MigrationJobAPI.java @@ -173,7 +173,7 @@ private YamlPipelineDataSourceConfiguration buildYamlPipelineDataSourceConfigura } private PipelineDataSourceConfiguration buildTargetPipelineDataSourceConfiguration(final ShardingSphereDatabase targetDatabase) { - Map> targetPoolProps = new HashMap<>(); + Map> targetPoolProps = new HashMap<>(targetDatabase.getResourceMetaData().getStorageUnits().size(), 1F); YamlDataSourceConfigurationSwapper dataSourceConfigSwapper = new YamlDataSourceConfigurationSwapper(); for (Entry entry : targetDatabase.getResourceMetaData().getStorageUnits().entrySet()) { targetPoolProps.put(entry.getKey(), dataSourceConfigSwapper.swapToMap(entry.getValue().getDataSourcePoolProperties())); @@ -192,7 +192,7 @@ private YamlRootConfiguration buildYamlRootConfiguration(final String databaseNa } private Map buildTargetTableSchemaMap(final Map> sourceDataNodes) { - Map result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(sourceDataNodes.size(), 1F); sourceDataNodes.forEach((tableName, dataNodes) -> result.put(tableName, dataNodes.get(0).getSchemaName())); return result; } @@ -285,7 +285,7 @@ public void commit(final String jobId) { } private void refreshTableMetadata(final String jobId, final String databaseName) { - // TODO use origin database name now, wait reloadDatabaseMetaData fix case-sensitive probelm + // TODO use origin database name now, wait reloadDatabaseMetaData fix case-sensitive problem ContextManager contextManager = PipelineContextManager.getContext(PipelineJobIdUtils.parseContextKey(jobId)).getContextManager(); ShardingSphereDatabase database = contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName); contextManager.refreshTableMetaData(database); diff --git a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/context/MigrationJobItemContext.java b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/context/MigrationJobItemContext.java index a7caa8aa922ea..743ca8f47e444 100644 --- a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/context/MigrationJobItemContext.java +++ b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/context/MigrationJobItemContext.java @@ -67,9 +67,9 @@ public final class MigrationJobItemContext implements TransmissionJobItemContext private final Collection incrementalTasks = new LinkedList<>(); - private final AtomicLong processedRecordsCount = new AtomicLong(0); + private final AtomicLong processedRecordsCount = new AtomicLong(0L); - private final AtomicLong inventoryRecordsCount = new AtomicLong(0); + private final AtomicLong inventoryRecordsCount = new AtomicLong(0L); private final MigrationJobConfiguration jobConfig; @@ -98,7 +98,7 @@ public MigrationJobItemContext(final MigrationJobConfiguration jobConfig, final this.jobConfig = jobConfig; jobId = jobConfig.getJobId(); this.shardingItem = shardingItem; - this.dataSourceName = taskConfig.getDataSourceName(); + dataSourceName = taskConfig.getDataSourceName(); this.initProgress = initProgress; if (null != initProgress) { processedRecordsCount.set(initProgress.getProcessedRecordsCount()); diff --git a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/preparer/MigrationJobPreparer.java b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/preparer/MigrationJobPreparer.java index b0c695fc383ee..a893e286c24ed 100644 --- a/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/preparer/MigrationJobPreparer.java +++ b/kernel/data-pipeline/scenario/migration/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/preparer/MigrationJobPreparer.java @@ -130,7 +130,7 @@ private void prepareAndCheckTargetWithLock(final MigrationJobItemContext jobItem } LockDefinition lockDefinition = new GlobalLockDefinition(String.format(GlobalLockNames.PREPARE.getLockName(), jobConfig.getJobId())); long startTimeMillis = System.currentTimeMillis(); - if (lockContext.tryLock(lockDefinition, 600000)) { + if (lockContext.tryLock(lockDefinition, 600000L)) { log.info("try lock success, jobId={}, shardingItem={}, cost {} ms", jobId, jobItemContext.getShardingItem(), System.currentTimeMillis() - startTimeMillis); try { JobOffsetInfo offsetInfo = PipelineAPIFactory.getPipelineGovernanceFacade(PipelineJobIdUtils.parseContextKey(jobId)).getJobFacade().getOffset().load(jobId); diff --git a/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java b/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java index 48b69f7d39a23..67838b40bd99a 100644 --- a/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java +++ b/kernel/global-clock/type/tso/provider/redis/src/main/java/org/apache/shardingsphere/globalclock/type/tso/provider/RedisTSOProvider.java @@ -32,7 +32,7 @@ public final class RedisTSOProvider implements TSOProvider { private static final String CSN_KEY = "csn"; - private static final long ERROR_CSN = 0; + private static final long ERROR_CSN = 0L; private static final long INIT_CSN = Integer.MAX_VALUE; diff --git a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/util/LoggingUtils.java b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/util/LoggingUtils.java index 206e713952a8c..440283a7bc143 100644 --- a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/util/LoggingUtils.java +++ b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/util/LoggingUtils.java @@ -64,7 +64,7 @@ public static Optional getSQLLogger(final LoggingRuleConfi * @param props configuration properties */ public static void syncLoggingConfig(final LoggingRuleConfiguration loggingRuleConfig, final ConfigurationProperties props) { - LoggingUtils.getSQLLogger(loggingRuleConfig).ifPresent(option -> { + getSQLLogger(loggingRuleConfig).ifPresent(option -> { Properties loggerProps = option.getProps(); syncPropsToLoggingRule(loggerProps, props); syncLoggingRuleToProps(loggerProps, props); diff --git a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/database/DatabaseMetaDataPersistService.java b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/database/DatabaseMetaDataPersistService.java index 351629379eb2e..d3034bea2ee2b 100644 --- a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/database/DatabaseMetaDataPersistService.java +++ b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/database/DatabaseMetaDataPersistService.java @@ -48,8 +48,8 @@ public final class DatabaseMetaDataPersistService implements DatabaseMetaDataBas public DatabaseMetaDataPersistService(final PersistRepository repository, final MetaDataVersionPersistService metaDataVersionPersistService) { this.repository = repository; this.metaDataVersionPersistService = metaDataVersionPersistService; - this.tableMetaDataPersistService = new TableMetaDataPersistService(repository, metaDataVersionPersistService); - this.viewMetaDataPersistService = new ViewMetaDataPersistService(repository, metaDataVersionPersistService); + tableMetaDataPersistService = new TableMetaDataPersistService(repository, metaDataVersionPersistService); + viewMetaDataPersistService = new ViewMetaDataPersistService(repository, metaDataVersionPersistService); } @Override diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java index 42500e70f37a6..d8443e5d7cae1 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoader.java @@ -114,7 +114,7 @@ private static Map> load(final String databaseName, private static Map> loadSpecifiedDataNodes(final Map> actualDataNodes, final Collection featureRequiredSingleTables, final Map>> configuredTableMap) { - Map> result = new ConcurrentHashMap<>(); + Map> result = new ConcurrentHashMap<>(actualDataNodes.size(), 1F); for (Entry> entry : actualDataNodes.entrySet()) { Collection singleNode = loadSpecifiedDataNode(entry.getValue(), featureRequiredSingleTables, configuredTableMap); if (!singleNode.isEmpty()) { @@ -158,8 +158,8 @@ private static Map>> getConfiguredTableMa if (configuredTables.isEmpty()) { return Collections.emptyMap(); } - Map>> result = new LinkedHashMap<>(); Collection dataNodes = SingleTableLoadUtils.convertToDataNodes(databaseName, protocolType, configuredTables); + Map>> result = new LinkedHashMap<>(dataNodes.size(), 1F); for (DataNode each : dataNodes) { Map> schemaTables = result.getOrDefault(each.getDataSourceName(), new LinkedHashMap<>()); Collection tables = schemaTables.getOrDefault(each.getSchemaName(), new LinkedList<>()); diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decider/SingleSQLFederationDecider.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decider/SingleSQLFederationDecider.java index 0799b25da5fa9..899630731104f 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decider/SingleSQLFederationDecider.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decider/SingleSQLFederationDecider.java @@ -66,7 +66,7 @@ private boolean containsView(final ShardingSphereDatabase database, final Collec } private Collection getTableDataNodes(final SingleRule rule, final Collection singleTables) { - Collection result = new HashSet<>(); + Collection result = new HashSet<>(singleTables.size(), 1F); for (QualifiedTable each : singleTables) { rule.getAttributes().getAttribute(MutableDataNodeRuleAttribute.class).findTableDataNode(each.getSchemaName(), each.getTableName()).ifPresent(result::add); } diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java index 34182d0f86b00..e9b2c81838ff1 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/decorator/SingleRuleConfigurationDecorator.java @@ -82,8 +82,8 @@ private boolean isExpandRequired(final Collection splitTables) { private Collection loadSpecifiedTables(final boolean isSchemaSupportedDatabaseType, final Map> actualDataNodes, final Collection builtRules, final Collection configuredDataNodes) { - Collection expandRequiredDataSources = new LinkedHashSet<>(); - Map expectedDataNodes = new LinkedHashMap<>(); + Collection expandRequiredDataSources = new LinkedHashSet<>(configuredDataNodes.size(), 1F); + Map expectedDataNodes = new LinkedHashMap<>(configuredDataNodes.size(), 1F); for (DataNode each : configuredDataNodes) { if (SingleTableConstants.ASTERISK.equals(each.getTableName())) { expandRequiredDataSources.add(each.getDataSourceName()); @@ -101,7 +101,7 @@ private Collection loadSpecifiedTables(final boolean isSchemaSupportedDa private Collection loadSpecifiedTablesWithExpand(final boolean isSchemaSupportedDatabaseType, final Map> actualDataNodes, final Collection featureRequiredSingleTables, final Collection expandRequiredDataSources, final Map expectedDataNodes) { - Collection result = new LinkedHashSet<>(); + Collection result = new LinkedHashSet<>(actualDataNodes.size(), 1F); for (Entry> entry : actualDataNodes.entrySet()) { if (featureRequiredSingleTables.contains(entry.getKey())) { continue; @@ -125,7 +125,7 @@ private Collection loadSpecifiedTablesWithExpand(final boolean isSchemaS private Collection loadSpecifiedTablesWithoutExpand(final boolean isSchemaSupportedDatabaseType, final Map> actualDataNodes, final Collection configuredDataNodes) { - Collection result = new LinkedHashSet<>(); + Collection result = new LinkedHashSet<>(configuredDataNodes.size(), 1F); for (DataNode each : configuredDataNodes) { ShardingSpherePreconditions.checkContainsKey(actualDataNodes, each.getTableName(), () -> new SingleTableNotFoundException(getTableNodeString(isSchemaSupportedDatabaseType, each))); DataNode actualDataNode = actualDataNodes.get(each.getTableName()).iterator().next(); diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java index dc0309e457089..3a14dd9b0ede7 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java @@ -143,7 +143,7 @@ public static Collection splitTableLines(final Collection tables * @return data nodes */ public static Collection convertToDataNodes(final String databaseName, final DatabaseType databaseType, final Collection tables) { - Collection result = new LinkedHashSet<>(); + Collection result = new LinkedHashSet<>(tables.size(), 1F); for (String each : tables) { result.add(new DataNode(databaseName, databaseType, each)); } diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java index 3ce2a9ab09ad0..96e765ea2a634 100644 --- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java +++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java @@ -30,7 +30,7 @@ /** * Single rule configuration for YAML. */ -@RepositoryTupleEntity(value = "single") +@RepositoryTupleEntity("single") @Getter @Setter public final class YamlSingleRuleConfiguration implements YamlRuleConfiguration { diff --git a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java index 5e9263ba32008..216839ac96d37 100644 --- a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java +++ b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/LoadSingleTableExecutor.java @@ -131,7 +131,7 @@ private Collection getRequiredDataSources(final LoadSingleTableStatement } private Map>> getActualTableNodes(final Collection requiredDataSources, final Map aggregateDataSourceMap) { - Map>> result = new LinkedHashMap<>(); + Map>> result = new LinkedHashMap<>(requiredDataSources.size(), 1F); for (String each : requiredDataSources) { DataSource dataSource = aggregateDataSourceMap.get(each); Map> schemaTableNames = SingleTableDataNodeLoader.loadSchemaTableNames(database.getName(), DatabaseTypeEngine.getStorageType(dataSource), dataSource, each); diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java index d6a847fc057c6..0330f32d4dd9c 100644 --- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java +++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java @@ -54,7 +54,7 @@ public final class SQLFederationResultSetMetaData extends WrapperAdapter impleme public SQLFederationResultSetMetaData(final Schema sqlFederationSchema, final SelectStatementContext selectStatementContext, final RelDataType resultColumnType, final Map indexAndColumnLabels, final SQLFederationColumnTypeConverter columnTypeConverter) { this.sqlFederationSchema = sqlFederationSchema; - this.relDataTypeFactory = new JavaTypeFactoryImpl(); + relDataTypeFactory = new JavaTypeFactoryImpl(); this.selectStatementContext = selectStatementContext; this.resultColumnType = resultColumnType; this.indexAndColumnLabels = indexAndColumnLabels; diff --git a/kernel/sql-federation/distsql/parser/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/parser/core/SQLFederationDistSQLStatementVisitor.java b/kernel/sql-federation/distsql/parser/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/parser/core/SQLFederationDistSQLStatementVisitor.java index 5909767f1cf0e..633ed53c809a5 100644 --- a/kernel/sql-federation/distsql/parser/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/parser/core/SQLFederationDistSQLStatementVisitor.java +++ b/kernel/sql-federation/distsql/parser/src/main/java/org/apache/shardingsphere/sqlfederation/distsql/parser/core/SQLFederationDistSQLStatementVisitor.java @@ -42,7 +42,7 @@ public ASTNode visitShowSQLFederationRule(final ShowSQLFederationRuleContext ctx @Override public ASTNode visitAlterSQLFederationRule(final AlterSQLFederationRuleContext ctx) { - return super.visit(ctx.sqlFederationRuleDefinition()); + return visit(ctx.sqlFederationRuleDefinition()); } @Override diff --git a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java index cce7fc4e64d66..f0921d4772243 100644 --- a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java +++ b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java @@ -217,7 +217,7 @@ private List getParameters(final int[] paramIndexes) { if (null == paramIndexes) { return Collections.emptyList(); } - List result = new ArrayList<>(); + List result = new ArrayList<>(paramIndexes.length); for (int each : paramIndexes) { result.add(federationContext.getQueryContext().getParameters().get(each)); } diff --git a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java index 033d197964829..bb26814c93be3 100644 --- a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java +++ b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerator/JDBCRowEnumerator.java @@ -69,7 +69,7 @@ private void setCurrentRow() throws SQLException { for (int i = 0; i < metaData.getColumnCount(); i++) { rowValues[i] = getValue(i); } - this.currentRow = 1 == metaData.getColumnCount() ? rowValues[0] : rowValues; + currentRow = 1 == metaData.getColumnCount() ? rowValues[0] : rowValues; } private Object getValue(final int index) throws SQLException { diff --git a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/RowExpressionConverter.java b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/RowExpressionConverter.java index b2859fb320170..2134bce1fc033 100644 --- a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/RowExpressionConverter.java +++ b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/RowExpressionConverter.java @@ -43,7 +43,7 @@ public final class RowExpressionConverter { * @return sql node */ public static Optional convert(final RowExpression segment) { - List sqlNodes = new ArrayList<>(); + List sqlNodes = new ArrayList<>(segment.getItems().size()); for (ExpressionSegment each : segment.getItems()) { ExpressionConverter.convert(each).ifPresent(sqlNodes::add); } diff --git a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/operator/logical/LogicalScan.java b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/operator/logical/LogicalScan.java index 05b248444031b..eaf4c188dc659 100644 --- a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/operator/logical/LogicalScan.java +++ b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/operator/logical/LogicalScan.java @@ -48,7 +48,7 @@ public LogicalScan(final TableScan tableScan, final String databaseType) { } private void resetRowType(final RelNode relNode) { - this.rowType = relNode.getRowType(); + rowType = relNode.getRowType(); } /** diff --git a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/util/SQLFederationPlannerUtils.java b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/util/SQLFederationPlannerUtils.java index 6a7596ab65ea8..8ffc3f3bab3f0 100644 --- a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/util/SQLFederationPlannerUtils.java +++ b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/planner/util/SQLFederationPlannerUtils.java @@ -259,6 +259,6 @@ public static SqlToRelConverter createSqlToRelConverter(final CalciteCatalogRead * @return rel opt cluster */ public static RelOptCluster createRelOptCluster(final RelDataTypeFactory relDataTypeFactory) { - return RelOptCluster.create(SQLFederationPlannerUtils.createVolcanoPlanner(), new RexBuilder(relDataTypeFactory)); + return RelOptCluster.create(createVolcanoPlanner(), new RexBuilder(relDataTypeFactory)); } } diff --git a/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLStatementCompilerIT.java b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLStatementCompilerIT.java index f7bcbd4aaa89b..04b3ba3978ec7 100644 --- a/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLStatementCompilerIT.java +++ b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLStatementCompilerIT.java @@ -68,7 +68,7 @@ class SQLStatementCompilerIT { @BeforeEach void init() { - Map tables = new HashMap<>(); + Map tables = new HashMap<>(12, 1F); tables.put("t_order_federate", createOrderFederationTableMetaData()); tables.put("t_user_info", createUserInfoTableMetaData()); tables.put("t_order", createTOrderTableMetaData()); diff --git a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/SQLParserRuleTest.java b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/SQLParserRuleTest.java index 55c1b1fc99f94..d8897224dbc21 100644 --- a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/SQLParserRuleTest.java +++ b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/SQLParserRuleTest.java @@ -34,7 +34,7 @@ class SQLParserRuleTest { @BeforeEach void setup() { - sqlParserRule = new SQLParserRule(new SQLParserRuleConfiguration(new CacheOption(2, 4), new CacheOption(3, 7))); + sqlParserRule = new SQLParserRule(new SQLParserRuleConfiguration(new CacheOption(2, 4L), new CacheOption(3, 7L))); } @Test diff --git a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilderTest.java b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilderTest.java index 29746123292cc..3477814873f78 100644 --- a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilderTest.java +++ b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/rule/builder/SQLParserRuleBuilderTest.java @@ -24,7 +24,7 @@ import org.apache.shardingsphere.sql.parser.api.CacheOption; import org.junit.jupiter.api.Test; -import java.util.HashMap; +import java.util.Collections; import java.util.Properties; import static org.hamcrest.MatcherAssert.assertThat; @@ -34,8 +34,8 @@ class SQLParserRuleBuilderTest { @Test void assertBuild() { - SQLParserRuleConfiguration ruleConfig = new SQLParserRuleConfiguration(new CacheOption(2, 5), new CacheOption(4, 7)); - SQLParserRule actualResult = new SQLParserRuleBuilder().build(ruleConfig, new HashMap<>(), new ConfigurationProperties(new Properties())); + SQLParserRuleConfiguration ruleConfig = new SQLParserRuleConfiguration(new CacheOption(2, 5L), new CacheOption(4, 7L)); + SQLParserRule actualResult = new SQLParserRuleBuilder().build(ruleConfig, Collections.emptyMap(), new ConfigurationProperties(new Properties())); assertThat(actualResult.getConfiguration(), is(ruleConfig)); assertThat(actualResult.getSqlStatementCache().getInitialCapacity(), is(4)); assertThat(actualResult.getSqlStatementCache().getMaximumSize(), is(7L)); diff --git a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java index ec18c970232b9..2199069f743fd 100644 --- a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java +++ b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java @@ -28,7 +28,7 @@ class YamlSQLParserCacheOptionConfigurationSwapperTest { @Test void assertSwapToYamlConfiguration() { - YamlSQLParserCacheOptionRuleConfiguration actual = new YamlSQLParserCacheOptionConfigurationSwapper().swapToYamlConfiguration(new CacheOption(2, 5)); + YamlSQLParserCacheOptionRuleConfiguration actual = new YamlSQLParserCacheOptionConfigurationSwapper().swapToYamlConfiguration(new CacheOption(2, 5L)); assertThat(actual.getInitialCapacity(), is(2)); assertThat(actual.getMaximumSize(), is(5L)); } diff --git a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java index 7f395ea8f27fa..0d4d6078f6b2d 100644 --- a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java +++ b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java @@ -31,7 +31,7 @@ class YamlSQLParserRuleConfigurationSwapperTest { @Test void assertSwapToYamlConfiguration() { YamlSQLParserRuleConfiguration actual = - new YamlSQLParserRuleConfigurationSwapper().swapToYamlConfiguration(new SQLParserRuleConfiguration(new CacheOption(2, 5), new CacheOption(4, 7))); + new YamlSQLParserRuleConfigurationSwapper().swapToYamlConfiguration(new SQLParserRuleConfiguration(new CacheOption(2, 5L), new CacheOption(4, 7L))); assertThat(actual.getParseTreeCache().getInitialCapacity(), is(2)); assertThat(actual.getParseTreeCache().getMaximumSize(), is(5L)); assertThat(actual.getSqlStatementCache().getInitialCapacity(), is(4)); diff --git a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java index 2764e4158eca0..7d737c4e04621 100644 --- a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java +++ b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java @@ -51,7 +51,7 @@ void setUp() { private ContextManager mockContextManager() { ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS); SQLParserRule rule = mock(SQLParserRule.class); - when(rule.getConfiguration()).thenReturn(new SQLParserRuleConfiguration(new CacheOption(128, 1024), new CacheOption(2000, 65535))); + when(rule.getConfiguration()).thenReturn(new SQLParserRuleConfiguration(new CacheOption(128, 1024L), new CacheOption(2000, 65535L))); when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(rule)); return result; } diff --git a/kernel/sql-parser/distsql/parser/src/main/java/org/apache/shardingsphere/parser/distsql/parser/core/SQLParserDistSQLStatementVisitor.java b/kernel/sql-parser/distsql/parser/src/main/java/org/apache/shardingsphere/parser/distsql/parser/core/SQLParserDistSQLStatementVisitor.java index 348a9592c5fdd..3d4cb0e03ca5b 100644 --- a/kernel/sql-parser/distsql/parser/src/main/java/org/apache/shardingsphere/parser/distsql/parser/core/SQLParserDistSQLStatementVisitor.java +++ b/kernel/sql-parser/distsql/parser/src/main/java/org/apache/shardingsphere/parser/distsql/parser/core/SQLParserDistSQLStatementVisitor.java @@ -42,7 +42,7 @@ public ASTNode visitShowSQLParserRule(final ShowSQLParserRuleContext ctx) { @Override public ASTNode visitAlterSQLParserRule(final AlterSQLParserRuleContext ctx) { - return super.visit(ctx.sqlParserRuleDefinition()); + return visit(ctx.sqlParserRuleDefinition()); } @Override diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/ConnectionTransaction.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/ConnectionTransaction.java index 5adf0cc7b079d..55425f3153d37 100644 --- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/ConnectionTransaction.java +++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/ConnectionTransaction.java @@ -40,9 +40,9 @@ public final class ConnectionTransaction { private final TransactionConnectionContext transactionContext; public ConnectionTransaction(final TransactionRule rule, final TransactionConnectionContext transactionContext) { - this.transactionType = transactionContext.getTransactionType().isPresent() ? TransactionType.valueOf(transactionContext.getTransactionType().get()) : rule.getDefaultType(); + transactionType = transactionContext.getTransactionType().isPresent() ? TransactionType.valueOf(transactionContext.getTransactionType().get()) : rule.getDefaultType(); this.transactionContext = transactionContext; - transactionManager = TransactionType.LOCAL == this.transactionType ? null : rule.getResource().getTransactionManager(rule.getDefaultType()); + transactionManager = TransactionType.LOCAL == transactionType ? null : rule.getResource().getTransactionManager(rule.getDefaultType()); } /** diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java index 4986f7dd3dbad..ae60d42255c15 100644 --- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java +++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java @@ -61,8 +61,8 @@ private static HikariDataSource createHikariDataSource(final DatabaseType databa result.setPassword("root"); result.setMaximumPoolSize(10); result.setMinimumIdle(2); - result.setConnectionTimeout(15 * 1000L); - result.setIdleTimeout(40 * 1000L); + result.setConnectionTimeout(15L * 1000L); + result.setIdleTimeout(40L * 1000L); return result; } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java index ae29706d9a1d3..2431cd90d5695 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/switcher/ResourceSwitchManager.java @@ -117,7 +117,7 @@ public SwitchingResource unregisterStorageUnit(final ResourceMetaData resourceMe } private Map getToBeRemovedStaleDataSource(final ResourceMetaData resourceMetaData, final Collection storageUnitNames) { - Map result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(storageUnitNames.size(), 1F); for (String each : storageUnitNames) { if (!resourceMetaData.getStorageUnits().containsKey(each)) { return Collections.emptyMap(); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java index dc0e794aa5063..c6cdd7a8c5955 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContexts.java @@ -53,7 +53,7 @@ public final class MetaDataContexts implements AutoCloseable { public MetaDataContexts(final MetaDataBasedPersistService persistService, final ShardingSphereMetaData metaData) { this.persistService = persistService; this.metaData = metaData; - this.statistics = initStatistics(metaData); + statistics = initStatistics(metaData); } private ShardingSphereStatistics initStatistics(final ShardingSphereMetaData metaData) { diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java index 80cfe7ebf0eea..2efacde544d0b 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterModeContextManager.java @@ -109,7 +109,7 @@ public void unregisterStorageUnits(final String databaseName, final Collection getToBeDroppedDataSourcePoolProperties(final Map propsMap, final Collection toBeDroppedResourceNames) { - Map result = new LinkedHashMap<>(); + Map result = new LinkedHashMap<>(toBeDroppedResourceNames.size(), 1F); for (String each : toBeDroppedResourceNames) { if (propsMap.containsKey(each)) { result.put(each, propsMap.get(each)); diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java index 199ad54bb7c0e..96488f881f1d6 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java @@ -172,8 +172,8 @@ public ComputeNodeInstance loadComputeNodeInstance(final InstanceMetaData instan * @return assigned worker ids */ public Collection getAssignedWorkerIds() { - Collection result = new LinkedHashSet<>(); Collection childrenKeys = repository.getChildrenKeys(ComputeNode.getInstanceWorkerIdRootNodePath()); + Collection result = new LinkedHashSet<>(childrenKeys.size(), 1F); for (String each : childrenKeys) { String workerId = repository.getDirectly(ComputeNode.getInstanceWorkerIdNodePath(each)); if (null != workerId) { diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriberTest.java index 6ca87662d910c..4ec220a035966 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/ResourceMetaDataChangedSubscriberTest.java @@ -127,7 +127,7 @@ void assertRenewForDatabaseDeleted() { @Test void assertRenewForSchemaAdded() { subscriber.renew(new SchemaAddedEvent("db", "foo_schema")); - verify(contextManager.getMetaDataContexts().getMetaData().getDatabase("db")).addSchema(argThat(argument -> argument.equals("foo_schema")), any(ShardingSphereSchema.class)); + verify(contextManager.getMetaDataContexts().getMetaData().getDatabase("db")).addSchema(argThat("foo_schema"::equals), any(ShardingSphereSchema.class)); } @Test diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java index 6526dd265efbf..71ee8ac064161 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/subscriber/StateChangedSubscriberTest.java @@ -117,7 +117,7 @@ void assertRenewForDisableStateChanged() { subscriber.renew(event); verify(ruleAttribute).updateStatus( argThat(qualifiedDataSource -> Objects.equals(event.getQualifiedDataSource(), qualifiedDataSource)), - argThat(dataSourceState -> Objects.equals(event.getStatus().getStatus(), dataSourceState))); + argThat(dataSourceState -> event.getStatus().getStatus() == dataSourceState)); } @Test diff --git a/mode/type/cluster/repository/api/src/main/java/org/apache/shardingsphere/mode/repository/cluster/lock/holder/DistributedLockHolder.java b/mode/type/cluster/repository/api/src/main/java/org/apache/shardingsphere/mode/repository/cluster/lock/holder/DistributedLockHolder.java index 00c169180f6c0..4c1f99faada8f 100644 --- a/mode/type/cluster/repository/api/src/main/java/org/apache/shardingsphere/mode/repository/cluster/lock/holder/DistributedLockHolder.java +++ b/mode/type/cluster/repository/api/src/main/java/org/apache/shardingsphere/mode/repository/cluster/lock/holder/DistributedLockHolder.java @@ -36,14 +36,13 @@ public final class DistributedLockHolder { private final TypedProperties props; - private final Map locks; + private final Map locks = new ConcurrentHashMap<>(); @SuppressWarnings("unchecked") public DistributedLockHolder(final String type, final Object client, final TypedProperties props) { creator = TypedSPILoader.getService(DistributedLockCreator.class, type); this.client = client; this.props = props; - locks = new ConcurrentHashMap<>(); } /** diff --git a/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java b/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java index a4288ae55cf4e..a03783f2be8cf 100644 --- a/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java +++ b/mode/type/cluster/repository/provider/zookeeper/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java @@ -39,7 +39,7 @@ @Slf4j public final class SessionConnectionListener implements ConnectionStateListener { - private static final int RECONNECT_INTERVAL_SECONDS = 5; + private static final long RECONNECT_INTERVAL_SECONDS = 5L; private final InstanceContext instanceContext; diff --git a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java index 41042cf9ee38a..4e9d42fc67343 100644 --- a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java +++ b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java @@ -177,7 +177,7 @@ private void removeViewsToDataNode(final ShardingSphereDatabase database, final @Override public void dropSchema(final String databaseName, final Collection schemaNames) { Collection tobeRemovedTables = new LinkedHashSet<>(); - Collection tobeRemovedSchemas = new LinkedHashSet<>(); + Collection tobeRemovedSchemas = new LinkedHashSet<>(schemaNames.size(), 1F); ShardingSphereMetaData metaData = contextManager.getMetaDataContexts().getMetaData(); ShardingSphereDatabase database = metaData.getDatabase(databaseName); for (String each : schemaNames) {