You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/07/02 08:49:59 UTC
[shardingsphere] branch master updated: Refactor InstanceMetaData (#18787)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 3a93b8aee9a Refactor InstanceMetaData (#18787)
3a93b8aee9a is described below
commit 3a93b8aee9aac8ea920b9bcbcee3bfded774124e
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Jul 2 16:49:54 2022 +0800
Refactor InstanceMetaData (#18787)
---
.../dbdiscovery/rule/DatabaseDiscoveryRule.java | 2 +-
.../infra/instance/ComputeNodeInstance.java | 2 +-
.../infra/instance/InstanceContext.java | 14 +++++++-------
.../infra/instance/metadata/InstanceMetaData.java | 4 ++--
.../instance/metadata/jdbc/JDBCInstanceMetaData.java | 8 ++++----
.../metadata/proxy/ProxyInstanceMetaData.java | 12 ++++++------
.../infra/instance/InstanceContextTest.java | 8 ++++----
.../jdbc/JDBCInstanceMetaDataBuilderTest.java | 4 ++--
.../proxy/ProxyInstanceMetaDataBuilderTest.java | 4 ++--
.../jdbc/core/connection/ConnectionManager.java | 2 +-
.../shardingsphere/traffic/engine/TrafficEngine.java | 2 +-
.../manager/cluster/ClusterContextManagerBuilder.java | 19 +++++++++----------
.../coordinator/ClusterContextManagerCoordinator.java | 4 ++--
.../lock/manager/internal/ExclusiveInternalLock.java | 2 +-
.../compute/service/ComputeNodeStatusService.java | 8 ++++----
.../workerid/generator/ClusterWorkerIdGenerator.java | 6 +++---
.../ClusterContextManagerCoordinatorTest.java | 8 ++++----
.../compute/service/ComputeNodeStatusServiceTest.java | 12 ++++++------
.../zookeeper/listener/SessionConnectionListener.java | 2 +-
.../ral/common/queryable/ShowInstanceHandler.java | 4 ++--
.../ral/common/queryable/ShowInstanceModeHandler.java | 2 +-
.../common/queryable/ShowInstanceModeHandlerTest.java | 2 +-
22 files changed, 65 insertions(+), 66 deletions(-)
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 651fb6da2e9..a46964674e6 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().getInstanceMetaData().getInstanceId());
+ Optional<ModeScheduleContext> modeScheduleContext = ModeScheduleContextFactory.getInstance().get(instanceContext.getInstance().getInstanceMetaData().getId());
if (modeScheduleContext.isPresent()) {
for (Entry<String, DatabaseDiscoveryDataSourceRule> entry : dataSourceRules.entrySet()) {
DatabaseDiscoveryDataSourceRule rule = entry.getValue();
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 e6c7d026259..51a68a2e8e7 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
@@ -69,6 +69,6 @@ public final class ComputeNodeInstance {
* @return current instance id
*/
public String getCurrentInstanceId() {
- return instanceMetaData.getInstanceId();
+ return instanceMetaData.getId();
}
}
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 1fe4dfa41bc..ebef3b2a871 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
@@ -63,7 +63,7 @@ public final class InstanceContext {
* @param status status
*/
public void updateInstanceStatus(final String instanceId, final Collection<String> status) {
- if (instance.getInstanceMetaData().getInstanceId().equals(instanceId)) {
+ if (instance.getInstanceMetaData().getId().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.getInstanceMetaData().getInstanceId().equals(instanceId)) {
+ if (each.getInstanceMetaData().getId().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.getInstanceMetaData().getInstanceId().equals(instanceId)) {
+ if (instance.getInstanceMetaData().getId().equals(instanceId)) {
instance.setLabels(labels);
}
- computeNodeInstances.stream().filter(each -> each.getInstanceMetaData().getInstanceId().equals(instanceId)).forEach(each -> each.setLabels(labels));
+ computeNodeInstances.stream().filter(each -> each.getInstanceMetaData().getId().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.getInstanceMetaData().getInstanceId().equalsIgnoreCase(instance.getInstanceMetaData().getInstanceId()));
+ computeNodeInstances.removeIf(each -> each.getInstanceMetaData().getId().equalsIgnoreCase(instance.getInstanceMetaData().getId()));
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.getInstanceMetaData().getInstanceId().equalsIgnoreCase(instance.getInstanceMetaData().getInstanceId()));
+ computeNodeInstances.removeIf(each -> each.getInstanceMetaData().getId().equalsIgnoreCase(instance.getInstanceMetaData().getId()));
}
/**
@@ -143,7 +143,7 @@ public final class InstanceContext {
public List<InstanceMetaData> getComputeNodeInstances(final InstanceType instanceType, final Collection<String> labels) {
List<InstanceMetaData> result = new ArrayList<>(computeNodeInstances.size());
for (ComputeNodeInstance each : computeNodeInstances) {
- if (each.getInstanceMetaData().getInstanceType() == instanceType && labels.stream().anyMatch(((Collection<String>) each.getLabels())::contains)) {
+ if (each.getInstanceMetaData().getType() == instanceType && labels.stream().anyMatch(((Collection<String>) each.getLabels())::contains)) {
result.add(each.getInstanceMetaData());
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaData.java
index 26198cac926..55df09e5e82 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/InstanceMetaData.java
@@ -27,14 +27,14 @@ public interface InstanceMetaData {
*
* @return instance ID
*/
- String getInstanceId();
+ String getId();
/**
* Get instance type.
*
* @return instance type
*/
- InstanceType getInstanceType();
+ InstanceType getType();
/**
* Get IP.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaData.java
index 038a969cbab..42501ae9704 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaData.java
@@ -28,17 +28,17 @@ import org.apache.shardingsphere.infra.instance.utils.IpUtils;
@Getter
public final class JDBCInstanceMetaData implements InstanceMetaData {
- private final String instanceId;
+ private final String id;
private final String ip;
- public JDBCInstanceMetaData(final String instanceId) {
- this.instanceId = instanceId;
+ public JDBCInstanceMetaData(final String id) {
+ this.id = id;
ip = IpUtils.getIp();
}
@Override
- public InstanceType getInstanceType() {
+ public InstanceType getType() {
return InstanceType.JDBC;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaData.java
index 395896832d8..9788c0f9881 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaData.java
@@ -31,27 +31,27 @@ public final class ProxyInstanceMetaData implements InstanceMetaData {
private static final String DELIMITER = "@";
- private final String instanceId;
+ private final String id;
private final String ip;
private final int port;
- public ProxyInstanceMetaData(final String instanceId, final int port) {
- this.instanceId = instanceId;
+ public ProxyInstanceMetaData(final String id, final int port) {
+ this.id = id;
ip = IpUtils.getIp();
this.port = port;
}
- public ProxyInstanceMetaData(final String instanceId, final String attributes) {
- this.instanceId = instanceId;
+ public ProxyInstanceMetaData(final String id, final String attributes) {
+ this.id = id;
String[] attributesList = attributes.split(DELIMITER);
ip = attributesList[0];
port = Integer.parseInt(attributesList[1]);
}
@Override
- public InstanceType getInstanceType() {
+ public InstanceType getType() {
return InstanceType.PROXY;
}
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 fe137700319..9d627394dbb 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
@@ -49,14 +49,14 @@ public final class InstanceContextTest {
@Test
public void assertUpdateInstanceStatus() {
InstanceMetaData instanceMetaData = mock(InstanceMetaData.class);
- when(instanceMetaData.getInstanceId()).thenReturn("foo_instance_id");
+ when(instanceMetaData.getId()).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(instanceMetaData.getInstanceId(), Collections.singleton(StateType.CIRCUIT_BREAK.name()));
+ context.updateInstanceStatus(instanceMetaData.getId(), Collections.singleton(StateType.CIRCUIT_BREAK.name()));
actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.CIRCUIT_BREAK));
- context.updateInstanceStatus(instanceMetaData.getInstanceId(), Collections.emptyList());
+ context.updateInstanceStatus(instanceMetaData.getId(), Collections.emptyList());
actual = context.getInstance().getState().getCurrentState();
assertThat(actual, is(StateType.OK));
}
@@ -76,7 +76,7 @@ public final class InstanceContextTest {
@Test
public void assertUpdateLabel() {
InstanceMetaData instanceMetaData = mock(InstanceMetaData.class);
- when(instanceMetaData.getInstanceId()).thenReturn("foo_instance_id");
+ when(instanceMetaData.getId()).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);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java
index 49972ac4851..c6dd4f8ad06 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/jdbc/JDBCInstanceMetaDataBuilderTest.java
@@ -31,9 +31,9 @@ public final class JDBCInstanceMetaDataBuilderTest {
@Test
public void assertNewInstance() {
InstanceMetaData actual = InstanceMetaDataBuilderFactory.create("JDBC", -1);
- assertNotNull(actual.getInstanceId());
+ assertNotNull(actual.getId());
assertNotNull(actual.getIp());
assertThat(actual.getAttributes(), is(""));
- assertThat(actual.getInstanceType(), is(InstanceType.JDBC));
+ assertThat(actual.getType(), is(InstanceType.JDBC));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java
index efbdabf6641..731d3bd7733 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/instance/metadata/proxy/ProxyInstanceMetaDataBuilderTest.java
@@ -31,10 +31,10 @@ public final class ProxyInstanceMetaDataBuilderTest {
@Test
public void assertNewInstance() {
ProxyInstanceMetaData actual = (ProxyInstanceMetaData) InstanceMetaDataBuilderFactory.create("Proxy", 3307);
- assertNotNull(actual.getInstanceId());
+ assertNotNull(actual.getId());
assertNotNull(actual.getIp());
assertThat(actual.getPort(), is(3307));
assertThat(actual.getAttributes(), endsWith("@3307"));
- assertThat(actual.getInstanceType(), is(InstanceType.PROXY));
+ assertThat(actual.getType(), is(InstanceType.PROXY));
}
}
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 4ae18d91afd..059b9a61e7d 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
@@ -101,7 +101,7 @@ public final class ConnectionManager implements ExecutorJDBCConnectionManager, A
final DataSourceProperties dataSourcePropsSample, final String schema) {
Map<String, DataSourceProperties> result = new LinkedHashMap<>();
for (InstanceMetaData each : instances) {
- result.put(each.getInstanceId(), createDataSourceProperties((ProxyInstanceMetaData) each, users, dataSourcePropsSample, schema));
+ result.put(each.getId(), createDataSourceProperties((ProxyInstanceMetaData) each, users, dataSourcePropsSample, schema));
}
return result;
}
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 b9276735916..41287d63272 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
@@ -57,7 +57,7 @@ public final class TrafficEngine {
if (!instances.isEmpty()) {
TrafficLoadBalanceAlgorithm loadBalancer = strategyRule.get().getLoadBalancer();
InstanceMetaData instanceMetaData = 1 == instances.size() ? instances.iterator().next() : loadBalancer.getInstanceId(strategyRule.get().getName(), instances);
- result.setInstanceId(instanceMetaData.getInstanceId());
+ result.setInstanceId(instanceMetaData.getId());
}
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/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 84f07c2ca99..8793b7830e8 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
@@ -59,7 +59,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
@Override
public ContextManager build(final ContextManagerBuilderParameter parameter) throws SQLException {
- ModeScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getInstanceId(), parameter.getModeConfig());
+ ModeScheduleContextFactory.getInstance().init(parameter.getInstanceMetaData().getId(), parameter.getModeConfig());
ClusterPersistRepository repository = ClusterPersistRepositoryFactory.getInstance((ClusterPersistRepositoryConfiguration) parameter.getModeConfig().getRepository());
MetaDataPersistService persistService = new MetaDataPersistService(repository);
persistConfigurations(persistService, parameter);
@@ -89,15 +89,15 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
return new MetaDataContexts(persistService, new ShardingSphereMetaData(databases, globalMetaData, props), OptimizerContextFactory.create(databases, globalMetaData));
}
- private Map<String, DatabaseConfiguration> getDatabaseConfigMap(final Collection<String> databaseNames, final MetaDataPersistService metaDataPersistService,
- final ContextManagerBuilderParameter parameter) {
+ private Map<String, DatabaseConfiguration> getDatabaseConfigMap(final Collection<String> databaseNames,
+ final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter) {
Map<String, DatabaseConfiguration> result = new HashMap<>(databaseNames.size(), 1);
databaseNames.forEach(each -> result.put(each, createDatabaseConfiguration(each, metaDataPersistService, parameter)));
return result;
}
- private DatabaseConfiguration createDatabaseConfiguration(final String databaseName, final MetaDataPersistService metaDataPersistService,
- final ContextManagerBuilderParameter parameter) {
+ private DatabaseConfiguration createDatabaseConfiguration(final String databaseName,
+ final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter) {
Map<String, DataSource> dataSources = metaDataPersistService.getEffectiveDataSources(databaseName, parameter.getDatabaseConfigs());
Collection<RuleConfiguration> databaseRuleConfigs = metaDataPersistService.getDatabaseRulePersistService().load(databaseName);
return new DataSourceProvidedDatabaseConfiguration(dataSources, databaseRuleConfigs);
@@ -108,9 +108,8 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
.forEach((schemaName, tables) -> metaDataContexts.getPersistService().ifPresent(optional -> optional.getSchemaMetaDataService().persistMetaData(databaseName, schemaName, tables))));
}
- private ContextManager createContextManager(final ClusterPersistRepository repository, final RegistryCenter registryCenter,
- final InstanceMetaData instanceMetaData, final MetaDataContexts metaDataContexts,
- final ModeConfiguration modeConfig) {
+ private ContextManager createContextManager(final ClusterPersistRepository repository, final RegistryCenter registryCenter, final InstanceMetaData instanceMetaData,
+ final MetaDataContexts metaDataContexts, final ModeConfiguration modeConfig) {
ClusterWorkerIdGenerator clusterWorkerIdGenerator = new ClusterWorkerIdGenerator(repository, registryCenter, instanceMetaData);
DistributedLockContext distributedLockContext = new DistributedLockContext(repository);
InstanceContext instanceContext = new InstanceContext(new ComputeNodeInstance(instanceMetaData), clusterWorkerIdGenerator, modeConfig, distributedLockContext);
@@ -118,8 +117,8 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
return new ContextManager(metaDataContexts, instanceContext);
}
- private void registerOnline(final MetaDataPersistService metaDataPersistService, final ContextManagerBuilderParameter parameter, final ContextManager contextManager,
- final RegistryCenter registryCenter) {
+ private void registerOnline(final MetaDataPersistService metaDataPersistService,
+ final ContextManagerBuilderParameter parameter, final ContextManager contextManager, final RegistryCenter registryCenter) {
contextManager.getInstanceContext().getInstance().setLabels(parameter.getLabels());
contextManager.getInstanceContext().getComputeNodeInstances().addAll(registryCenter.getComputeNodeStatusService().loadAllComputeNodeInstances());
new ClusterContextManagerCoordinator(metaDataPersistService, contextManager, registryCenter);
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 459a1c73f35..b28f423d9cd 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().getInstanceMetaData().getInstanceId().equals(event.getInstanceId())) {
+ if (contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId().equals(event.getInstanceId())) {
contextManager.getInstanceContext().updateWorkerId(event.getWorkerId());
}
}
@@ -281,7 +281,7 @@ public final class ClusterContextManagerCoordinator {
*/
@Subscribe
public synchronized void triggerShowProcessList(final ShowProcessListTriggerEvent event) {
- if (!event.getInstanceId().equals(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId())) {
+ if (!event.getInstanceId().equals(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId())) {
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/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 c3109715a1a..e5dbf653742 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.getInstanceMetaData().getInstanceId())) {
+ if (!lockedInstances.contains(each.getInstanceMetaData().getId())) {
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/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 e09473f9a20..e311a4e9a0f 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
@@ -49,7 +49,7 @@ public final class ComputeNodeStatusService {
* @param instanceMetaData instance definition
*/
public void registerOnline(final InstanceMetaData instanceMetaData) {
- repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(instanceMetaData.getInstanceId(), instanceMetaData.getInstanceType()), instanceMetaData.getAttributes());
+ repository.persistEphemeral(ComputeNode.getOnlineInstanceNodePath(instanceMetaData.getId(), instanceMetaData.getType()), instanceMetaData.getAttributes());
}
/**
@@ -141,9 +141,9 @@ public final class ComputeNodeStatusService {
*/
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);
+ result.setLabels(loadInstanceLabels(instanceMetaData.getId()));
+ result.switchState(loadInstanceStatus(instanceMetaData.getId()));
+ loadInstanceWorkerId(instanceMetaData.getId()).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/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 577b8208426..ec032a0471f 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
@@ -40,12 +40,12 @@ public final class ClusterWorkerIdGenerator implements WorkerIdGenerator {
@Override
public long generate() {
- return registryCenter.getComputeNodeStatusService().loadInstanceWorkerId(instanceMetaData.getInstanceId()).orElseGet(this::reGenerate);
+ return registryCenter.getComputeNodeStatusService().loadInstanceWorkerId(instanceMetaData.getId()).orElseGet(this::reGenerate);
}
private Long reGenerate() {
- Long result = Long.valueOf(Optional.ofNullable(repository.getSequentialId(WorkerIdNode.getWorkerIdGeneratorPath(instanceMetaData.getInstanceId()), "")).orElse("0"));
- registryCenter.getComputeNodeStatusService().persistInstanceWorkerId(instanceMetaData.getInstanceId(), result);
+ Long result = Long.valueOf(Optional.ofNullable(repository.getSequentialId(WorkerIdNode.getWorkerIdGeneratorPath(instanceMetaData.getId()), "")).orElse("0"));
+ registryCenter.getComputeNodeStatusService().persistInstanceWorkerId(instanceMetaData.getId(), 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 4d8f9005649..64859cc5f84 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
@@ -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().getInstanceMetaData().getInstanceId(), testStates);
+ StateEvent mockStateEvent = new StateEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId(), 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().getInstanceMetaData().getInstanceId(), 12223L);
+ WorkerIdEvent mockWorkerIdEvent = new WorkerIdEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId(), 12223L);
coordinator.renew(mockWorkerIdEvent);
assertThat(contextManager.getInstanceContext().getWorkerId(), is(12223L));
}
@@ -309,7 +309,7 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertRenewInstanceLabels() {
Collection<String> labels = Collections.singleton("test");
- coordinator.renew(new LabelsEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId(), labels));
+ coordinator.renew(new LabelsEvent(contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId(), labels));
assertThat(contextManager.getInstanceContext().getInstance().getLabels(), is(labels));
}
@@ -372,7 +372,7 @@ public final class ClusterContextManagerCoordinatorTest {
@Test
public void assertTriggerShowProcessList() throws NoSuchFieldException, IllegalAccessException {
- String instanceId = contextManager.getInstanceContext().getInstance().getInstanceMetaData().getInstanceId();
+ String instanceId = contextManager.getInstanceContext().getInstance().getInstanceMetaData().getId();
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/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 79c1aa2ce63..3fe67e38a04 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
@@ -50,14 +50,14 @@ public final class ComputeNodeStatusServiceTest {
public void assertRegisterOnline() {
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());
+ verify(repository).persistEphemeral(eq("/nodes/compute_nodes/online/proxy/" + instanceMetaData.getId()), anyString());
}
@Test
public void assertPersistInstanceLabels() {
ComputeNodeStatusService computeNodeStatusService = new ComputeNodeStatusService(repository);
InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
- final String instanceId = instanceMetaData.getInstanceId();
+ final String instanceId = instanceMetaData.getId();
computeNodeStatusService.persistInstanceLabels(instanceId, Collections.singletonList("test"));
verify(repository, times(1)).persistEphemeral(ComputeNode.getInstanceLabelsNodePath(instanceId), YamlEngine.marshal(Collections.singletonList("test")));
computeNodeStatusService.persistInstanceLabels(instanceId, Collections.emptyList());
@@ -67,7 +67,7 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertPersistInstanceWorkerId() {
InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
- final String instanceId = instanceMetaData.getInstanceId();
+ final String instanceId = instanceMetaData.getId();
new ComputeNodeStatusService(repository).persistInstanceWorkerId(instanceId, 100L);
verify(repository).persistEphemeral(ComputeNode.getInstanceWorkerIdNodePath(instanceId), String.valueOf(100L));
}
@@ -75,7 +75,7 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertLoadInstanceLabels() {
InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
- final String instanceId = instanceMetaData.getInstanceId();
+ final String instanceId = instanceMetaData.getId();
new ComputeNodeStatusService(repository).loadInstanceLabels(instanceId);
verify(repository).get(ComputeNode.getInstanceLabelsNodePath(instanceId));
}
@@ -83,7 +83,7 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertLoadInstanceStatus() {
InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
- final String instanceId = instanceMetaData.getInstanceId();
+ final String instanceId = instanceMetaData.getId();
new ComputeNodeStatusService(repository).loadInstanceStatus(instanceId);
verify(repository).get(ComputeNode.getInstanceStatusNodePath(instanceId));
}
@@ -91,7 +91,7 @@ public final class ComputeNodeStatusServiceTest {
@Test
public void assertLoadInstanceWorkerId() {
InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3307);
- final String instanceId = instanceMetaData.getInstanceId();
+ final String instanceId = instanceMetaData.getId();
new ComputeNodeStatusService(repository).loadInstanceWorkerId(instanceId);
verify(repository).get(ComputeNode.getInstanceWorkerIdNodePath(instanceId));
}
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 b9d90649a00..cd4b492d3e6 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().getInstanceMetaData().getInstanceType()), instanceContext.getInstance().getInstanceMetaData().getAttributes());
+ instanceContext.getInstance().getInstanceMetaData().getType()), instanceContext.getInstance().getInstanceMetaData().getAttributes());
return true;
}
sleepInterval();
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 833f60aff56..ca766171fb2 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
@@ -61,14 +61,14 @@ 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.getInstanceMetaData().getInstanceType()).collect(Collectors.toList());
+ .filter(each -> InstanceType.PROXY == each.getInstanceMetaData().getType()).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());
InstanceMetaData instanceMetaData = instance.getInstanceMetaData();
- return new LocalDataQueryResultRow(instanceMetaData.getInstanceId(), instanceMetaData.getIp(),
+ return new LocalDataQueryResultRow(instanceMetaData.getId(), 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 779f4cfcfde..38acea60a0b 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().getInstanceMetaData().getInstanceId();
+ String instanceId = instanceContext.getInstance().getInstanceMetaData().getId();
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/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 8d6c50f3e04..eb833aed106 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().getInstanceMetaData().getInstanceId()).thenReturn("127.0.0.1@3309");
+ when(result.getInstance().getInstanceMetaData().getId()).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;