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 2023/05/03 14:29:29 UTC
[shardingsphere] branch master updated: Remove ProcessReporterCleaner (#25442)
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 bf737ae741a Remove ProcessReporterCleaner (#25442)
bf737ae741a is described below
commit bf737ae741aaa0dfedeec835b53ee96ebc31839d
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed May 3 22:29:20 2023 +0800
Remove ProcessReporterCleaner (#25442)
---
.../infra/executor/sql/process/ProcessContext.java | 23 +++++----------
.../infra/executor/sql/process/ProcessEngine.java | 11 ++++---
.../sql/process/ProcessReporterCleaner.java | 34 ----------------------
.../sql/process/DriverProcessReporterCleaner.java | 33 ---------------------
...fra.executor.sql.process.ProcessReporterCleaner | 18 ------------
.../sql/process/ProxyProcessReporterCleaner.java | 32 --------------------
...fra.executor.sql.process.ProcessReporterCleaner | 18 ------------
7 files changed, 12 insertions(+), 157 deletions(-)
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessContext.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessContext.java
index b3331f38456..b685744fef8 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessContext.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessContext.java
@@ -37,6 +37,10 @@ public final class ProcessContext {
private final String id;
+ private final long startMillis;
+
+ private final String sql;
+
private final String databaseName;
private final String username;
@@ -49,11 +53,7 @@ public final class ProcessContext {
private final AtomicInteger completedUnitCount;
- private volatile String sql;
-
- private volatile long startMillis;
-
- private volatile boolean idle;
+ private final boolean idle;
public ProcessContext(final ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext) {
this("", executionGroupContext, true);
@@ -65,6 +65,8 @@ public final class ProcessContext {
private ProcessContext(final String sql, final ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext, final boolean idle) {
id = executionGroupContext.getReportContext().getProcessID();
+ startMillis = System.currentTimeMillis();
+ this.sql = sql;
databaseName = executionGroupContext.getReportContext().getDatabaseName();
Grantee grantee = executionGroupContext.getReportContext().getGrantee();
username = null == grantee ? null : grantee.getUsername();
@@ -72,8 +74,6 @@ public final class ProcessContext {
totalUnitCount = executionGroupContext.getInputGroups().stream().mapToInt(each -> each.getInputs().size()).sum();
processStatements = getProcessStatements(executionGroupContext);
completedUnitCount = new AtomicInteger(0);
- this.sql = sql;
- startMillis = System.currentTimeMillis();
this.idle = idle;
}
@@ -104,13 +104,4 @@ public final class ProcessContext {
public int getCompletedUnitCount() {
return completedUnitCount.get();
}
-
- /**
- * Reset.
- */
- public void reset() {
- sql = "";
- startMillis = System.currentTimeMillis();
- idle = true;
- }
}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java
index 10a322445df..00681c1f1ce 100644
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java
+++ b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessEngine.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupConte
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupReportContext;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutionUnit;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement;
@@ -90,13 +89,13 @@ public final class ProcessEngine {
if (ProcessIDContext.isEmpty()) {
return;
}
- ProcessContext context = ProcessRegistry.getInstance().getProcessContext(ProcessIDContext.get());
- if (null == context) {
+ ProcessContext processContext = ProcessRegistry.getInstance().getProcessContext(ProcessIDContext.get());
+ if (null == processContext) {
return;
}
- for (ProcessReporterCleaner each : ShardingSphereServiceLoader.getServiceInstances(ProcessReporterCleaner.class)) {
- each.reset(context);
- }
+ ExecutionGroupContext<? extends SQLExecutionUnit> executionGroupContext = new ExecutionGroupContext<>(
+ Collections.emptyList(), new ExecutionGroupReportContext(processContext.getDatabaseName(), new Grantee(processContext.getUsername(), processContext.getHostname())));
+ ProcessRegistry.getInstance().putProcessContext(ProcessIDContext.get(), new ProcessContext(executionGroupContext));
ProcessIDContext.remove();
}
diff --git a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessReporterCleaner.java b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessReporterCleaner.java
deleted file mode 100644
index 6b7ff6dba91..00000000000
--- a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/process/ProcessReporterCleaner.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.executor.sql.process;
-
-import org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
-
-/**
- * Process reporter cleaner.
- */
-@SingletonSPI
-public interface ProcessReporterCleaner {
-
- /**
- * Reset reporter.
- *
- * @param context process context
- */
- void reset(ProcessContext context);
-}
diff --git a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/sql/process/DriverProcessReporterCleaner.java b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/sql/process/DriverProcessReporterCleaner.java
deleted file mode 100644
index a8098d66827..00000000000
--- a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/executor/sql/process/DriverProcessReporterCleaner.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.driver.executor.sql.process;
-
-import org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner;
-import org.apache.shardingsphere.infra.executor.sql.process.ProcessRegistry;
-import org.apache.shardingsphere.infra.executor.sql.process.ProcessContext;
-
-/**
- * Process reporter cleaner for driver.
- */
-public final class DriverProcessReporterCleaner implements ProcessReporterCleaner {
-
- @Override
- public void reset(final ProcessContext context) {
- ProcessRegistry.getInstance().removeProcessContext(context.getId());
- }
-}
diff --git a/jdbc/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner b/jdbc/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner
deleted file mode 100644
index 5bb58d66c04..00000000000
--- a/jdbc/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.driver.executor.sql.process.DriverProcessReporterCleaner
diff --git a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/executor/sql/process/ProxyProcessReporterCleaner.java b/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/executor/sql/process/ProxyProcessReporterCleaner.java
deleted file mode 100644
index f6b3203df35..00000000000
--- a/proxy/bootstrap/src/main/java/org/apache/shardingsphere/proxy/executor/sql/process/ProxyProcessReporterCleaner.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.executor.sql.process;
-
-import org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner;
-import org.apache.shardingsphere.infra.executor.sql.process.ProcessContext;
-
-/**
- * Process reporter cleaner for proxy.
- */
-public final class ProxyProcessReporterCleaner implements ProcessReporterCleaner {
-
- @Override
- public void reset(final ProcessContext context) {
- context.reset();
- }
-}
diff --git a/proxy/bootstrap/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner b/proxy/bootstrap/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner
deleted file mode 100644
index 42d2e2d77e1..00000000000
--- a/proxy/bootstrap/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.process.ProcessReporterCleaner
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.proxy.executor.sql.process.ProxyProcessReporterCleaner