From 1c54ed871265f85c71251b92ecde1895d507baec Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Tue, 7 Nov 2023 19:03:24 +0800 Subject: [PATCH] Rename DataPipelineNodePath (#28977) --- ...odeConstants.java => DataPipelineNodePath.java} | 4 ++-- .../common/metadata/node/PipelineMetaDataNode.java | 8 ++++---- .../metadata/node/PipelineMetaDataNodeWatcher.java | 2 +- .../service/GovernanceRepositoryAPIImplTest.java | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) rename kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/{DataPipelineDataNodeConstants.java => DataPipelineNodePath.java} (92%) diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineDataNodeConstants.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineNodePath.java similarity index 92% rename from kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineDataNodeConstants.java rename to kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineNodePath.java index 963f879603210..eb900e08f9dd8 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineDataNodeConstants.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/DataPipelineNodePath.java @@ -21,10 +21,10 @@ import lombok.NoArgsConstructor; /** - * Data pipeline data node constants. + * Data pipeline node path. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class DataPipelineDataNodeConstants { +public final class DataPipelineNodePath { /** * Data pipeline root path. diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNode.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNode.java index b42f7c896024b..2bea6b52dc573 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNode.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNode.java @@ -29,7 +29,7 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class PipelineMetaDataNode { - private static final String JOB_PATTERN_PREFIX = DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT + "/jobs/(j\\d{2}\\d{2}[0-9a-z]+)"; + private static final String JOB_PATTERN_PREFIX = DataPipelineNodePath.DATA_PIPELINE_ROOT + "/jobs/(j\\d{2}\\d{2}[0-9a-z]+)"; public static final Pattern CONFIG_PATTERN = Pattern.compile(JOB_PATTERN_PREFIX + "/config"); @@ -47,8 +47,8 @@ public static String getMetaDataDataSourcesPath(final JobType jobType) { private static String getMetaDataRootPath(final JobType jobType) { return null == jobType - ? String.join("/", DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT, "metadata") - : String.join("/", DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT, jobType.getType().toLowerCase(), "metadata"); + ? String.join("/", DataPipelineNodePath.DATA_PIPELINE_ROOT, "metadata") + : String.join("/", DataPipelineNodePath.DATA_PIPELINE_ROOT, jobType.getType().toLowerCase(), "metadata"); } /** @@ -72,7 +72,7 @@ public static String getElasticJobNamespace() { } private static String getJobsPath() { - return String.join("/", DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT, "jobs"); + return String.join("/", DataPipelineNodePath.DATA_PIPELINE_ROOT, "jobs"); } /** diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNodeWatcher.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNodeWatcher.java index d2d54b075c192..cb29fad0f59fa 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNodeWatcher.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/metadata/node/PipelineMetaDataNodeWatcher.java @@ -50,7 +50,7 @@ public final class PipelineMetaDataNodeWatcher { private PipelineMetaDataNodeWatcher(final PipelineContextKey contextKey) { listenerMap.putAll(ShardingSphereServiceLoader.getServiceInstances(PipelineMetaDataChangedEventHandler.class) .stream().collect(Collectors.toMap(PipelineMetaDataChangedEventHandler::getKeyPattern, each -> each))); - PipelineAPIFactory.getGovernanceRepositoryAPI(contextKey).watch(DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT, this::dispatchEvent); + PipelineAPIFactory.getGovernanceRepositoryAPI(contextKey).watch(DataPipelineNodePath.DATA_PIPELINE_ROOT, this::dispatchEvent); } private void dispatchEvent(final DataChangedEvent event) { diff --git a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java index af037ba01439b..5472c52644cac 100644 --- a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java +++ b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java @@ -19,7 +19,7 @@ import org.apache.shardingsphere.data.pipeline.core.ingest.dumper.context.InventoryDumperContext; import org.apache.shardingsphere.data.pipeline.core.ingest.dumper.Dumper; -import org.apache.shardingsphere.data.pipeline.common.metadata.node.DataPipelineDataNodeConstants; +import org.apache.shardingsphere.data.pipeline.common.metadata.node.DataPipelineNodePath; import org.apache.shardingsphere.data.pipeline.common.ingest.position.PlaceholderPosition; import org.apache.shardingsphere.data.pipeline.common.registrycenter.repository.GovernanceRepositoryAPI; import org.apache.shardingsphere.data.pipeline.core.consistencycheck.result.TableDataConsistencyCheckResult; @@ -70,8 +70,8 @@ static void beforeClass() { } private static void watch() { - governanceRepositoryAPI.watch(DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT, event -> { - if ((DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT + "/1").equals(event.getKey())) { + governanceRepositoryAPI.watch(DataPipelineNodePath.DATA_PIPELINE_ROOT, event -> { + if ((DataPipelineNodePath.DATA_PIPELINE_ROOT + "/1").equals(event.getKey())) { EVENT_ATOMIC_REFERENCE.set(event); COUNT_DOWN_LATCH.countDown(); } @@ -114,7 +114,7 @@ void assertPersistJobCheckResult() { @Test void assertDeleteJob() { - governanceRepositoryAPI.persist(DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT + "/1", ""); + governanceRepositoryAPI.persist(DataPipelineNodePath.DATA_PIPELINE_ROOT + "/1", ""); governanceRepositoryAPI.deleteJob("1"); Optional actual = governanceRepositoryAPI.getJobItemProgress("1", 0); assertFalse(actual.isPresent()); @@ -122,15 +122,15 @@ void assertDeleteJob() { @Test void assertGetChildrenKeys() { - governanceRepositoryAPI.persist(DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT + "/1", ""); - List actual = governanceRepositoryAPI.getChildrenKeys(DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT); + governanceRepositoryAPI.persist(DataPipelineNodePath.DATA_PIPELINE_ROOT + "/1", ""); + List actual = governanceRepositoryAPI.getChildrenKeys(DataPipelineNodePath.DATA_PIPELINE_ROOT); assertFalse(actual.isEmpty()); assertTrue(actual.contains("1")); } @Test void assertWatch() throws InterruptedException { - String key = DataPipelineDataNodeConstants.DATA_PIPELINE_ROOT + "/1"; + String key = DataPipelineNodePath.DATA_PIPELINE_ROOT + "/1"; governanceRepositoryAPI.persist(key, ""); boolean awaitResult = COUNT_DOWN_LATCH.await(10, TimeUnit.SECONDS); assertTrue(awaitResult);