You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/02/07 10:02:40 UTC
(shardingsphere) branch master updated: Refactor show processlist and kill logic (#30049)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 f836403747b Refactor show processlist and kill logic (#30049)
f836403747b is described below
commit f836403747b39af4ef94e0894618037e616dda06
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Feb 7 18:02:34 2024 +0800
Refactor show processlist and kill logic (#30049)
---
.../infra/executor/sql/process/Process.java | 18 ++++++++++++++++++
.../sql/process/yaml/swapper/YamlProcessSwapper.java | 2 +-
.../subscriber/NewProcessListChangedSubscriber.java | 2 +-
.../subscriber/ProcessListChangedSubscriber.java | 2 +-
.../subscriber/ProcessListChangedSubscriberTest.java | 2 +-
5 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java
index dce76230e60..13cdc11ac93 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/Process.java
@@ -126,6 +126,24 @@ public final class Process {
return completedUnitCount.get();
}
+ /**
+ * Get interrupted.
+ *
+ * @return interrupted
+ */
+ public boolean getInterrupted() {
+ return interrupted.get();
+ }
+
+ /**
+ * Set interrupted.
+ *
+ * @param interrupted interrupted
+ */
+ public void setInterrupted(final boolean interrupted) {
+ this.interrupted.set(interrupted);
+ }
+
/**
* Get process statements.
*
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/yaml/swapper/YamlProcessSwapper.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/yaml/swapper/YamlProcessSwapper.java
index d733859f855..2606086904c 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/yaml/swapper/YamlProcessSwapper.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/yaml/swapper/YamlProcessSwapper.java
@@ -42,7 +42,7 @@ public final class YamlProcessSwapper implements YamlConfigurationSwapper<YamlPr
result.setCompletedUnitCount(data.getCompletedUnitCount());
result.setIdle(data.isIdle());
result.setHeldByConnection(data.isHeldByConnection());
- result.setInterrupted(data.getInterrupted().get());
+ result.setInterrupted(data.getInterrupted());
return result;
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/NewProcessListChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/NewProcessListChangedSubscriber.java
index f927464bf73..64cd1d938a5 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/NewProcessListChangedSubscriber.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/NewProcessListChangedSubscriber.java
@@ -95,7 +95,7 @@ public final class NewProcessListChangedSubscriber {
}
Process process = ProcessRegistry.getInstance().get(event.getProcessId());
if (null != process) {
- process.getInterrupted().set(true);
+ process.setInterrupted(true);
for (Statement each : process.getProcessStatements()) {
each.cancel();
}
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriber.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriber.java
index 18ac44232ec..6efd5045f0c 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriber.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriber.java
@@ -94,7 +94,7 @@ public final class ProcessListChangedSubscriber {
}
Process process = ProcessRegistry.getInstance().get(event.getProcessId());
if (null != process) {
- process.getInterrupted().set(true);
+ process.setInterrupted(true);
for (Statement each : process.getProcessStatements()) {
each.cancel();
}
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriberTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriberTest.java
index 7dd15982013..74ea27249a3 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriberTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/process/subscriber/ProcessListChangedSubscriberTest.java
@@ -111,7 +111,7 @@ class ProcessListChangedSubscriberTest {
Process process = mock(Process.class);
String processId = "foo_id";
when(process.getId()).thenReturn(processId);
- when(process.getInterrupted()).thenReturn(new AtomicBoolean());
+ when(process.getInterrupted()).thenReturn(false);
ProcessRegistry.getInstance().add(process);
String instanceId = contextManager.getInstanceContext().getInstance().getMetaData().getId();
subscriber.reportLocalProcesses(new ReportLocalProcessesEvent(instanceId, processId));