You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/07/01 16:27:39 UTC
[shardingsphere] branch master updated: Rename InstanceDefinition to InstanceMetaData (#18779)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3a823927371 Rename InstanceDefinition to InstanceMetaData (#18779)
3a823927371 is described below
commit 3a823927371da353cae0c52acf2e52f700f14bd8
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Jul 2 00:27:31 2022 +0800
Rename InstanceDefinition to InstanceMetaData (#18779)
* Add SQL Translator java API doc
* Add SQL Translator yaml doc
* Add SQL Translator spring boot doc
* Remove SQL Translator spring boot doc
* Add SQL Translator in proxy doc
* Add SQL Translator built-algorithm doc
* Update doc page number
* Rename InstanceDefinition to InstanceMetaData
---
.../java-api/rules/transaction.cn.md | 16 ++++++++++
.../java-api/rules/transaction.en.md | 16 ++++++++++
.../collector/ProxyInfoCollectorTest.java | 4 +--
.../service/PrometheusPluginBootServiceTest.java | 4 +--
.../dbdiscovery/rule/DatabaseDiscoveryRule.java | 2 +-
.../keygen/SnowflakeKeyGenerateAlgorithmTest.java | 6 ++--
.../CosIdSnowflakeKeyGenerateAlgorithmTest.java | 10 +++---
.../infra/instance/ComputeNodeInstance.java | 6 ++--
.../infra/instance/InstanceContext.java | 22 ++++++-------
...stanceDefinition.java => InstanceMetaData.java} | 4 +--
...onBuilder.java => InstanceMetaDataBuilder.java} | 10 +++---
...ry.java => InstanceMetaDataBuilderFactory.java} | 14 ++++-----
...ceDefinition.java => JDBCInstanceMetaData.java} | 8 ++---
...ilder.java => JDBCInstanceMetaDataBuilder.java} | 10 +++---
...eDefinition.java => ProxyInstanceMetaData.java} | 10 +++---
...lder.java => ProxyInstanceMetaDataBuilder.java} | 10 +++---
...ra.instance.definition.InstanceMetaDataBuilder} | 4 +--
.../infra/instance/InstanceContextTest.java | 32 +++++++++----------
...t.java => JDBCInstanceMetaDataBuilderTest.java} | 8 ++---
....java => ProxyInstanceMetaDataBuilderTest.java} | 6 ++--
.../jdbc/core/connection/ConnectionManager.java | 20 ++++++------
.../core/datasource/ShardingSphereDataSource.java | 8 ++---
.../core/connection/ConnectionManagerTest.java | 4 +--
.../traffic/spi/TrafficLoadBalanceAlgorithm.java | 4 +--
.../TrafficLoadBalanceAlgorithmFixture.java | 4 +--
.../RandomTrafficLoadBalanceAlgorithm.java | 4 +--
.../RoundRobinTrafficLoadBalanceAlgorithm.java | 4 +--
.../traffic/engine/TrafficEngine.java | 8 ++---
.../algorithm/engine/TrafficEngineTest.java | 16 +++++-----
.../RandomTrafficLoadBalanceAlgorithmTest.java | 6 ++--
.../RoundRobinTrafficLoadBalanceAlgorithmTest.java | 10 +++---
.../manager/ContextManagerBuilderParameter.java | 4 +--
.../cluster/ClusterContextManagerBuilder.java | 16 +++++-----
.../ClusterContextManagerCoordinator.java | 8 ++---
.../cluster/coordinator/RegistryCenter.java | 2 +-
.../manager/internal/ExclusiveInternalLock.java | 2 +-
.../status/compute/event/InstanceOfflineEvent.java | 4 +--
.../status/compute/event/InstanceOnlineEvent.java | 4 +--
.../compute/service/ComputeNodeStatusService.java | 32 +++++++++----------
.../watcher/ComputeNodeStateChangedWatcher.java | 16 +++++-----
.../generator/ClusterWorkerIdGenerator.java | 10 +++---
.../ClusterContextManagerCoordinatorTest.java | 34 ++++++++++----------
.../lock/DistributedLockContextTest.java | 10 +++---
.../service/ComputeNodeStatusServiceTest.java | 36 +++++++++++-----------
.../listener/SessionConnectionListener.java | 2 +-
.../memory/MemoryContextManagerBuilder.java | 2 +-
.../StandaloneContextManagerBuilder.java | 6 ++--
.../StandaloneContextManagerBuilderTextTest.java | 8 ++---
.../ral/common/queryable/ShowInstanceHandler.java | 12 ++++----
.../common/queryable/ShowInstanceModeHandler.java | 2 +-
.../DistSQLTrafficLoadBalanceAlgorithmFixture.java | 4 +--
.../queryable/ShowInstanceModeHandlerTest.java | 2 +-
.../proxy/initializer/BootstrapInitializer.java | 8 ++---
53 files changed, 273 insertions(+), 241 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.cn.md
new file mode 100644
index 00000000000..b26ea40c2d4
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.cn.md
@@ -0,0 +1,16 @@
++++
+title = "分布式事务"
+weight = 3
++++
+
+## 配置入口
+
+org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration
+
+可配置属性:
+
+| *名称* | *数据类型* | *说明* |
+| ---------------- | ---------- | ------------ |
+| defaultType | String | 默认事务类型 |
+| providerType (?) | String | 事务提供者类型 |
+| props (?) | Properties | 事务属性配置 |
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.en.md
new file mode 100644
index 00000000000..6418ac7d288
--- /dev/null
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/java-api/rules/transaction.en.md
@@ -0,0 +1,16 @@
++++
+title = "Distributed Transaction"
+weight = 3
++++
+
+## Root Configuration
+
+org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration
+
+Attributes:
+
+| *name* | *DataType* | *Description* |
+| ---------------- | ---------- | ------------------------- |
+| defaultType | String | Default transaction type |
+| providerType (?) | String | Transaction provider type |
+| props (?) | Properties | Transaction properties |
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
index ac95c78ed2b..263da1f6602 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -41,7 +41,7 @@ public final class ProxyInfoCollectorTest extends ProxyContextRestorer {
public void assertCollect() {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), new ShardingSphereMetaData(), mock(OptimizerContext.class));
InstanceContext instanceContext = new InstanceContext(
- new ComputeNodeInstance(mock(InstanceDefinition.class)), new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class));
+ new ComputeNodeInstance(mock(InstanceMetaData.class)), new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class));
ProxyContext.init(new ContextManager(metaDataContexts, instanceContext));
assertFalse(new ProxyInfoCollector().collect().isEmpty());
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
index 761b230e04e..de8e6e05cfd 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -54,7 +54,7 @@ public final class PrometheusPluginBootServiceTest extends ProxyContextRestorer
public void assertStart() throws IOException {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), new ShardingSphereMetaData(), mock(OptimizerContext.class));
InstanceContext instanceContext = new InstanceContext(
- new ComputeNodeInstance(mock(InstanceDefinition.class)), new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class));
+ new ComputeNodeInstance(mock(InstanceMetaData.class)), new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class));
ProxyContext.init(new ContextManager(metaDataContexts, instanceContext));
PROMETHEUS_PLUGIN_BOOT_SERVICE.start(new PluginConfiguration("localhost", 8090, "", createProperties()));
new Socket().connect(new InetSocketAddress("localhost", 8090));
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
index 2f77205125f..651fb6da2e9 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRule.java
@@ -187,7 +187,7 @@ public final class DatabaseDiscoveryRule implements DatabaseRule, DataSourceCont
}
private void initHeartBeatJobs(final InstanceContext instanceContext) {
- Optional<ModeScheduleContext> modeScheduleContext = ModeScheduleContextFactory.getInstance().get(instanceContext.getInstance().getInstanceDefinition().getInstanceId());
+ Optional<ModeScheduleContext> modeScheduleContext = ModeScheduleContextFactory.getInstance().get(instanceContext.getInstance().getInstanceMetaData().getInstanceId());
if (modeScheduleContext.isPresent()) {
for (Entry<String, DatabaseDiscoveryDataSourceRule> entry : dataSourceRules.entrySet()) {
DatabaseDiscoveryDataSourceRule rule = entry.getValue();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
index 10fac7d8aa0..71cd010c729 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmC
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.sharding.algorithm.keygen.fixture.FixedTimeService;
import org.apache.shardingsphere.sharding.algorithm.keygen.fixture.WorkerIdGeneratorFixture;
@@ -174,7 +174,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
@Test(expected = IllegalArgumentException.class)
public void assertSetWorkerIdFailureWhenNegative() {
SnowflakeKeyGenerateAlgorithm algorithm = (SnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", new Properties()));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(-1L),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(-1L),
new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
algorithm.init(new Properties());
algorithm.generateKey();
@@ -190,7 +190,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
@Test(expected = IllegalArgumentException.class)
public void assertSetWorkerIdFailureWhenOutOfRange() {
SnowflakeKeyGenerateAlgorithm algorithm = (SnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("SNOWFLAKE", new Properties()));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE),
new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
algorithm.generateKey();
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java
index 576cab73a8b..6c05177f44d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmC
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.sharding.cosid.algorithm.keygen.fixture.WorkerIdGeneratorFixture;
import org.apache.shardingsphere.sharding.factory.KeyGenerateAlgorithmFactory;
@@ -53,7 +53,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithmTest {
public void assertGenerateKey() {
CosIdSnowflakeKeyGenerateAlgorithm algorithm = (CosIdSnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(
new ShardingSphereAlgorithmConfiguration("COSID_SNOWFLAKE", new Properties()));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(FIXTURE_WORKER_ID),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(FIXTURE_WORKER_ID),
new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
long firstActualKey = (Long) algorithm.generateKey();
long secondActualKey = (Long) algorithm.generateKey();
@@ -72,7 +72,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithmTest {
props.setProperty(CosIdSnowflakeKeyGenerateAlgorithm.AS_STRING_KEY, Boolean.TRUE.toString());
CosIdSnowflakeKeyGenerateAlgorithm algorithm = (CosIdSnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(
new ShardingSphereAlgorithmConfiguration("COSID_SNOWFLAKE", props));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)),
new WorkerIdGeneratorFixture(FIXTURE_WORKER_ID), new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
Comparable<?> actualKey = algorithm.generateKey();
assertThat(actualKey, instanceOf(String.class));
@@ -93,7 +93,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithmTest {
public void assertGenerateKeyWhenNegative() {
CosIdSnowflakeKeyGenerateAlgorithm algorithm = (CosIdSnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(
new ShardingSphereAlgorithmConfiguration("COSID_SNOWFLAKE", new Properties()));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(-1),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(-1),
new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
algorithm.generateKey();
}
@@ -102,7 +102,7 @@ public final class CosIdSnowflakeKeyGenerateAlgorithmTest {
public void assertGenerateKeyWhenGreaterThen1023() {
CosIdSnowflakeKeyGenerateAlgorithm algorithm = (CosIdSnowflakeKeyGenerateAlgorithm) KeyGenerateAlgorithmFactory.newInstance(
new ShardingSphereAlgorithmConfiguration("COSID_SNOWFLAKE", new Properties()));
- algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(1024),
+ algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(1024),
new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
algorithm.generateKey();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
index 85cb12122b4..3603617f0a9 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstance.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.infra.instance;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.state.StateContext;
import org.apache.shardingsphere.infra.state.StateType;
@@ -34,7 +34,7 @@ import java.util.Collection;
@Setter
public final class ComputeNodeInstance {
- private final InstanceDefinition instanceDefinition;
+ private final InstanceMetaData instanceMetaData;
private final StateContext state = new StateContext();
@@ -69,6 +69,6 @@ public final class ComputeNodeInstance {
* @return current instance id
*/
public String getCurrentInstanceId() {
- return instanceDefinition.getInstanceId();
+ return instanceMetaData.getInstanceId();
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceContext.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceContext.java
index b66be41676a..7cd2b5eb5c4 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/InstanceContext.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.instance;
import lombok.Getter;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
import org.apache.shardingsphere.infra.lock.LockContext;
@@ -63,7 +63,7 @@ public final class InstanceContext {
* @param status status
*/
public void updateInstanceStatus(final String instanceId, final Collection<String> status) {
- if (instance.getInstanceDefinition().getInstanceId().equals(instanceId)) {
+ if (instance.getInstanceMetaData().getInstanceId().equals(instanceId)) {
instance.switchState(status);
}
updateRelatedComputeNodeInstancesStatus(instanceId, status);
@@ -71,7 +71,7 @@ public final class InstanceContext {
private void updateRelatedComputeNodeInstancesStatus(final String instanceId, final Collection<String> status) {
for (ComputeNodeInstance each : computeNodeInstances) {
- if (each.getInstanceDefinition().getInstanceId().equals(instanceId)) {
+ if (each.getInstanceMetaData().getInstanceId().equals(instanceId)) {
each.switchState(status);
}
}
@@ -95,10 +95,10 @@ public final class InstanceContext {
* @param labels collection of label
*/
public void updateLabel(final String instanceId, final Collection<String> labels) {
- if (instance.getInstanceDefinition().getInstanceId().equals(instanceId)) {
+ if (instance.getInstanceMetaData().getInstanceId().equals(instanceId)) {
instance.setLabels(labels);
}
- computeNodeInstances.stream().filter(each -> each.getInstanceDefinition().getInstanceId().equals(instanceId)).forEach(each -> each.setLabels(labels));
+ computeNodeInstances.stream().filter(each -> each.getInstanceMetaData().getInstanceId().equals(instanceId)).forEach(each -> each.setLabels(labels));
}
/**
@@ -120,7 +120,7 @@ public final class InstanceContext {
* @param instance compute node instance
*/
public void addComputeNodeInstance(final ComputeNodeInstance instance) {
- computeNodeInstances.removeIf(each -> each.getInstanceDefinition().getInstanceId().equalsIgnoreCase(instance.getInstanceDefinition().getInstanceId()));
+ computeNodeInstances.removeIf(each -> each.getInstanceMetaData().getInstanceId().equalsIgnoreCase(instance.getInstanceMetaData().getInstanceId()));
computeNodeInstances.add(instance);
}
@@ -130,7 +130,7 @@ public final class InstanceContext {
* @param instance compute node instance
*/
public void deleteComputeNodeInstance(final ComputeNodeInstance instance) {
- computeNodeInstances.removeIf(each -> each.getInstanceDefinition().getInstanceId().equalsIgnoreCase(instance.getInstanceDefinition().getInstanceId()));
+ computeNodeInstances.removeIf(each -> each.getInstanceMetaData().getInstanceId().equalsIgnoreCase(instance.getInstanceMetaData().getInstanceId()));
}
/**
@@ -140,11 +140,11 @@ public final class InstanceContext {
* @param labels collection of contained label
* @return compute node instances
*/
- public List<InstanceDefinition> getComputeNodeInstances(final InstanceType instanceType, final Collection<String> labels) {
- List<InstanceDefinition> result = new ArrayList<>(computeNodeInstances.size());
+ public List<InstanceMetaData> getComputeNodeInstances(final InstanceType instanceType, final Collection<String> labels) {
+ List<InstanceMetaData> result = new ArrayList<>(computeNodeInstances.size());
for (ComputeNodeInstance each : computeNodeInstances) {
- if (each.getInstanceDefinition().getInstanceType() == instanceType && labels.stream().anyMatch(((Collection<String>) each.getLabels())::contains)) {
- result.add(each.getInstanceDefinition());
+ if (each.getInstanceMetaData().getInstanceType() == instanceType && labels.stream().anyMatch(((Collection<String>) each.getLabels())::contains)) {
+ result.add(each.getInstanceMetaData());
}
}
return result;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinition.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaData.java
similarity index 95%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinition.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaData.java
index 142d919a6a2..a055f36273d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinition.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaData.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.infra.instance.definition;
/**
- * Instance definition.
+ * Instance meta data.
*/
-public interface InstanceDefinition {
+public interface InstanceMetaData {
/**
* Get instance ID.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilder.java
similarity index 83%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilder.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilder.java
index 139c0be1439..7d7a8da3071 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilder.java
@@ -21,16 +21,16 @@ import org.apache.shardingsphere.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
- * Instance definition builder.
+ * Instance meta data builder.
*/
@SingletonSPI
-public interface InstanceDefinitionBuilder extends TypedSPI {
+public interface InstanceMetaDataBuilder extends TypedSPI {
/**
- * Build instance definition.
+ * Build instance meta data.
*
* @param port port
- * @return built instance definition
+ * @return built instance meta data
*/
- InstanceDefinition build(int port);
+ InstanceMetaData build(int port);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilderFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilderFactory.java
similarity index 72%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilderFactory.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilderFactory.java
index b6c0aaf0d5b..f7c46e6b37a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceDefinitionBuilderFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/InstanceMetaDataBuilderFactory.java
@@ -23,23 +23,23 @@ import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
/**
- * Instance definition builder factory.
+ * Instance meta data builder factory.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class InstanceDefinitionBuilderFactory {
+public final class InstanceMetaDataBuilderFactory {
static {
- ShardingSphereServiceLoader.register(InstanceDefinitionBuilder.class);
+ ShardingSphereServiceLoader.register(InstanceMetaDataBuilder.class);
}
/**
- * Create instance of instance definition.
+ * Create instance of instance meta data.
*
* @param type type
* @param port port
- * @return created instance of instance definition
+ * @return created instance of instance meta data
*/
- public static InstanceDefinition newInstance(final String type, final int port) {
- return TypedSPIRegistry.getRegisteredService(InstanceDefinitionBuilder.class, type).build(port);
+ public static InstanceMetaData newInstance(final String type, final int port) {
+ return TypedSPIRegistry.getRegisteredService(InstanceMetaDataBuilder.class, type).build(port);
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinition.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaData.java
similarity index 89%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinition.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaData.java
index 4c8cd5999d8..e16c9427f51 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinition.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaData.java
@@ -18,21 +18,21 @@
package org.apache.shardingsphere.infra.instance.definition.jdbc;
import lombok.Getter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.apache.shardingsphere.infra.instance.utils.IpUtils;
/**
- * JDBC instance definition.
+ * JDBC instance meta data.
*/
@Getter
-public final class JDBCInstanceDefinition implements InstanceDefinition {
+public final class JDBCInstanceMetaData implements InstanceMetaData {
private final String instanceId;
private final String ip;
- public JDBCInstanceDefinition(final String instanceId) {
+ public JDBCInstanceMetaData(final String instanceId) {
this.instanceId = instanceId;
ip = IpUtils.getIp();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilder.java
similarity index 82%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilder.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilder.java
index e8c55f909d0..91322eccb2b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilder.java
@@ -17,19 +17,19 @@
package org.apache.shardingsphere.infra.instance.definition.jdbc;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilder;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilder;
import java.util.UUID;
/**
* JDBC instance definition builder.
*/
-public final class JDBCInstanceDefinitionBuilder implements InstanceDefinitionBuilder {
+public final class JDBCInstanceMetaDataBuilder implements InstanceMetaDataBuilder {
@Override
- public InstanceDefinition build(final int port) {
- return new JDBCInstanceDefinition(UUID.randomUUID().toString());
+ public InstanceMetaData build(final int port) {
+ return new JDBCInstanceMetaData(UUID.randomUUID().toString());
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinition.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaData.java
similarity index 86%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinition.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaData.java
index 3aa2fbfe0db..02bd96afc02 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinition.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaData.java
@@ -19,15 +19,15 @@ package org.apache.shardingsphere.infra.instance.definition.proxy;
import com.google.common.base.Joiner;
import lombok.Getter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.apache.shardingsphere.infra.instance.utils.IpUtils;
/**
- * Proxy instance definition.
+ * Proxy instance meta data.
*/
@Getter
-public final class ProxyInstanceDefinition implements InstanceDefinition {
+public final class ProxyInstanceMetaData implements InstanceMetaData {
private static final String DELIMITER = "@";
@@ -37,13 +37,13 @@ public final class ProxyInstanceDefinition implements InstanceDefinition {
private final int port;
- public ProxyInstanceDefinition(final String instanceId, final int port) {
+ public ProxyInstanceMetaData(final String instanceId, final int port) {
this.instanceId = instanceId;
ip = IpUtils.getIp();
this.port = port;
}
- public ProxyInstanceDefinition(final String instanceId, final String attributes) {
+ public ProxyInstanceMetaData(final String instanceId, final String attributes) {
this.instanceId = instanceId;
String[] attributesList = attributes.split(DELIMITER);
ip = attributesList[0];
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilder.java
similarity index 81%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilder.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilder.java
index b7ea55dc5ef..6dafa8d8ca9 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilder.java
@@ -17,19 +17,19 @@
package org.apache.shardingsphere.infra.instance.definition.proxy;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilder;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilder;
import java.util.UUID;
/**
* Proxy instance definition builder.
*/
-public final class ProxyInstanceDefinitionBuilder implements InstanceDefinitionBuilder {
+public final class ProxyInstanceMetaDataBuilder implements InstanceMetaDataBuilder {
@Override
- public InstanceDefinition build(final int port) {
- return new ProxyInstanceDefinition(UUID.randomUUID().toString(), port);
+ public InstanceMetaData build(final int port) {
+ return new ProxyInstanceMetaData(UUID.randomUUID().toString(), port);
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilder b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilder
similarity index 95%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilder
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilder
index 371b9e8613f..b847cd06dc1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilder
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilder
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceDefinitionBuilder
-org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinitionBuilder
+org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceMetaDataBuilder
+org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaDataBuilder
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
index ac0c87d09b8..ce7b6a5f4f9 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/InstanceContextTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.infra.instance;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.fixture.WorkerIdGeneratorFixture;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.infra.state.StateContext;
@@ -48,22 +48,22 @@ public final class InstanceContextTest {
@Test
public void assertUpdateInstanceStatus() {
- InstanceDefinition instanceDefinition = mock(InstanceDefinition.class);
- when(instanceDefinition.getInstanceId()).thenReturn("foo_instance_id");
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceMetaData instanceMetaData = mock(InstanceMetaData.class);
+ when(instanceMetaData.getInstanceId()).thenReturn("foo_instance_id");
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceMetaData), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
StateType actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.OK));
- context.updateInstanceStatus(instanceDefinition.getInstanceId(), Collections.singleton(StateType.CIRCUIT_BREAK.name()));
+ context.updateInstanceStatus(instanceMetaData.getInstanceId(), Collections.singleton(StateType.CIRCUIT_BREAK.name()));
actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.CIRCUIT_BREAK));
- context.updateInstanceStatus(instanceDefinition.getInstanceId(), Collections.emptyList());
+ context.updateInstanceStatus(instanceMetaData.getInstanceId(), Collections.emptyList());
actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.OK));
}
@Test
public void assertUpdateWorkerId() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
long actual = context.getWorkerId();
assertThat(actual, is(Long.MIN_VALUE));
Random random = new Random();
@@ -75,9 +75,9 @@ public final class InstanceContextTest {
@Test
public void assertUpdateLabel() {
- InstanceDefinition instanceDefinition = mock(InstanceDefinition.class);
- when(instanceDefinition.getInstanceId()).thenReturn("foo_instance_id");
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceDefinition), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceMetaData instanceMetaData = mock(InstanceMetaData.class);
+ when(instanceMetaData.getInstanceId()).thenReturn("foo_instance_id");
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(instanceMetaData), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
Set<String> expected = new LinkedHashSet<>(Arrays.asList("label_1", "label_2"));
context.updateLabel("foo_instance_id", expected);
Collection<String> actual = context.getInstance().getLabels();
@@ -86,7 +86,7 @@ public final class InstanceContextTest {
@Test
public void assertGetInstance() {
- ComputeNodeInstance expected = new ComputeNodeInstance(mock(InstanceDefinition.class));
+ ComputeNodeInstance expected = new ComputeNodeInstance(mock(InstanceMetaData.class));
InstanceContext context = new InstanceContext(expected, new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
ComputeNodeInstance actual = context.getInstance();
assertThat(actual, is(expected));
@@ -94,7 +94,7 @@ public final class InstanceContextTest {
@Test
public void assertGetState() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
StateContext actual = context.getInstance().getState();
assertNotNull(actual);
}
@@ -102,23 +102,23 @@ public final class InstanceContextTest {
@Test
public void assertGetWorkerIdGenerator() {
WorkerIdGeneratorFixture expected = new WorkerIdGeneratorFixture(Long.MIN_VALUE);
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), expected, modeConfig, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), expected, modeConfig, lockContext);
WorkerIdGeneratorFixture actual = (WorkerIdGeneratorFixture) context.getWorkerIdGenerator();
assertThat(actual, is(expected));
}
@Test
public void assertGetModeConfiguration() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
ModeConfiguration actual = context.getModeConfiguration();
assertThat(actual, is(modeConfig));
}
@Test
public void assertIsCluster() {
- InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
+ InstanceContext context = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE), modeConfig, lockContext);
assertFalse(context.isCluster());
- InstanceContext clusterContext = new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE),
+ InstanceContext clusterContext = new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(Long.MIN_VALUE),
new ModeConfiguration("Cluster", null, false), lockContext);
assertTrue(clusterContext.isCluster());
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilderTest.java
similarity index 88%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilderTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilderTest.java
index c96c3637d76..030e196f9ea 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceDefinitionBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/jdbc/JDBCInstanceMetaDataBuilderTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.infra.instance.definition.jdbc;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilderFactory;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilderFactory;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.junit.Test;
@@ -26,11 +26,11 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-public final class JDBCInstanceDefinitionBuilderTest {
+public final class JDBCInstanceMetaDataBuilderTest {
@Test
public void assertNewInstance() {
- InstanceDefinition actual = InstanceDefinitionBuilderFactory.newInstance("JDBC", -1);
+ InstanceMetaData actual = InstanceMetaDataBuilderFactory.newInstance("JDBC", -1);
assertNotNull(actual.getInstanceId());
assertNotNull(actual.getIp());
assertThat(actual.getAttributes(), is(""));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilderTest.java
similarity index 87%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilderTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilderTest.java
index 659fdc72158..fa65be4be9b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceDefinitionBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/definition/proxy/ProxyInstanceMetaDataBuilderTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.infra.instance.definition.proxy;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilderFactory;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilderFactory;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.junit.Test;
@@ -26,11 +26,11 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-public final class ProxyInstanceDefinitionBuilderTest {
+public final class ProxyInstanceMetaDataBuilderTest {
@Test
public void assertNewInstance() {
- ProxyInstanceDefinition actual = (ProxyInstanceDefinition) InstanceDefinitionBuilderFactory.newInstance("Proxy", 3307);
+ ProxyInstanceMetaData actual = (ProxyInstanceMetaData) InstanceMetaDataBuilderFactory.newInstance("Proxy", 3307);
assertNotNull(actual.getInstanceId());
assertNotNull(actual.getIp());
assertThat(actual.getPort(), is(3307));
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
index e9145ce4d19..ea781e8269d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
@@ -29,9 +29,9 @@ import org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCre
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.ExecutorJDBCConnectionManager;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -93,34 +93,34 @@ public final class ConnectionManager implements ExecutorJDBCConnectionManager, A
Preconditions.checkState(!dataSourcePropsMap.isEmpty(), "Can not get data source properties from meta data.");
DataSourceProperties dataSourcePropsSample = dataSourcePropsMap.values().iterator().next();
Collection<ShardingSphereUser> users = metaDataPersistService.get().getGlobalRuleService().loadUsers();
- Collection<InstanceDefinition> instances = contextManager.getInstanceContext().getComputeNodeInstances(InstanceType.PROXY, trafficRule.getLabels());
+ Collection<InstanceMetaData> instances = contextManager.getInstanceContext().getComputeNodeInstances(InstanceType.PROXY, trafficRule.getLabels());
return DataSourcePoolCreator.create(createDataSourcePropertiesMap(instances, users, dataSourcePropsSample, schema));
}
- private Map<String, DataSourceProperties> createDataSourcePropertiesMap(final Collection<InstanceDefinition> instances, final Collection<ShardingSphereUser> users,
+ private Map<String, DataSourceProperties> createDataSourcePropertiesMap(final Collection<InstanceMetaData> instances, final Collection<ShardingSphereUser> users,
final DataSourceProperties dataSourcePropsSample, final String schema) {
Map<String, DataSourceProperties> result = new LinkedHashMap<>();
- for (InstanceDefinition each : instances) {
- result.put(each.getInstanceId(), createDataSourceProperties((ProxyInstanceDefinition) each, users, dataSourcePropsSample, schema));
+ for (InstanceMetaData each : instances) {
+ result.put(each.getInstanceId(), createDataSourceProperties((ProxyInstanceMetaData) each, users, dataSourcePropsSample, schema));
}
return result;
}
- private DataSourceProperties createDataSourceProperties(final ProxyInstanceDefinition instanceDefinition, final Collection<ShardingSphereUser> users,
+ private DataSourceProperties createDataSourceProperties(final ProxyInstanceMetaData instanceMetaData, final Collection<ShardingSphereUser> users,
final DataSourceProperties dataSourcePropsSample, final String schema) {
Map<String, Object> props = dataSourcePropsSample.getAllLocalProperties();
- props.put("jdbcUrl", createJdbcUrl(instanceDefinition, schema, props));
+ props.put("jdbcUrl", createJdbcUrl(instanceMetaData, schema, props));
ShardingSphereUser user = users.iterator().next();
props.put("username", user.getGrantee().getUsername());
props.put("password", user.getPassword());
return new DataSourceProperties("com.zaxxer.hikari.HikariDataSource", props);
}
- private String createJdbcUrl(final ProxyInstanceDefinition instanceDefinition, final String schema, final Map<String, Object> props) {
+ private String createJdbcUrl(final ProxyInstanceMetaData instanceMetaData, final String schema, final Map<String, Object> props) {
String jdbcUrl = String.valueOf(props.get("jdbcUrl"));
String jdbcUrlPrefix = jdbcUrl.substring(0, jdbcUrl.indexOf("//"));
String jdbcUrlSuffix = jdbcUrl.contains("?") ? jdbcUrl.substring(jdbcUrl.indexOf("?")) : "";
- return String.format("%s//%s:%s/%s%s", jdbcUrlPrefix, instanceDefinition.getIp(), instanceDefinition.getPort(), schema, jdbcUrlSuffix);
+ return String.format("%s//%s:%s/%s%s", jdbcUrlPrefix, instanceMetaData.getIp(), instanceMetaData.getPort(), schema, jdbcUrlSuffix);
}
private ConnectionTransaction createConnectionTransaction(final String databaseName, final ContextManager contextManager) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index ca3383715b7..d0935c1e8ab 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -25,8 +25,8 @@ import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFa
import org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.scope.GlobalRuleConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilderFactory;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilderFactory;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilderFactory;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter;
@@ -74,10 +74,10 @@ public final class ShardingSphereDataSource extends AbstractDataSourceAdapter im
private ContextManager createContextManager(final String databaseName, final ModeConfiguration modeConfig, final Map<String, DataSource> dataSourceMap,
final Collection<RuleConfiguration> ruleConfigs, final Properties props) throws SQLException {
- InstanceDefinition instanceDefinition = InstanceDefinitionBuilderFactory.newInstance("JDBC", -1);
+ InstanceMetaData instanceMetaData = InstanceMetaDataBuilderFactory.newInstance("JDBC", -1);
Collection<RuleConfiguration> globalRuleConfigs = ruleConfigs.stream().filter(each -> each instanceof GlobalRuleConfiguration).collect(Collectors.toList());
ContextManagerBuilderParameter parameter = new ContextManagerBuilderParameter(modeConfig, Collections.singletonMap(databaseName,
- new DataSourceProvidedDatabaseConfiguration(dataSourceMap, ruleConfigs)), globalRuleConfigs, props, Collections.emptyList(), instanceDefinition);
+ new DataSourceProvidedDatabaseConfiguration(dataSourceMap, ruleConfigs)), globalRuleConfigs, props, Collections.emptyList(), instanceMetaData);
return ContextManagerBuilderFactory.getInstance(modeConfig).build(parameter);
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
index ab28ec9dec3..a75e63b6f26 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCre
import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -96,7 +96,7 @@ public final class ConnectionManagerTest {
when(globalRuleMetaData.getSingleRule(TransactionRule.class)).thenReturn(mock(TransactionRule.class, RETURNS_DEEP_STUBS));
when(globalRuleMetaData.getSingleRule(TrafficRule.class)).thenReturn(mock(TrafficRule.class, RETURNS_DEEP_STUBS));
when(result.getInstanceContext().getComputeNodeInstances(InstanceType.PROXY, Arrays.asList("OLTP", "OLAP"))).thenReturn(
- Collections.singletonList(new ProxyInstanceDefinition("127.0.0.1@3307", "127.0.0.1@3307")));
+ Collections.singletonList(new ProxyInstanceMetaData("127.0.0.1@3307", "127.0.0.1@3307")));
dataSourcePoolCreator = mockStatic(DataSourcePoolCreator.class);
Map<String, DataSource> trafficDataSourceMap = mockTrafficDataSourceMap();
when(DataSourcePoolCreator.create((Map) any())).thenReturn(trafficDataSourceMap);
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/spi/TrafficLoadBalanceAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/spi/TrafficLoadBalanceAlgorithm.java
index 9f9c7c1611a..d715e837822 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/spi/TrafficLoadBalanceAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/main/java/org/apache/shardingsphere/traffic/spi/TrafficLoadBalanceAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.traffic.spi;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.spi.type.required.RequiredSPI;
import java.util.List;
@@ -35,5 +35,5 @@ public interface TrafficLoadBalanceAlgorithm extends ShardingSphereAlgorithm, Re
* @param instances instance collection
* @return instance definition
*/
- InstanceDefinition getInstanceId(String name, List<InstanceDefinition> instances);
+ InstanceMetaData getInstanceId(String name, List<InstanceMetaData> instances);
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java
index 8ae08ebd967..9c94ee3d504 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.traffic.fixture;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
@@ -35,7 +35,7 @@ public final class TrafficLoadBalanceAlgorithmFixture implements TrafficLoadBala
}
@Override
- public InstanceDefinition getInstanceId(final String name, final List<InstanceDefinition> instances) {
+ public InstanceMetaData getInstanceId(final String name, final List<InstanceMetaData> instances) {
return null;
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
index c5fa526080e..56188a412a1 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
import lombok.Getter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
@@ -39,7 +39,7 @@ public final class RandomTrafficLoadBalanceAlgorithm implements TrafficLoadBalan
}
@Override
- public InstanceDefinition getInstanceId(final String name, final List<InstanceDefinition> instances) {
+ public InstanceMetaData getInstanceId(final String name, final List<InstanceMetaData> instances) {
return instances.get(ThreadLocalRandom.current().nextInt(instances.size()));
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
index 774ecccf98c..f14c93d652c 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
import lombok.Getter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
@@ -41,7 +41,7 @@ public final class RoundRobinTrafficLoadBalanceAlgorithm implements TrafficLoadB
}
@Override
- public InstanceDefinition getInstanceId(final String name, final List<InstanceDefinition> instances) {
+ public InstanceMetaData getInstanceId(final String name, final List<InstanceMetaData> instances) {
return instances.get(Math.abs(count.getAndIncrement()) % instances.size());
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
index ee34fea4281..a3933e58b79 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/main/java/org/apache/shardingsphere/traffic/engine/TrafficEngine.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.traffic.engine;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.binder.LogicSQL;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
import org.apache.shardingsphere.traffic.context.TrafficContext;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
@@ -53,11 +53,11 @@ public final class TrafficEngine {
if (!strategyRule.isPresent() || isInvalidStrategyRule(strategyRule.get())) {
return result;
}
- List<InstanceDefinition> instances = instanceContext.getComputeNodeInstances(InstanceType.PROXY, strategyRule.get().getLabels());
+ List<InstanceMetaData> instances = instanceContext.getComputeNodeInstances(InstanceType.PROXY, strategyRule.get().getLabels());
if (!instances.isEmpty()) {
TrafficLoadBalanceAlgorithm loadBalancer = strategyRule.get().getLoadBalancer();
- InstanceDefinition instanceDefinition = 1 == instances.size() ? instances.iterator().next() : loadBalancer.getInstanceId(strategyRule.get().getName(), instances);
- result.setInstanceId(instanceDefinition.getInstanceId());
+ InstanceMetaData instanceMetaData = 1 == instances.size() ? instances.iterator().next() : loadBalancer.getInstanceId(strategyRule.get().getName(), instances);
+ result.setInstanceId(instanceMetaData.getInstanceId());
}
return result;
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
index bffcea712ef..22473c5ba00 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/engine/TrafficEngineTest.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.traffic.algorithm.engine;
import org.apache.shardingsphere.infra.binder.LogicSQL;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.traffic.context.TrafficContext;
import org.apache.shardingsphere.traffic.engine.TrafficEngine;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
@@ -92,8 +92,8 @@ public final class TrafficEngineTest {
when(trafficRule.findMatchedStrategyRule(logicSQL, false)).thenReturn(Optional.of(strategyRule));
when(strategyRule.getLabels()).thenReturn(Arrays.asList("OLTP", "OLAP"));
TrafficLoadBalanceAlgorithm loadBalancer = mock(TrafficLoadBalanceAlgorithm.class);
- List<InstanceDefinition> instanceIds = mockComputeNodeInstances();
- when(loadBalancer.getInstanceId("traffic", instanceIds)).thenReturn(new ProxyInstanceDefinition("127.0.0.1@3307", 3307));
+ List<InstanceMetaData> instanceIds = mockComputeNodeInstances();
+ when(loadBalancer.getInstanceId("traffic", instanceIds)).thenReturn(new ProxyInstanceMetaData("127.0.0.1@3307", 3307));
when(strategyRule.getLoadBalancer()).thenReturn(loadBalancer);
when(strategyRule.getName()).thenReturn("traffic");
when(instanceContext.getComputeNodeInstances(InstanceType.PROXY, Arrays.asList("OLTP", "OLAP"))).thenReturn(instanceIds);
@@ -101,10 +101,10 @@ public final class TrafficEngineTest {
assertThat(actual.getInstanceId(), is("127.0.0.1@3307"));
}
- private List<InstanceDefinition> mockComputeNodeInstances() {
- List<InstanceDefinition> result = new ArrayList<>();
- result.add(new ProxyInstanceDefinition("127.0.0.1@3307", "127.0.0.1@3307"));
- result.add(new ProxyInstanceDefinition("127.0.0.1@3308", "127.0.0.1@3308"));
+ private List<InstanceMetaData> mockComputeNodeInstances() {
+ List<InstanceMetaData> result = new ArrayList<>();
+ result.add(new ProxyInstanceMetaData("127.0.0.1@3307", "127.0.0.1@3307"));
+ result.add(new ProxyInstanceMetaData("127.0.0.1@3308", "127.0.0.1@3308"));
return result;
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
index 66bd664ab6a..63f02307fbb 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.junit.Test;
import java.util.Arrays;
@@ -30,7 +30,7 @@ public final class RandomTrafficLoadBalanceAlgorithmTest {
@Test
public void assertGetInstanceId() {
- List<InstanceDefinition> instances = Arrays.asList(new ProxyInstanceDefinition("127.0.0.1@3307", "127.0.0.1@3307"), new ProxyInstanceDefinition("127.0.0.1@3308", "127.0.0.1@3308"));
+ List<InstanceMetaData> instances = Arrays.asList(new ProxyInstanceMetaData("127.0.0.1@3307", "127.0.0.1@3307"), new ProxyInstanceMetaData("127.0.0.1@3308", "127.0.0.1@3308"));
RandomTrafficLoadBalanceAlgorithm randomAlgorithm = new RandomTrafficLoadBalanceAlgorithm();
assertTrue(instances.contains(randomAlgorithm.getInstanceId("simple_traffic", instances)));
assertTrue(instances.contains(randomAlgorithm.getInstanceId("simple_traffic", instances)));
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
index d7717614b65..83ad6a1c40d 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.traffic.algorithm.loadbalance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.junit.Test;
import java.util.Arrays;
@@ -31,9 +31,9 @@ public final class RoundRobinTrafficLoadBalanceAlgorithmTest {
@Test
public void assertGetInstanceId() {
- InstanceDefinition instance1 = new ProxyInstanceDefinition("127.0.0.1@3307", "127.0.0.1@3307");
- InstanceDefinition instance2 = new ProxyInstanceDefinition("127.0.0.1@3308", "127.0.0.1@3308");
- List<InstanceDefinition> instances = Arrays.asList(instance1, instance2);
+ InstanceMetaData instance1 = new ProxyInstanceMetaData("127.0.0.1@3307", "127.0.0.1@3307");
+ InstanceMetaData instance2 = new ProxyInstanceMetaData("127.0.0.1@3308", "127.0.0.1@3308");
+ List<InstanceMetaData> instances = Arrays.asList(instance1, instance2);
RoundRobinTrafficLoadBalanceAlgorithm roundRobinAlgorithm = new RoundRobinTrafficLoadBalanceAlgorithm();
assertThat(roundRobinAlgorithm.getInstanceId("simple_traffic", instances), is(instance1));
assertThat(roundRobinAlgorithm.getInstanceId("simple_traffic", instances), is(instance2));
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
index b437c20408b..17666d5232d 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderParameter.java
@@ -22,7 +22,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import java.util.Collection;
import java.util.Map;
@@ -45,7 +45,7 @@ public final class ContextManagerBuilderParameter {
private final Collection<String> labels;
- private final InstanceDefinition instanceDefinition;
+ private final InstanceMetaData instanceMetaData;
/**
* Whether parameter is empty.
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index ff29f6f8bcb..ba4a2076a6e 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -25,8 +25,8 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContextFactory;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory;
@@ -59,14 +59,14 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
@Override
public ContextManager build(final ContextManagerBuilderParameter parameter) throws SQLException {
- ModeScheduleContextFactory.getInstance().init(parameter.getInstanceDefinition().getInstanceId(), parameter.getModeConfig());
+ ModeScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getInstanceId(), parameter.getModeConfig());
ClusterPersistRepository repository = ClusterPersistRepositoryFactory.getInstance((ClusterPersistRepositoryConfiguration) parameter.getModeConfig().getRepository());
MetaDataPersistService persistService = new MetaDataPersistService(repository);
persistConfigurations(persistService, parameter);
RegistryCenter registryCenter = new RegistryCenter(repository);
MetaDataContexts metaDataContexts = createMetaDataContexts(persistService, parameter);
persistMetaData(metaDataContexts);
- ContextManager result = createContextManager(repository, registryCenter, parameter.getInstanceDefinition(), metaDataContexts, parameter.getModeConfig());
+ ContextManager result = createContextManager(repository, registryCenter, parameter.getInstanceMetaData(), metaDataContexts, parameter.getModeConfig());
registerOnline(persistService, parameter, result, registryCenter);
return result;
}
@@ -79,7 +79,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
}
private MetaDataContexts createMetaDataContexts(final MetaDataPersistService persistService, final ContextManagerBuilderParameter parameter) throws SQLException {
- Collection<String> databaseNames = parameter.getInstanceDefinition() instanceof JDBCInstanceDefinition
+ Collection<String> databaseNames = parameter.getInstanceMetaData() instanceof JDBCInstanceMetaData
? parameter.getDatabaseConfigs().keySet()
: persistService.getSchemaMetaDataService().loadAllDatabaseNames();
Collection<RuleConfiguration> globalRuleConfigs = persistService.getGlobalRuleService().load();
@@ -109,11 +109,11 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
}
private ContextManager createContextManager(final ClusterPersistRepository repository, final RegistryCenter registryCenter,
- final InstanceDefinition instanceDefinition, final MetaDataContexts metaDataContexts,
+ final InstanceMetaData instanceMetaData, final MetaDataContexts metaDataContexts,
final ModeConfiguration modeConfig) {
- ClusterWorkerIdGenerator clusterWorkerIdGenerator = new ClusterWorkerIdGenerator(repository, registryCenter, instanceDefinition);
+ ClusterWorkerIdGenerator clusterWorkerIdGenerator = new ClusterWorkerIdGenerator(repository, registryCenter, instanceMetaData);
DistributedLockContext distributedLockContext = new DistributedLockContext(repository);
- InstanceContext instanceContext = new InstanceContext(new ComputeNodeInstance(instanceDefinition), clusterWorkerIdGenerator, modeConfig, distributedLockContext);
+ InstanceContext instanceContext = new InstanceContext(new ComputeNodeInstance(instanceMetaData), clusterWorkerIdGenerator, modeConfig, distributedLockContext);
repository.watchSessionConnection(instanceContext);
return new ContextManager(metaDataContexts, instanceContext);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
index f6d5415a917..459a1c73f35 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
@@ -225,7 +225,7 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void renew(final WorkerIdEvent event) {
- if (contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId().equals(event.getInstanceId())) {
+ if (contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId().equals(event.getInstanceId())) {
contextManager.getInstanceContext().updateWorkerId(event.getWorkerId());
}
}
@@ -248,7 +248,7 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void renew(final InstanceOnlineEvent event) {
- contextManager.getInstanceContext().addComputeNodeInstance(registryCenter.getComputeNodeStatusService().loadComputeNodeInstance(event.getInstanceDefinition()));
+ contextManager.getInstanceContext().addComputeNodeInstance(registryCenter.getComputeNodeStatusService().loadComputeNodeInstance(event.getInstanceMetaData()));
}
/**
@@ -258,7 +258,7 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void renew(final InstanceOfflineEvent event) {
- contextManager.getInstanceContext().deleteComputeNodeInstance(new ComputeNodeInstance(event.getInstanceDefinition()));
+ contextManager.getInstanceContext().deleteComputeNodeInstance(new ComputeNodeInstance(event.getInstanceMetaData()));
}
/**
@@ -281,7 +281,7 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void triggerShowProcessList(final ShowProcessListTriggerEvent event) {
- if (!event.getInstanceId().equals(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId())) {
+ if (!event.getInstanceId().equals(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId())) {
return;
}
Collection<YamlExecuteProcessContext> processContexts = ShowProcessListManager.getInstance().getAllProcessContext();
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
index e8b3d0b0363..49caded9c0e 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/RegistryCenter.java
@@ -73,7 +73,7 @@ public final class RegistryCenter {
* @param computeNodeInstance compute node instance
*/
public void onlineInstance(final ComputeNodeInstance computeNodeInstance) {
- computeNodeStatusService.registerOnline(computeNodeInstance.getInstanceDefinition());
+ computeNodeStatusService.registerOnline(computeNodeInstance.getInstanceMetaData());
computeNodeStatusService.persistInstanceLabels(computeNodeInstance.getCurrentInstanceId(), computeNodeInstance.getLabels());
listenerFactory.watchListeners();
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/manager/internal/ExclusiveInternalLock.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/manager/internal/ExclusiveInternalLock.java
index 643bf7c54be..c3109715a1a 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/manager/internal/ExclusiveInternalLock.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/manager/internal/ExclusiveInternalLock.java
@@ -137,7 +137,7 @@ public final class ExclusiveInternalLock implements InternalLock, LockAckAble {
return false;
}
for (ComputeNodeInstance each : computeNodeInstances) {
- if (!lockedInstances.contains(each.getInstanceDefinition().getInstanceId())) {
+ if (!lockedInstances.contains(each.getInstanceMetaData().getInstanceId())) {
return false;
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOfflineEvent.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOfflineEvent.java
index 10c3c4235c2..e9e446aa215 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOfflineEvent.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOfflineEvent.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
/**
@@ -29,5 +29,5 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.Gover
@Getter
public final class InstanceOfflineEvent implements GovernanceEvent {
- private final InstanceDefinition instanceDefinition;
+ private final InstanceMetaData instanceMetaData;
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOnlineEvent.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOnlineEvent.java
index 8a37ff185db..837114a2c90 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOnlineEvent.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/event/InstanceOnlineEvent.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.stat
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
/**
@@ -29,5 +29,5 @@ import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.Gover
@Getter
public final class InstanceOnlineEvent implements GovernanceEvent {
- private final InstanceDefinition instanceDefinition;
+ private final InstanceMetaData instanceMetaData;
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
index 7a40b8fcc0a..291f72f2b20 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusService.java
@@ -21,10 +21,10 @@ import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
@@ -47,10 +47,10 @@ public final class ComputeNodeStatusService {
/**
* Register online.
*
- * @param instanceDefinition instance definition
+ * @param instanceMetaData instance definition
*/
- public void registerOnline(final InstanceDefinition instanceDefinition) {
- repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(instanceDefinition.getInstanceId(), instanceDefinition.getInstanceType()), instanceDefinition.getAttributes());
+ public void registerOnline(final InstanceMetaData instanceMetaData) {
+ repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(instanceMetaData.getInstanceId(), instanceMetaData.getInstanceType()), instanceMetaData.getAttributes());
}
/**
@@ -130,26 +130,26 @@ public final class ComputeNodeStatusService {
private Collection<ComputeNodeInstance> loadComputeNodeInstances(final InstanceType instanceType) {
Collection<String> onlineComputeNodes = repository.getChildrenKeys(ComputeNode.getOnlineNodePath(instanceType));
- return onlineComputeNodes.stream().map(each -> loadComputeNodeInstance(createInstanceDefinition(each, instanceType))).collect(Collectors.toList());
+ return onlineComputeNodes.stream().map(each -> loadComputeNodeInstance(createInstanceMetaData(each, instanceType))).collect(Collectors.toList());
}
- private InstanceDefinition createInstanceDefinition(final String instanceId, final InstanceType type) {
+ private InstanceMetaData createInstanceMetaData(final String instanceId, final InstanceType type) {
return InstanceType.JDBC == type
- ? new JDBCInstanceDefinition(instanceId)
- : new ProxyInstanceDefinition(instanceId, repository.get(ComputeNode.getOnlineInstanceNodePath(instanceId, type)));
+ ? new JDBCInstanceMetaData(instanceId)
+ : new ProxyInstanceMetaData(instanceId, repository.get(ComputeNode.getOnlineInstanceNodePath(instanceId, type)));
}
/**
* Load compute node instance by instance definition.
*
- * @param instanceDefinition instance definition
+ * @param instanceMetaData instance definition
* @return compute node instance
*/
- public ComputeNodeInstance loadComputeNodeInstance(final InstanceDefinition instanceDefinition) {
- ComputeNodeInstance result = new ComputeNodeInstance(instanceDefinition);
- result.setLabels(loadInstanceLabels(instanceDefinition.getInstanceId()));
- result.switchState(loadInstanceStatus(instanceDefinition.getInstanceId()));
- loadInstanceWorkerId(instanceDefinition.getInstanceId()).ifPresent(result::setWorkerId);
+ public ComputeNodeInstance loadComputeNodeInstance(final InstanceMetaData instanceMetaData) {
+ ComputeNodeInstance result = new ComputeNodeInstance(instanceMetaData);
+ result.setLabels(loadInstanceLabels(instanceMetaData.getInstanceId()));
+ result.switchState(loadInstanceStatus(instanceMetaData.getInstanceId()));
+ loadInstanceWorkerId(instanceMetaData.getInstanceId()).ifPresent(result::setWorkerId);
return result;
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/watcher/ComputeNodeStateChangedWatcher.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/watcher/ComputeNodeStateChan [...]
index 48b6e920d21..5dd0461d7e5 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/watcher/ComputeNodeStateChangedWatcher.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/watcher/ComputeNodeStateChangedWatcher.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.watcher;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceEvent;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcher;
@@ -103,12 +103,12 @@ public final class ComputeNodeStateChangedWatcher implements GovernanceWatcher<G
private Optional<GovernanceEvent> createInstanceEvent(final DataChangedEvent event) {
Matcher matcher = matchInstanceOnlinePath(event.getKey());
if (matcher.find()) {
- InstanceDefinition instanceDefinition = createInstanceDefinition(matcher.group(2), InstanceType.valueOf(matcher.group(1).toUpperCase()), event.getValue());
+ InstanceMetaData instanceMetaData = createInstanceMetaData(matcher.group(2), InstanceType.valueOf(matcher.group(1).toUpperCase()), event.getValue());
if (Type.ADDED == event.getType()) {
- return Optional.of(new InstanceOnlineEvent(instanceDefinition));
+ return Optional.of(new InstanceOnlineEvent(instanceMetaData));
}
if (Type.DELETED == event.getType()) {
- return Optional.of(new InstanceOfflineEvent(instanceDefinition));
+ return Optional.of(new InstanceOfflineEvent(instanceMetaData));
}
}
return Optional.empty();
@@ -118,7 +118,7 @@ public final class ComputeNodeStateChangedWatcher implements GovernanceWatcher<G
return Pattern.compile(ComputeNode.getOnlineInstanceNodePath() + "/[\\S]+/([\\S]+)$", Pattern.CASE_INSENSITIVE).matcher(onlineInstancePath);
}
- private InstanceDefinition createInstanceDefinition(final String instanceId, final InstanceType instanceType, final String attributes) {
- return InstanceType.JDBC == instanceType ? new JDBCInstanceDefinition(instanceId) : new ProxyInstanceDefinition(instanceId, attributes);
+ private InstanceMetaData createInstanceMetaData(final String instanceId, final InstanceType instanceType, final String attributes) {
+ return InstanceType.JDBC == instanceType ? new JDBCInstanceMetaData(instanceId) : new ProxyInstanceMetaData(instanceId, attributes);
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
index 95c1549a64b..4a838234146 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/workerid/generator/ClusterWorkerIdGenerator.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.generator;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.RegistryCenter;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.workerid.node.WorkerIdNode;
@@ -36,16 +36,16 @@ public final class ClusterWorkerIdGenerator implements WorkerIdGenerator {
private final RegistryCenter registryCenter;
- private final InstanceDefinition instanceDefinition;
+ private final InstanceMetaData instanceMetaData;
@Override
public long generate() {
- return registryCenter.getComputeNodeStatusService().loadInstanceWorkerId(instanceDefinition.getInstanceId()).orElseGet(this::reGenerate);
+ return registryCenter.getComputeNodeStatusService().loadInstanceWorkerId(instanceMetaData.getInstanceId()).orElseGet(this::reGenerate);
}
private Long reGenerate() {
- Long result = Long.valueOf(Optional.ofNullable(repository.getSequentialId(WorkerIdNode.getWorkerIdGeneratorPath(instanceDefinition.getInstanceId()), "")).orElse("0"));
- registryCenter.getComputeNodeStatusService().persistInstanceWorkerId(instanceDefinition.getInstanceId(), result);
+ Long result = Long.valueOf(Optional.ofNullable(repository.getSequentialId(WorkerIdNode.getWorkerIdGeneratorPath(instanceMetaData.getInstanceId()), "")).orElse("0"));
+ registryCenter.getComputeNodeStatusService().persistInstanceWorkerId(instanceMetaData.getInstanceId(), result);
return result;
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 3d9b3ea6f02..5f909bd29d0 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -33,8 +33,8 @@ import org.apache.shardingsphere.infra.executor.sql.process.model.yaml.YamlExecu
import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
import org.apache.shardingsphere.infra.federation.optimizer.metadata.FederationDatabaseMetaData;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResource;
@@ -145,8 +145,8 @@ public final class ClusterContextManagerCoordinatorTest {
private ContextManagerBuilderParameter createContextManagerBuilderParameter() {
ModeConfiguration modeConfig = new ModeConfiguration("Cluster", new ClusterPersistRepositoryConfiguration("FIXTURE", "", "", new Properties()), false);
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- return new ContextManagerBuilderParameter(modeConfig, Collections.emptyMap(), Collections.emptyList(), new Properties(), Collections.emptyList(), instanceDefinition);
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ return new ContextManagerBuilderParameter(modeConfig, Collections.emptyMap(), Collections.emptyList(), new Properties(), Collections.emptyList(), instanceMetaData);
}
private Map<String, ShardingSphereDatabase> createDatabases() {
@@ -291,7 +291,7 @@ public final class ClusterContextManagerCoordinatorTest {
public void assertRenewInstanceStatus() {
Collection<String> testStates = new LinkedList<>();
testStates.add(StateType.OK.name());
- StateEvent mockStateEvent = new StateEvent(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId(), testStates);
+ StateEvent mockStateEvent = new StateEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId(), testStates);
coordinator.renew(mockStateEvent);
assertThat(contextManager.getInstanceContext().getInstance().getState().getCurrentState(), is(StateType.OK));
testStates.add(StateType.CIRCUIT_BREAK.name());
@@ -301,7 +301,7 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertRenewWorkerIdChange() {
- WorkerIdEvent mockWorkerIdEvent = new WorkerIdEvent(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId(), 12223L);
+ WorkerIdEvent mockWorkerIdEvent = new WorkerIdEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId(), 12223L);
coordinator.renew(mockWorkerIdEvent);
assertThat(contextManager.getInstanceContext().getWorkerId(), is(12223L));
}
@@ -309,14 +309,14 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertRenewInstanceLabels() {
Collection<String> labels = Collections.singleton("test");
- coordinator.renew(new LabelsEvent(contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId(), labels));
+ coordinator.renew(new LabelsEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId(), labels));
assertThat(contextManager.getInstanceContext().getInstance().getLabels(), is(labels));
}
@Test
public void assertRenewInstanceOfflineEvent() {
- coordinator.renew(new InstanceOfflineEvent(contextManager.getInstanceContext().getInstance().getInstanceDefinition()));
- assertThat(((ProxyInstanceDefinition) contextManager.getInstanceContext().getInstance().getInstanceDefinition()).getPort(), is(3307));
+ coordinator.renew(new InstanceOfflineEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData()));
+ assertThat(((ProxyInstanceMetaData) contextManager.getInstanceContext().getInstance().getInstanceMetaData()).getPort(), is(3307));
}
@Test
@@ -334,19 +334,19 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertRenewInstanceOnlineEvent() {
- InstanceDefinition instanceDefinition1 = new ProxyInstanceDefinition("foo_instance_3307", 3307);
- InstanceOnlineEvent instanceOnlineEvent1 = new InstanceOnlineEvent(instanceDefinition1);
+ InstanceMetaData instanceMetaData1 = new ProxyInstanceMetaData("foo_instance_3307", 3307);
+ InstanceOnlineEvent instanceOnlineEvent1 = new InstanceOnlineEvent(instanceMetaData1);
coordinator.renew(instanceOnlineEvent1);
assertThat(contextManager.getInstanceContext().getComputeNodeInstances().size(), is(1));
- assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(0).getInstanceDefinition(), is(instanceDefinition1));
- InstanceDefinition instanceDefinition2 = new ProxyInstanceDefinition("foo_instance_3308", 3308);
- InstanceOnlineEvent instanceOnlineEvent2 = new InstanceOnlineEvent(instanceDefinition2);
+ assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(0).getInstanceMetaData(), is(instanceMetaData1));
+ InstanceMetaData instanceMetaData2 = new ProxyInstanceMetaData("foo_instance_3308", 3308);
+ InstanceOnlineEvent instanceOnlineEvent2 = new InstanceOnlineEvent(instanceMetaData2);
coordinator.renew(instanceOnlineEvent2);
assertThat(contextManager.getInstanceContext().getComputeNodeInstances().size(), is(2));
- assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(1).getInstanceDefinition(), is(instanceDefinition2));
+ assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(1).getInstanceMetaData(), is(instanceMetaData2));
coordinator.renew(instanceOnlineEvent1);
assertThat(contextManager.getInstanceContext().getComputeNodeInstances().size(), is(2));
- assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(1).getInstanceDefinition(), is(instanceDefinition1));
+ assertThat(((LinkedList<ComputeNodeInstance>) contextManager.getInstanceContext().getComputeNodeInstances()).get(1).getInstanceMetaData(), is(instanceMetaData1));
}
@Test
@@ -372,7 +372,7 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertTriggerShowProcessList() throws NoSuchFieldException, IllegalAccessException {
- String instanceId = contextManager.getInstanceContext().getInstance().getInstanceDefinition().getInstanceId();
+ String instanceId = contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId();
ShowProcessListManager.getInstance().putProcessContext("foo_execution_id", new YamlExecuteProcessContext(mock(ExecuteProcessContext.class)));
String showProcessListId = "foo_process_id";
coordinator.triggerShowProcessList(new ShowProcessListTriggerEvent(instanceId, showProcessListId));
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/DistributedLockContextTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/DistributedLockContextTest.java
index 41ad42a0d16..e75bf0f22f8 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/DistributedLockContextTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/lock/DistributedLockContextTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mode.manager.cluster.coordinator.lock;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator;
import org.apache.shardingsphere.infra.lock.ShardingSphereLock;
import org.apache.shardingsphere.mode.manager.lock.definition.LockNameDefinitionFactory;
@@ -38,14 +38,14 @@ public final class DistributedLockContextTest {
@Test
public void assertGetDistributedLock() {
DistributedLockContext distributedLockContext = new DistributedLockContext(mock(ClusterPersistRepository.class));
- ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceDefinition("1", 3307));
+ ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceMetaData("1", 3307));
new InstanceContext(currentInstance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), distributedLockContext);
assertThat(distributedLockContext.getLock(), instanceOf(ShardingSphereLock.class));
}
@Test
public void assertTryLock() {
- ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceDefinition("1", 3307));
+ ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceMetaData("1", 3307));
DistributedLockContext distributedLockContext = new DistributedLockContext(mock(ClusterPersistRepository.class));
new InstanceContext(currentInstance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), distributedLockContext);
assertNotNull(distributedLockContext.getLock());
@@ -53,7 +53,7 @@ public final class DistributedLockContextTest {
@Test
public void assertReleaseLock() {
- ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceDefinition("1", 3307));
+ ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceMetaData("1", 3307));
DistributedLockContext distributedLockContext = new DistributedLockContext(mock(ClusterPersistRepository.class));
new InstanceContext(currentInstance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), distributedLockContext);
distributedLockContext.releaseLock(LockNameDefinitionFactory.newDatabaseDefinition("database"));
@@ -61,7 +61,7 @@ public final class DistributedLockContextTest {
@Test
public void assertIsLockedDatabase() {
- ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceDefinition("1", 3307));
+ ComputeNodeInstance currentInstance = new ComputeNodeInstance(new ProxyInstanceMetaData("1", 3307));
DistributedLockContext distributedLockContext = new DistributedLockContext(mock(ClusterPersistRepository.class));
new InstanceContext(currentInstance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), distributedLockContext);
assertFalse(distributedLockContext.isLocked(LockNameDefinitionFactory.newDatabaseDefinition("database")));
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServi [...]
index 33571dc3091..26c182ca01d 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/status/compute/service/ComputeNodeStatusServiceTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.service;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.mode.metadata.persist.node.ComputeNode;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
@@ -48,16 +48,16 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertRegisterOnline() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- new ComputeNodeStatusService(repository).registerOnline(instanceDefinition);
- verify(repository).persistEphemeral(eq("/nodes/compute_nodes/online/proxy/" + instanceDefinition.getInstanceId()), anyString());
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ new ComputeNodeStatusService(repository).registerOnline(instanceMetaData);
+ verify(repository).persistEphemeral(eq("/nodes/compute_nodes/online/proxy/" + instanceMetaData.getInstanceId()), anyString());
}
@Test
public void assertPersistInstanceLabels() {
ComputeNodeStatusService computeNodeStatusService = new ComputeNodeStatusService(repository);
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- final String instanceId = instanceDefinition.getInstanceId();
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ final String instanceId = instanceMetaData.getInstanceId();
computeNodeStatusService.persistInstanceLabels(instanceId, Collections.singletonList("test"));
verify(repository, times(1)).persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), YamlEngine.marshal(Collections.singletonList("test")));
computeNodeStatusService.persistInstanceLabels(instanceId, Collections.emptyList());
@@ -66,32 +66,32 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertPersistInstanceWorkerId() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- final String instanceId = instanceDefinition.getInstanceId();
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ final String instanceId = instanceMetaData.getInstanceId();
new ComputeNodeStatusService(repository).persistInstanceWorkerId(instanceId, 100L);
verify(repository).persistEphemeral(ComputeNode.getInstanceWorkerIdNodePath(instanceId), String.valueOf(100L));
}
@Test
public void assertLoadInstanceLabels() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- final String instanceId = instanceDefinition.getInstanceId();
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ final String instanceId = instanceMetaData.getInstanceId();
new ComputeNodeStatusService(repository).loadInstanceLabels(instanceId);
verify(repository).get(ComputeNode.getInstanceLabelsNodePath(instanceId));
}
@Test
public void assertLoadInstanceStatus() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- final String instanceId = instanceDefinition.getInstanceId();
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ final String instanceId = instanceMetaData.getInstanceId();
new ComputeNodeStatusService(repository).loadInstanceStatus(instanceId);
verify(repository).get(ComputeNode.getInstanceStatusNodePath(instanceId));
}
@Test
public void assertLoadInstanceWorkerId() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- final String instanceId = instanceDefinition.getInstanceId();
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ final String instanceId = instanceMetaData.getInstanceId();
new ComputeNodeStatusService(repository).loadInstanceWorkerId(instanceId);
verify(repository).get(ComputeNode.getInstanceWorkerIdNodePath(instanceId));
}
@@ -108,8 +108,8 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertLoadComputeNodeInstance() {
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition("foo_instance_id", 3307);
- ComputeNodeInstance actual = new ComputeNodeStatusService(repository).loadComputeNodeInstance(instanceDefinition);
- assertThat(actual.getInstanceDefinition(), is(instanceDefinition));
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
+ ComputeNodeInstance actual = new ComputeNodeStatusService(repository).loadComputeNodeInstance(instanceMetaData);
+ assertThat(actual.getInstanceMetaData(), is(instanceMetaData));
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-reposit [...]
index 83ccaf16821..b9d90649a00 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-zookeeper-curator/src/main/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/listener/SessionConnectionListener.java
@@ -58,7 +58,7 @@ public final class SessionConnectionListener implements ConnectionStateListener
try {
if (client.getZookeeperClient().blockUntilConnectedOrTimedOut()) {
repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(instanceContext.getInstance().getCurrentInstanceId(),
- instanceContext.getInstance().getInstanceDefinition().getInstanceType()), instanceContext.getInstance().getInstanceDefinition().getAttributes());
+ instanceContext.getInstance().getInstanceMetaData().getInstanceType()), instanceContext.getInstance().getInstanceMetaData().getAttributes());
return true;
}
sleepInterval();
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
index a7142d9c77a..0f56ba12f40 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-memory-mode/shardingsphere-memory-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/memory/MemoryContextManagerBuilder.java
@@ -53,7 +53,7 @@ public final class MemoryContextManagerBuilder implements ContextManagerBuilder
}
private InstanceContext buildInstanceContext(final ContextManagerBuilderParameter parameter) {
- ComputeNodeInstance instance = new ComputeNodeInstance(parameter.getInstanceDefinition());
+ ComputeNodeInstance instance = new ComputeNodeInstance(parameter.getInstanceMetaData());
instance.setLabels(parameter.getLabels());
return new InstanceContext(instance, new MemoryWorkerIdGenerator(), buildMemoryModeConfiguration(parameter.getModeConfig()), new MemoryLockContext());
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index 75710dca76b..68d8faf2953 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContextFactory;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.jdbc.JDBCInstanceMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory;
@@ -65,7 +65,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
}
private MetaDataContexts createMetaDataContexts(final MetaDataPersistService persistService, final ContextManagerBuilderParameter parameter) throws SQLException {
- Collection<String> databaseNames = parameter.getInstanceDefinition() instanceof JDBCInstanceDefinition
+ Collection<String> databaseNames = parameter.getInstanceMetaData() instanceof JDBCInstanceMetaData
? parameter.getDatabaseConfigs().keySet()
: persistService.getSchemaMetaDataService().loadAllDatabaseNames();
Map<String, DatabaseConfiguration> databaseConfigMap = getDatabaseConfigMap(databaseNames, persistService, parameter);
@@ -92,7 +92,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
private ContextManager createContextManager(final ContextManagerBuilderParameter parameter, final MetaDataContexts metaDataContexts) {
InstanceContext instanceContext = new InstanceContext(
- new ComputeNodeInstance(parameter.getInstanceDefinition()), new StandaloneWorkerIdGenerator(), parameter.getModeConfig(), new StandaloneLockContext());
+ new ComputeNodeInstance(parameter.getInstanceMetaData()), new StandaloneWorkerIdGenerator(), parameter.getModeConfig(), new StandaloneLockContext());
return new ContextManager(metaDataContexts, instanceContext);
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
index 6e32abdc94f..5a7437843d8 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilderTextTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilderParameter;
import org.apache.shardingsphere.mode.metadata.persist.node.DatabaseMetaDataNode;
@@ -62,7 +62,7 @@ public final class StandaloneContextManagerBuilderTextTest {
Map<String, DatabaseConfiguration> databaseConfigs = Collections.singletonMap(
"foo_db", new DataSourceProvidedDatabaseConfiguration(Collections.singletonMap("foo_ds", new MockedDataSource()), Collections.singleton(mock(RuleConfiguration.class))));
Collection<RuleConfiguration> globalRuleConfigs = Collections.singleton(mock(RuleConfiguration.class));
- InstanceDefinition instanceDefinition = new ProxyInstanceDefinition(UUID.randomUUID().toString(), 3307);
- return new ContextManagerBuilderParameter(modeConfig, databaseConfigs, globalRuleConfigs, new Properties(), Collections.emptyList(), instanceDefinition);
+ InstanceMetaData instanceMetaData = new ProxyInstanceMetaData(UUID.randomUUID().toString(), 3307);
+ return new ContextManagerBuilderParameter(modeConfig, databaseConfigs, globalRuleConfigs, new Properties(), Collections.emptyList(), instanceMetaData);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
index 0e728a5f786..c72ca759dcc 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceHandler.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.queryabl
import org.apache.shardingsphere.distsql.parser.statement.ral.common.queryable.ShowInstanceStatement;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.infra.instance.definition.InstanceType;
-import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.proxy.ProxyInstanceMetaData;
import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.QueryableRALBackendHandler;
@@ -61,15 +61,15 @@ public final class ShowInstanceHandler extends QueryableRALBackendHandler<ShowIn
return Collections.singletonList(buildRow(contextManager.getInstanceContext().getInstance(), modeType));
}
Collection<ComputeNodeInstance> instances = contextManager.getInstanceContext().getComputeNodeInstances().stream()
- .filter(each -> InstanceType.PROXY == each.getInstanceDefinition().getInstanceType()).collect(Collectors.toList());
+ .filter(each -> InstanceType.PROXY == each.getInstanceMetaData().getInstanceType()).collect(Collectors.toList());
return instances.isEmpty() ? Collections.emptyList() : instances.stream().filter(Objects::nonNull).map(each -> buildRow(each, modeType)).collect(Collectors.toList());
}
private LocalDataQueryResultRow buildRow(final ComputeNodeInstance instance, final String modeType) {
String labels = null == instance.getLabels() ? "" : String.join(",", instance.getLabels());
- InstanceDefinition instanceDefinition = instance.getInstanceDefinition();
- return new LocalDataQueryResultRow(instanceDefinition.getInstanceId(), instanceDefinition.getIp(),
- instanceDefinition instanceof ProxyInstanceDefinition ? ((ProxyInstanceDefinition) instanceDefinition).getPort() : -1,
+ InstanceMetaData instanceMetaData = instance.getInstanceMetaData();
+ return new LocalDataQueryResultRow(instanceMetaData.getInstanceId(), instanceMetaData.getIp(),
+ instanceMetaData instanceof ProxyInstanceMetaData ? ((ProxyInstanceMetaData) instanceMetaData).getPort() : -1,
instance.getState().getCurrentState().name(), modeType, labels);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
index a70c9669a71..779f4cfcfde 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandler.java
@@ -54,7 +54,7 @@ public final class ShowInstanceModeHandler extends QueryableRALBackendHandler<Sh
protected Collection<LocalDataQueryResultRow> getRows(final ContextManager contextManager) {
InstanceContext instanceContext = ProxyContext.getInstance().getContextManager().getInstanceContext();
PersistRepositoryConfiguration repositoryConfig = instanceContext.getModeConfiguration().getRepository();
- String instanceId = instanceContext.getInstance().getInstanceDefinition().getInstanceId();
+ String instanceId = instanceContext.getInstance().getInstanceMetaData().getInstanceId();
String modeType = instanceContext.getModeConfiguration().getType();
String repositoryType = null == repositoryConfig ? "" : repositoryConfig.getType();
String props = null == repositoryConfig || null == repositoryConfig.getProps() ? "" : new Gson().toJson(repositoryConfig.getProps());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
index 6250067be44..3d1e1ae07c6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/fixture/DistSQLTrafficLoadBalanceAlgorithmFixture.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.distsql.fixture;
import lombok.Getter;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm;
import java.util.List;
@@ -40,7 +40,7 @@ public final class DistSQLTrafficLoadBalanceAlgorithmFixture implements TrafficL
}
@Override
- public InstanceDefinition getInstanceId(final String name, final List<InstanceDefinition> instances) {
+ public InstanceMetaData getInstanceId(final String name, final List<InstanceMetaData> instances) {
return null;
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
index 4e5770a2213..8d6c50f3e04 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
@@ -59,7 +59,7 @@ public final class ShowInstanceModeHandlerTest extends ProxyContextRestorer {
private InstanceContext createInstanceContext() {
InstanceContext result = mock(InstanceContext.class, RETURNS_DEEP_STUBS);
- when(result.getInstance().getInstanceDefinition().getInstanceId()).thenReturn("127.0.0.1@3309");
+ when(result.getInstance().getInstanceMetaData().getInstanceId()).thenReturn("127.0.0.1@3309");
when(result.getModeConfiguration()).thenReturn(new ModeConfiguration("Cluster",
new ClusterPersistRepositoryConfiguration("ZooKeeper", "governance_ds", "127.0.0.1:2181", createProperties("key", "value1,value2")), false));
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index dce009be85f..834f557edeb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.proxy.initializer;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
-import org.apache.shardingsphere.infra.instance.definition.InstanceDefinitionBuilderFactory;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaData;
+import org.apache.shardingsphere.infra.instance.definition.InstanceMetaDataBuilderFactory;
import org.apache.shardingsphere.infra.yaml.config.swapper.mode.ModeConfigurationYamlSwapper;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.ContextManagerBuilderFactory;
@@ -60,9 +60,9 @@ public final class BootstrapInitializer {
private ContextManager createContextManager(final YamlProxyConfiguration yamlConfig, final ModeConfiguration modeConfig, final int port) throws SQLException {
ProxyConfiguration proxyConfig = new YamlProxyConfigurationSwapper().swap(yamlConfig);
- InstanceDefinition instanceDefinition = InstanceDefinitionBuilderFactory.newInstance("Proxy", port);
+ InstanceMetaData instanceMetaData = InstanceMetaDataBuilderFactory.newInstance("Proxy", port);
ContextManagerBuilderParameter parameter = new ContextManagerBuilderParameter(modeConfig, proxyConfig.getDatabaseConfigurations(),
- proxyConfig.getGlobalConfiguration().getRules(), proxyConfig.getGlobalConfiguration().getProperties(), proxyConfig.getGlobalConfiguration().getLabels(), instanceDefinition);
+ proxyConfig.getGlobalConfiguration().getRules(), proxyConfig.getGlobalConfiguration().getProperties(), proxyConfig.getGlobalConfiguration().getLabels(), instanceMetaData);
return ContextManagerBuilderFactory.getInstance(modeConfig).build(parameter);
}