This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 69553a27be1 Remove useless cluster mode check when using
DistSQLExecutorClusterModeRequired (#34999)
69553a27be1 is described below
commit 69553a27be104279de1c798d43c4fc0f31180cbd
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Mar 15 14:47:04 2025 +0800
Remove useless cluster mode check when using
DistSQLExecutorClusterModeRequired (#34999)
* Remove useless cluster mode check when using
DistSQLExecutorClusterModeRequired on
* Remove useless cluster mode check when using
DistSQLExecutorClusterModeRequired
---
.../global/node/compute/type/ComputeNodeOnlineHandlerTest.java | 7 ++++---
.../ral/updatable/computenode/SetComputeNodeStateExecutor.java | 7 ++-----
.../distsql/ral/updatable/label/LabelComputeNodeExecutor.java | 3 ---
.../distsql/ral/updatable/label/UnlabelComputeNodeExecutor.java | 3 ---
4 files changed, 6 insertions(+), 14 deletions(-)
diff --git
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/node/compute/type/ComputeNodeOnlineHandlerTest.java
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/node/compute/type/ComputeNodeOnlineHandlerTest.java
index 777e00b3938..375dbe9aa9d 100644
---
a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/node/compute/type/ComputeNodeOnlineHandlerTest.java
+++
b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/global/node/compute/type/ComputeNodeOnlineHandlerTest.java
@@ -33,7 +33,6 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -47,10 +46,14 @@ class ComputeNodeOnlineHandlerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ContextManager contextManager;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private ClusterPersistServiceFacade clusterPersistServiceFacade;
+
@BeforeEach
void setUp() {
handler =
ShardingSphereServiceLoader.getServiceInstances(GlobalDataChangedEventHandler.class).stream()
.filter(each ->
NodePathGenerator.toPath(each.getSubscribedNodePath()).equals("/nodes/compute_nodes/online")).findFirst().orElse(null);
+
when(contextManager.getPersistServiceFacade().getModeFacade()).thenReturn(clusterPersistServiceFacade);
}
@Test
@@ -62,9 +65,7 @@ class ComputeNodeOnlineHandlerTest {
@Test
void assertHandleWithInstanceOnlineEvent() {
ComputeNodeInstance computeNodeInstance =
mock(ComputeNodeInstance.class);
- ClusterPersistServiceFacade clusterPersistServiceFacade =
mock(ClusterPersistServiceFacade.class, RETURNS_DEEP_STUBS);
when(clusterPersistServiceFacade.getComputeNodeService().loadInstance(any())).thenReturn(computeNodeInstance);
-
when(contextManager.getPersistServiceFacade().getModeFacade()).thenReturn(clusterPersistServiceFacade);
handler.handle(contextManager, new
DataChangedEvent("/nodes/compute_nodes/online/proxy/foo_instance_id",
"{attribute: 127.0.0.1@3307,version: 1}", Type.ADDED));
verify(contextManager.getComputeNodeInstanceContext().getClusterInstanceRegistry()).add(computeNodeInstance);
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
index e6f2c3f003d..d830feda13b 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/computenode/SetComputeNodeStateExecutor.java
@@ -39,11 +39,8 @@ public final class SetComputeNodeStateExecutor implements
DistSQLUpdateExecutor<
} else {
checkEnablingIsValid(contextManager, sqlStatement.getInstanceId());
}
- if
(contextManager.getComputeNodeInstanceContext().getModeConfiguration().isCluster())
{
- ClusterPersistServiceFacade clusterPersistServiceFacade =
(ClusterPersistServiceFacade)
contextManager.getPersistServiceFacade().getModeFacade();
-
clusterPersistServiceFacade.getComputeNodeService().updateState(sqlStatement.getInstanceId(),
- "DISABLE".equals(sqlStatement.getState()) ?
InstanceState.CIRCUIT_BREAK : InstanceState.OK);
- }
+ ClusterPersistServiceFacade clusterPersistServiceFacade =
(ClusterPersistServiceFacade)
contextManager.getPersistServiceFacade().getModeFacade();
+
clusterPersistServiceFacade.getComputeNodeService().updateState(sqlStatement.getInstanceId(),
"DISABLE".equals(sqlStatement.getState()) ? InstanceState.CIRCUIT_BREAK :
InstanceState.OK);
}
private void checkEnablingIsValid(final ContextManager contextManager,
final String instanceId) {
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/LabelComputeNodeExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/LabelComputeNodeExecutor.java
index 7504c9f0487..4babb77f8d5 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/LabelComputeNodeExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/LabelComputeNodeExecutor.java
@@ -38,9 +38,6 @@ public final class LabelComputeNodeExecutor implements
DistSQLUpdateExecutor<Lab
@Override
public void executeUpdate(final LabelComputeNodeStatement sqlStatement,
final ContextManager contextManager) throws SQLException {
- if
(!contextManager.getComputeNodeInstanceContext().getModeConfiguration().isCluster())
{
- return;
- }
String instanceId = sqlStatement.getInstanceId();
Optional<ComputeNodeInstance> computeNodeInstance =
contextManager.getComputeNodeInstanceContext().getClusterInstanceRegistry().find(instanceId);
if (computeNodeInstance.isPresent()) {
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/UnlabelComputeNodeExecutor.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/UnlabelComputeNodeExecutor.java
index 29df92dceb0..d4af6241d00 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/UnlabelComputeNodeExecutor.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/label/UnlabelComputeNodeExecutor.java
@@ -38,9 +38,6 @@ public final class UnlabelComputeNodeExecutor implements
DistSQLUpdateExecutor<U
@Override
public void executeUpdate(final UnlabelComputeNodeStatement sqlStatement,
final ContextManager contextManager) {
- if
(!contextManager.getComputeNodeInstanceContext().getModeConfiguration().isCluster())
{
- return;
- }
String instanceId = sqlStatement.getInstanceId();
Optional<ComputeNodeInstance> computeNodeInstance =
contextManager.getComputeNodeInstanceContext().getClusterInstanceRegistry().find(instanceId);
if (computeNodeInstance.isPresent()) {