You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/12/10 12:02:10 UTC

[shardingsphere] branch master updated: Rename DataSourceKiller to DataSourceDestroyer (#14044)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 9e9714b  Rename DataSourceKiller to DataSourceDestroyer (#14044)
9e9714b is described below

commit 9e9714b76eb11b703b1a00568ef074bd9d602550
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Dec 10 20:01:31 2021 +0800

    Rename DataSourceKiller to DataSourceDestroyer (#14044)
---
 docs/document/content/dev-manual/data-source.cn.md |  16 +--
 docs/document/content/dev-manual/data-source.en.md |  16 +--
 .../DataSourceDestroyer.java}                      |  74 +++++++-------
 .../DataSourceDestroyerFactory.java}               |  16 +--
 .../impl/DefaultDataSourceDestroyer.java}          | 104 ++++++++++----------
 .../impl/HikariDataSourceDestroyer.java}           | 108 ++++++++++-----------
 .../metadata/resource/ShardingSphereResource.java  |   4 +-
 ...onfig.datasource.destroyer.DataSourceDestroyer} |  38 ++++----
 8 files changed, 188 insertions(+), 188 deletions(-)

diff --git a/docs/document/content/dev-manual/data-source.cn.md b/docs/document/content/dev-manual/data-source.cn.md
index 22e8eab..4ac5f5b 100644
--- a/docs/document/content/dev-manual/data-source.cn.md
+++ b/docs/document/content/dev-manual/data-source.cn.md
@@ -48,13 +48,13 @@ chapter = true
 | DefaultDataSourceCreator | 默认数据源创建器     |
 | HikariDataSourceCreator  | Hikari 数据源创建器 |
 
-## DataSourceKiller
+## DataSourceDestroyer
 
-| *SPI 名称*               | *详细说明*         |
-| ----------------------- | ----------------- |
-| DataSourceKiller        | 数据源销毁器        |
+| *SPI 名称*                  | *详细说明*         |
+| -------------------------- | ----------------- |
+| DataSourceDestroyer        | 数据源销毁器        |
 
-| *已知实现类*              | *详细说明*         |
-| ----------------------- | ----------------- |
-| DefaultDataSourceKiller | 默认数据源销毁器     |
-| HikariDataSourceKiller  | Hikari 数据源销毁器 |
+| *已知实现类*                 | *详细说明*         |
+| -------------------------- | ----------------- |
+| DefaultDataSourceDestroyer | 默认数据源销毁器     |
+| HikariDataSourceDestroyer  | Hikari 数据源销毁器 |
diff --git a/docs/document/content/dev-manual/data-source.en.md b/docs/document/content/dev-manual/data-source.en.md
index 41bc5f2..1255a6b 100644
--- a/docs/document/content/dev-manual/data-source.en.md
+++ b/docs/document/content/dev-manual/data-source.en.md
@@ -48,13 +48,13 @@ chapter = true
 | DefaultDataSourceCreator | Default data source creator |
 | HikariDataSourceCreator  | Hikari data source creator  |
 
-## DataSourceKiller
+## DataSourceDestroyer
 
-| *SPI Name*              | *Description*                |
-| ----------------------- | ---------------------------- |
-| DataSourceKiller        | Default data source killer   |
+| *SPI Name*                 | *Description*                 |
+| -------------------------- | ----------------------------- |
+| DataSourceDestroyer        | Default data source destroyer |
 
-| *Implementation Class*  | *Description*                |
-| ----------------------- | ---------------------------- |
-| DefaultDataSourceKiller | Default data source killer   |
-| HikariDataSourceKiller  | Hikari data source killer    |
+| *Implementation Class*     | *Description*                 |
+| -------------------------- | ----------------------------- |
+| DefaultDataSourceDestroyer | Default data source destroyer |
+| HikariDataSourceDestroyer  | Hikari data source destroyer  |
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKiller.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyer.java
similarity index 79%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKiller.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyer.java
index 79b5054..a7d4b40 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKiller.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyer.java
@@ -1,37 +1,37 @@
-/*
- * 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.config.datasource.killer;
-
-import org.apache.shardingsphere.spi.required.RequiredSPI;
-import org.apache.shardingsphere.spi.typed.TypedSPI;
-import javax.sql.DataSource;
-import java.sql.SQLException;
-
-/**
- * Data source killer.
- */
-public interface DataSourceKiller extends TypedSPI, RequiredSPI {
-    
-    /**
-     * Kill data source gracefully.
-     * 
-     * @param dataSource data source
-     * @throws SQLException SQL exception
-     */
-    void kill(DataSource dataSource) throws SQLException;
-}
+/*
+ * 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.config.datasource.destroyer;
+
+import org.apache.shardingsphere.spi.required.RequiredSPI;
+import org.apache.shardingsphere.spi.typed.TypedSPI;
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+/**
+ * Data source destroyer.
+ */
+public interface DataSourceDestroyer extends TypedSPI, RequiredSPI {
+    
+    /**
+     * destroy data source gracefully.
+     * 
+     * @param dataSource data source
+     * @throws SQLException SQL exception
+     */
+    void destroy(DataSource dataSource) throws SQLException;
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKillerFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyerFactory.java
similarity index 69%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKillerFactory.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyerFactory.java
index 1b38060..d1c117b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/DataSourceKillerFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/DataSourceDestroyerFactory.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.config.datasource.killer;
+package org.apache.shardingsphere.infra.config.datasource.destroyer;
 
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spi.required.RequiredSPIRegistry;
@@ -24,21 +24,21 @@ import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
 import java.util.Properties;
 
 /**
- * Data source killer factory.
+ * Data source destroyer factory.
  */
-public final class DataSourceKillerFactory {
+public final class DataSourceDestroyerFactory {
     
     static {
-        ShardingSphereServiceLoader.register(DataSourceKiller.class);
+        ShardingSphereServiceLoader.register(DataSourceDestroyer.class);
     }
     
     /**
-     * Get data source killer instance.
+     * Get data source destroyer instance.
      * 
      * @param dataSourceClassName data source class name
-     * @return instance of data source killer
+     * @return instance of data source destroyer
      */
-    public static DataSourceKiller getInstance(final String dataSourceClassName) {
-        return TypedSPIRegistry.findRegisteredService(DataSourceKiller.class, dataSourceClassName, new Properties()).orElse(RequiredSPIRegistry.getRegisteredService(DataSourceKiller.class));
+    public static DataSourceDestroyer getInstance(final String dataSourceClassName) {
+        return TypedSPIRegistry.findRegisteredService(DataSourceDestroyer.class, dataSourceClassName, new Properties()).orElse(RequiredSPIRegistry.getRegisteredService(DataSourceDestroyer.class));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/DefaultDataSourceKiller.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/DefaultDataSourceDestroyer.java
similarity index 78%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/DefaultDataSourceKiller.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/DefaultDataSourceDestroyer.java
index f789f49..3c67459 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/DefaultDataSourceKiller.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/DefaultDataSourceDestroyer.java
@@ -1,52 +1,52 @@
-/*
- * 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.config.datasource.killer.impl;
-
-import org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKiller;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-
-/**
- * Default data source killer.
- */
-public final class DefaultDataSourceKiller implements DataSourceKiller {
-    
-    @Override
-    public void kill(final DataSource dataSource) throws SQLException {
-        if (dataSource instanceof AutoCloseable) {
-            try {
-                ((AutoCloseable) dataSource).close();
-                // CHECKSTYLE:OFF
-            } catch (final Exception ex) {
-                // CHECKSTYLE:ON
-                throw new SQLException(ex);
-            }
-        }
-    }
-    
-    @Override
-    public String getType() {
-        return "Default";
-    }
-    
-    @Override
-    public boolean isDefault() {
-        return true;
-    }
-}
+/*
+ * 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.config.datasource.destroyer.impl;
+
+import org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyer;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+/**
+ * Default data source destroyer.
+ */
+public final class DefaultDataSourceDestroyer implements DataSourceDestroyer {
+    
+    @Override
+    public void destroy(final DataSource dataSource) throws SQLException {
+        if (dataSource instanceof AutoCloseable) {
+            try {
+                ((AutoCloseable) dataSource).close();
+                // CHECKSTYLE:OFF
+            } catch (final Exception ex) {
+                // CHECKSTYLE:ON
+                throw new SQLException(ex);
+            }
+        }
+    }
+    
+    @Override
+    public String getType() {
+        return "Default";
+    }
+    
+    @Override
+    public boolean isDefault() {
+        return true;
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/HikariDataSourceKiller.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/HikariDataSourceDestroyer.java
similarity index 82%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/HikariDataSourceKiller.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/HikariDataSourceDestroyer.java
index cbe433a..f82e87c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/killer/impl/HikariDataSourceKiller.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/destroyer/impl/HikariDataSourceDestroyer.java
@@ -1,54 +1,54 @@
-/*
- * 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.config.datasource.killer.impl;
-
-import com.zaxxer.hikari.HikariDataSource;
-import org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKiller;
-import javax.sql.DataSource;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * Hikari data source killer.
- */
-public final class HikariDataSourceKiller implements DataSourceKiller {
-    
-    @Override
-    public void kill(final DataSource dataSource) {
-        HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
-        ExecutorService executor = Executors.newSingleThreadExecutor();
-        executor.execute(() -> {
-            while (true) {
-                if (hikariDataSource.getHikariPoolMXBean().getActiveConnections() == 0) {
-                    hikariDataSource.close();
-                    break;
-                }
-                try {
-                    Thread.sleep(10);
-                } catch (final InterruptedException ignore) {
-                }
-            }
-        });
-        executor.shutdown();
-    }
-    
-    @Override
-    public String getType() {
-        return HikariDataSource.class.getCanonicalName();
-    }
-}
+/*
+ * 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.config.datasource.destroyer.impl;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyer;
+import javax.sql.DataSource;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * Hikari data source destroyer.
+ */
+public final class HikariDataSourceDestroyer implements DataSourceDestroyer {
+    
+    @Override
+    public void destroy(final DataSource dataSource) {
+        HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
+        ExecutorService executor = Executors.newSingleThreadExecutor();
+        executor.execute(() -> {
+            while (true) {
+                if (hikariDataSource.getHikariPoolMXBean().getActiveConnections() == 0) {
+                    hikariDataSource.close();
+                    break;
+                }
+                try {
+                    Thread.sleep(10);
+                } catch (final InterruptedException ignore) {
+                }
+            }
+        });
+        executor.shutdown();
+    }
+    
+    @Override
+    public String getType() {
+        return HikariDataSource.class.getCanonicalName();
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/resource/ShardingSphereResource.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/resource/ShardingSphereResource.java
index 5fed5ad..2a75c67 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/resource/ShardingSphereResource.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/resource/ShardingSphereResource.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.metadata.resource;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKillerFactory;
+import org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyerFactory;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 
 import javax.sql.DataSource;
@@ -82,6 +82,6 @@ public final class ShardingSphereResource {
      * @throws SQLException SQL exception
      */
     public void close(final DataSource dataSource) throws SQLException {
-        DataSourceKillerFactory.getInstance(dataSource.getClass().getName()).kill(dataSource);
+        DataSourceDestroyerFactory.getInstance(dataSource.getClass().getName()).destroy(dataSource);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKiller b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyer
similarity index 80%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKiller
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyer
index a6627b8..c44e525 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.killer.DataSourceKiller
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.destroyer.DataSourceDestroyer
@@ -1,19 +1,19 @@
-#
-# 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.infra.config.datasource.killer.impl.DefaultDataSourceKiller
-org.apache.shardingsphere.infra.config.datasource.killer.impl.HikariDataSourceKiller
+#
+# 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.infra.config.datasource.destroyer.impl.DefaultDataSourceDestroyer
+org.apache.shardingsphere.infra.config.datasource.destroyer.impl.HikariDataSourceDestroyer