diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java index 1ef7e83414bb7..4a3c708246170 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContext.java @@ -17,12 +17,10 @@ package org.apache.shardingsphere.infra.instance; -import com.google.common.base.Preconditions; import lombok.AccessLevel; import lombok.Getter; import org.apache.shardingsphere.infra.config.mode.ModeConfiguration; -import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData; -import org.apache.shardingsphere.infra.instance.metadata.InstanceType; +import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions; import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator; import org.apache.shardingsphere.infra.lock.LockContext; import org.apache.shardingsphere.infra.state.instance.InstanceState; @@ -30,8 +28,6 @@ import javax.annotation.concurrent.ThreadSafe; import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.Optional; import java.util.Properties; import java.util.concurrent.CopyOnWriteArrayList; @@ -51,17 +47,15 @@ public final class ComputeNodeInstanceContext { private final ModeConfiguration modeConfiguration; - @SuppressWarnings("rawtypes") @Getter(AccessLevel.NONE) - private final AtomicReference lockContext = new AtomicReference<>(); + private final AtomicReference> lockContext = new AtomicReference<>(); private final EventBusContext eventBusContext; private final Collection allClusterInstances = new CopyOnWriteArrayList<>(); - @SuppressWarnings("rawtypes") public ComputeNodeInstanceContext(final ComputeNodeInstance instance, final WorkerIdGenerator workerIdGenerator, - final ModeConfiguration modeConfig, final LockContext lockContext, final EventBusContext eventBusContext) { + final ModeConfiguration modeConfig, final LockContext lockContext, final EventBusContext eventBusContext) { this.instance = instance; this.workerIdGenerator.set(workerIdGenerator); this.modeConfiguration = modeConfig; @@ -79,8 +73,7 @@ public ComputeNodeInstanceContext(final ComputeNodeInstance instance, final Mode * @param workerIdGenerator worker id generator * @param lockContext lock context */ - @SuppressWarnings("rawtypes") - public void init(final WorkerIdGenerator workerIdGenerator, final LockContext lockContext) { + public void init(final WorkerIdGenerator workerIdGenerator, final LockContext lockContext) { this.workerIdGenerator.set(workerIdGenerator); this.lockContext.set(lockContext); } @@ -88,77 +81,68 @@ public void init(final WorkerIdGenerator workerIdGenerator, final LockContext lo /** * Update instance status. * - * @param id instance ID + * @param instanceId instance ID * @param status status */ - public void updateStatus(final String id, final String status) { + public void updateStatus(final String instanceId, final String status) { Optional instanceState = InstanceState.get(status); if (!instanceState.isPresent()) { return; } - if (instance.getMetaData().getId().equals(id)) { + if (instance.getMetaData().getId().equals(instanceId)) { instance.switchState(instanceState.get()); } - updateRelatedComputeNodeInstancesStatus(id, instanceState.get()); - } - - private void updateRelatedComputeNodeInstancesStatus(final String instanceId, final InstanceState instanceState) { - for (ComputeNodeInstance each : allClusterInstances) { - if (each.getMetaData().getId().equals(instanceId)) { - each.switchState(instanceState); - } - } + allClusterInstances.stream().filter(each -> each.getMetaData().getId().equals(instanceId)).forEach(each -> each.switchState(instanceState.get())); } /** - * Update instance worker id. + * Update instance labels. * - * @param instanceId instance id - * @param workerId worker id + * @param instanceId instance ID + * @param labels labels */ - public void updateWorkerId(final String instanceId, final Integer workerId) { + public void updateLabels(final String instanceId, final Collection labels) { if (instance.getMetaData().getId().equals(instanceId)) { - instance.setWorkerId(workerId); + updateLabels(instance, labels); } - allClusterInstances.stream().filter(each -> each.getMetaData().getId().equals(instanceId)).forEach(each -> each.setWorkerId(workerId)); + allClusterInstances.stream().filter(each -> each.getMetaData().getId().equals(instanceId)).forEach(each -> updateLabels(each, labels)); + } + + private void updateLabels(final ComputeNodeInstance computeNodeInstance, final Collection labels) { + computeNodeInstance.getLabels().clear(); + computeNodeInstance.getLabels().addAll(labels); } /** - * Update instance label. + * Update instance worker ID. * - * @param instanceId instance id - * @param labels collection of label + * @param instanceId instance ID + * @param workerId worker ID */ - public void updateLabel(final String instanceId, final Collection labels) { + public void updateWorkerId(final String instanceId, final Integer workerId) { if (instance.getMetaData().getId().equals(instanceId)) { - instance.getLabels().clear(); - instance.getLabels().addAll(labels); - } - for (ComputeNodeInstance each : allClusterInstances) { - if (each.getMetaData().getId().equals(instanceId)) { - each.getLabels().clear(); - each.getLabels().addAll(labels); - } + instance.setWorkerId(workerId); } + allClusterInstances.stream().filter(each -> each.getMetaData().getId().equals(instanceId)).forEach(each -> each.setWorkerId(workerId)); } /** - * Get worker id. + * Get worker ID. * - * @return worker id + * @return worker ID */ public int getWorkerId() { return instance.getWorkerId(); } /** - * Generate worker id. + * Generate worker ID. * * @param props properties - * @return worker id + * @return worker ID */ public int generateWorkerId(final Properties props) { - Preconditions.checkArgument(workerIdGenerator.get() != null, "Worker id generator is not initialized."); + ShardingSpherePreconditions.checkNotNull(workerIdGenerator.get(), () -> new IllegalArgumentException("Worker id generator is not initialized.")); int result = workerIdGenerator.get().generate(props); instance.setWorkerId(result); return result; @@ -184,26 +168,9 @@ public void deleteComputeNodeInstance(final ComputeNodeInstance instance) { } /** - * Get compute node instances by instance type and labels. - * - * @param instanceType instance type - * @param labels collection of contained label - * @return compute node instances - */ - public Map getAllClusterInstances(final InstanceType instanceType, final Collection labels) { - Map result = new LinkedHashMap<>(allClusterInstances.size(), 1F); - for (ComputeNodeInstance each : allClusterInstances) { - if (each.getMetaData().getType() == instanceType && labels.stream().anyMatch(each.getLabels()::contains)) { - result.put(each.getMetaData().getId(), each.getMetaData()); - } - } - return result; - } - - /** - * Get compute node instance by instance id. + * Get compute node instance. * - * @param instanceId instance id + * @param instanceId instance ID * @return compute node instance */ public Optional getComputeNodeInstanceById(final String instanceId) { @@ -216,8 +183,7 @@ public Optional getComputeNodeInstanceById(final String ins * @return lock context * @throws IllegalStateException if lock context is not initialized */ - @SuppressWarnings("rawtypes") - public LockContext getLockContext() throws IllegalStateException { + public LockContext getLockContext() throws IllegalStateException { return Optional.ofNullable(lockContext.get()).orElseThrow(() -> new IllegalStateException("Lock context is not initialized.")); } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContextTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContextTest.java index ce2eadeffd8ea..dfffac5f40bae 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContextTest.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/instance/ComputeNodeInstanceContextTest.java @@ -19,6 +19,7 @@ import org.apache.shardingsphere.infra.config.mode.ModeConfiguration; import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData; +import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData; import org.apache.shardingsphere.infra.instance.workerid.WorkerIdGenerator; import org.apache.shardingsphere.infra.lock.LockContext; import org.apache.shardingsphere.infra.state.instance.InstanceState; @@ -26,85 +27,128 @@ import org.junit.jupiter.api.Test; import java.util.Arrays; -import java.util.Collection; +import java.util.Optional; import java.util.Properties; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; class ComputeNodeInstanceContextTest { - private final ModeConfiguration modeConfig = new ModeConfiguration("Standalone", null); - - private final LockContext lockContext = mock(LockContext.class); - - private final EventBusContext eventBusContext = new EventBusContext(); + @Test + void assertInit() { + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(ModeConfiguration.class), new EventBusContext()); + WorkerIdGenerator workerIdGenerator = mock(WorkerIdGenerator.class); + LockContext lockContext = mock(LockContext.class); + context.init(workerIdGenerator, lockContext); + context.generateWorkerId(new Properties()); + verify(workerIdGenerator).generate(new Properties()); + assertThat(context.getLockContext(), is(lockContext)); + } @Test - void assertUpdateComputeNodeState() { + void assertUpdateStatusWithInvalidInstanceState() { InstanceMetaData instanceMetaData = mock(InstanceMetaData.class); - when(instanceMetaData.getId()).thenReturn("foo_instance_id"); ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( - new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - InstanceState actual = context.getInstance().getState().getCurrentState(); - assertThat(actual, is(InstanceState.OK)); - context.updateStatus(instanceMetaData.getId(), InstanceState.CIRCUIT_BREAK.name()); - actual = context.getInstance().getState().getCurrentState(); - assertThat(actual, is(InstanceState.CIRCUIT_BREAK)); - context.updateStatus(instanceMetaData.getId(), InstanceState.OK.name()); - actual = context.getInstance().getState().getCurrentState(); - assertThat(actual, is(InstanceState.OK)); + new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.updateStatus("id", "INVALID"); + verify(instanceMetaData, times(0)).getId(); } @Test - void assertGetWorkerId() { - ComputeNodeInstance computeNodeInstance = mock(ComputeNodeInstance.class); - when(computeNodeInstance.getWorkerId()).thenReturn(0); - ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(computeNodeInstance, mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - assertThat(context.getWorkerId(), is(0)); + void assertUpdateStatusWithCurrentInstance() { + InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3306); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( + new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + context.updateStatus("foo_instance_id", InstanceState.CIRCUIT_BREAK.name()); + assertThat(context.getInstance().getState().getCurrentState(), is(InstanceState.CIRCUIT_BREAK)); } @Test - void assertGenerateWorkerId() { + void assertUpdateStatusWithOtherInstance() { + InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3306); ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( - new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - assertThat(context.generateWorkerId(new Properties()), is(0)); + new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + context.updateStatus("bar_instance_id", InstanceState.CIRCUIT_BREAK.name()); + assertThat(context.getInstance().getState().getCurrentState(), is(InstanceState.OK)); } @Test - void assertUpdateLabel() { - InstanceMetaData instanceMetaData = mock(InstanceMetaData.class); - when(instanceMetaData.getId()).thenReturn("foo_instance_id"); + void assertUpdateLabelsWithCurrentInstance() { + InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3306); ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( - new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - Collection expected = Arrays.asList("label_1", "label_2"); - context.updateLabel("foo_instance_id", expected); - Collection actual = context.getInstance().getLabels(); - assertThat(actual, is(expected)); + new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.updateLabels("foo_instance_id", Arrays.asList("label_1", "label_2")); + assertThat(context.getInstance().getLabels(), is(Arrays.asList("label_1", "label_2"))); } @Test - void assertGetInstance() { - ComputeNodeInstance expected = new ComputeNodeInstance(mock(InstanceMetaData.class)); - ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(expected, mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - ComputeNodeInstance actual = context.getInstance(); - assertThat(actual, is(expected)); + void assertUpdateLabelsWithOtherInstance() { + InstanceMetaData instanceMetaData = new ProxyInstanceMetaData("foo_instance_id", 3306); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( + new ComputeNodeInstance(instanceMetaData), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + context.updateLabels("bar_instance_id", Arrays.asList("label_1", "label_2")); + assertTrue(context.getInstance().getLabels().isEmpty()); + assertThat(context.getAllClusterInstances().iterator().next().getLabels(), is(Arrays.asList("label_1", "label_2"))); } @Test - void assertGetState() { - ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( - new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - assertNotNull(context.getInstance().getState()); + void assertUpdateWorkerIdWithCurrentInstance() { + ComputeNodeInstance instance = new ComputeNodeInstance(new ProxyInstanceMetaData("foo_instance_id", 3306)); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(instance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.updateWorkerId("foo_instance_id", 10); + assertThat(context.getWorkerId(), is(10)); + } + + @Test + void assertUpdateWorkerIdWithOtherInstance() { + ComputeNodeInstance instance = new ComputeNodeInstance(new ProxyInstanceMetaData("foo_instance_id", 3306)); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(instance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + context.updateWorkerId("bar_instance_id", 10); + assertThat(context.getWorkerId(), is(-1)); + assertThat(context.getAllClusterInstances().iterator().next().getWorkerId(), is(10)); } @Test - void assertGetModeConfiguration() { + void assertGenerateWorkerId() { ComputeNodeInstanceContext context = new ComputeNodeInstanceContext( - new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(WorkerIdGenerator.class), modeConfig, lockContext, eventBusContext); - assertThat(context.getModeConfiguration(), is(modeConfig)); + new ComputeNodeInstance(mock(InstanceMetaData.class)), mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + assertThat(context.generateWorkerId(new Properties()), is(0)); + } + + @Test + void assertAddComputeNodeInstance() { + ComputeNodeInstance instance = new ComputeNodeInstance(new ProxyInstanceMetaData("foo_instance_id", 3306)); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(instance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + assertFalse(context.getAllClusterInstances().isEmpty()); + } + + @Test + void assertDeleteComputeNodeInstance() { + ComputeNodeInstance instance = new ComputeNodeInstance(new ProxyInstanceMetaData("foo_instance_id", 3306)); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(instance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + context.deleteComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + assertTrue(context.getAllClusterInstances().isEmpty()); + } + + @Test + void assertGetComputeNodeInstanceById() { + ComputeNodeInstance instance = new ComputeNodeInstance(new ProxyInstanceMetaData("foo_instance_id", 3306)); + ComputeNodeInstanceContext context = new ComputeNodeInstanceContext(instance, mock(WorkerIdGenerator.class), mock(ModeConfiguration.class), mock(LockContext.class), new EventBusContext()); + context.addComputeNodeInstance(new ComputeNodeInstance(new ProxyInstanceMetaData("bar_instance_id", 3307))); + Optional actual = context.getComputeNodeInstanceById("bar_instance_id"); + assertTrue(actual.isPresent()); + assertThat(actual.get().getMetaData().getId(), is("bar_instance_id")); } } diff --git a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/connector/url/JdbcUrlAppender.java b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/connector/url/JdbcUrlAppender.java index 7bf216843c48d..dc3a2f37f22d9 100644 --- a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/connector/url/JdbcUrlAppender.java +++ b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/connector/url/JdbcUrlAppender.java @@ -37,10 +37,10 @@ public final class JdbcUrlAppender { * @return appended JDBC URL */ public String appendQueryProperties(final String jdbcUrl, final Properties queryProps) { - Properties currentQueryProps = DatabaseTypedSPILoader.getService(ConnectionPropertiesParser.class, DatabaseTypeFactory.get(jdbcUrl)).parse(jdbcUrl, null, null).getQueryProperties(); if (queryProps.isEmpty()) { return jdbcUrl; } + Properties currentQueryProps = DatabaseTypedSPILoader.getService(ConnectionPropertiesParser.class, DatabaseTypeFactory.get(jdbcUrl)).parse(jdbcUrl, null, null).getQueryProperties(); return hasConflictedQueryProperties(currentQueryProps, queryProps) ? jdbcUrl.substring(0, jdbcUrl.indexOf('?') + 1) + concat(getMergedProperties(currentQueryProps, queryProps)) : jdbcUrl + getURLDelimiter(currentQueryProps) + concat(queryProps); diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java index f6f856666ebb9..6334f9e03b10c 100644 --- a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java +++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java @@ -21,8 +21,6 @@ import org.apache.shardingsphere.infra.database.core.DefaultDatabase; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode; -import org.apache.shardingsphere.infra.instance.metadata.InstanceType; -import org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData; import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.metadata.persist.MetaDataPersistService; @@ -67,8 +65,6 @@ private ContextManager mockContextManager() throws SQLException { MetaDataPersistService persistService = mockMetaDataPersistService(); when(result.getPersistServiceFacade().getMetaDataPersistService()).thenReturn(persistService); when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(mock(TransactionRule.class, RETURNS_DEEP_STUBS)))); - when(result.getComputeNodeInstanceContext().getAllClusterInstances(InstanceType.PROXY, Arrays.asList("OLTP", "OLAP"))).thenReturn( - Collections.singletonMap("foo_id", new ProxyInstanceMetaData("foo_id", "127.0.0.1@3307", "foo_version"))); return result; } diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriber.java index e00ed827f900b..6d661330cb908 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriber.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriber.java @@ -86,6 +86,6 @@ public synchronized void renew(final WorkerIdEvent event) { @Subscribe public synchronized void renew(final LabelsEvent event) { // TODO labels may be empty - contextManager.getComputeNodeInstanceContext().updateLabel(event.getInstanceId(), event.getLabels()); + contextManager.getComputeNodeInstanceContext().updateLabels(event.getInstanceId(), event.getLabels()); } } diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriberTest.java index 9ed424f0f8abe..95d8b8ad677e6 100644 --- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriberTest.java +++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/event/subscriber/dispatch/ComputeNodeStateSubscriberTest.java @@ -82,6 +82,6 @@ void assertRenewWithWorkerIdEvent() { @Test void assertRenewWithLabelsEvent() { subscriber.renew(new LabelsEvent("foo_instance_id", Collections.emptyList())); - verify(contextManager.getComputeNodeInstanceContext()).updateLabel("foo_instance_id", Collections.emptyList()); + verify(contextManager.getComputeNodeInstanceContext()).updateLabels("foo_instance_id", Collections.emptyList()); } }