You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by la...@apache.org on 2022/04/15 10:18:32 UTC

[shardingsphere] branch master updated: Ref #13432, correct the shadow algorithm name in example. (#16862)

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

lanchengxiang 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 dfb016c1c4e Ref #13432, correct the shadow algorithm name in example. (#16862)
dfb016c1c4e is described below

commit dfb016c1c4e9e7af0683c5e267f270a4b07865d2
Author: Raigor <ra...@gmail.com>
AuthorDate: Fri Apr 15 18:18:26 2022 +0800

    Ref #13432, correct the shadow algorithm name in example. (#16862)
---
 .../distsql/feature/encrypt/EncryptExecutor.java   |  8 +++----
 .../ReadWriteSplittingExecutor.java                |  6 ++---
 .../distsql/feature/resource/ResourceExecutor.java |  8 +++----
 .../distsql/feature/shadow/ShadowExecutor.java     | 22 ++++++++---------
 .../distsql/feature/sharding/ShardingExecutor.java | 28 ++++++++++++++++++----
 5 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/encrypt/EncryptExecutor.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/encrypt/EncryptExecutor.java
index 5c1060872b7..e61ef16508c 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/encrypt/EncryptExecutor.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/encrypt/EncryptExecutor.java
@@ -40,17 +40,17 @@ public final class EncryptExecutor extends AbstractFeatureExecutor {
             "COLUMNS(\n" +
             "(NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),\n" +
             "(NAME=order_id, CIPHER=order_cipher,TYPE(NAME=MD5))\n" +
-            "));";
+            "))";
     
     private static final String ALTER_RULE = "ALTER ENCRYPT RULE t_encrypt (\n" +
             "COLUMNS(\n" +
             "(NAME=user_id,PLAIN=user_plain,CIPHER=user_cipher,TYPE(NAME=AES,PROPERTIES('aes-key-value'='123456abc'))),\n" +
             "(NAME=order_id,CIPHER=order_cipher,TYPE(NAME=MD5))\n" +
-            "));";
+            "))";
     
-    private static final String DROP_RULE = "DROP ENCRYPT RULE t_encrypt,t_encrypt_2;";
+    private static final String DROP_RULE = "DROP ENCRYPT RULE t_encrypt,t_encrypt_2";
     
-    private static final String SHOW_RULE = "show encrypt rules";
+    private static final String SHOW_RULE = "SHOW ENCRYPT RULES";
     
     @Override
     public void init(Statement statement) {
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/readwritesplitting/ReadWriteSplittingExecutor.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/readwritesplitting/ReadWriteSplittingExecutor.java
index 32aee92bb4b..dcd95cdb019 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/readwritesplitting/ReadWriteSplittingExecutor.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/readwritesplitting/ReadWriteSplittingExecutor.java
@@ -35,17 +35,17 @@ public final class ReadWriteSplittingExecutor extends AbstractFeatureExecutor {
             "WRITE_RESOURCE=ds_0,\n" +
             "READ_RESOURCES(ds_1),\n" +
             "TYPE(NAME=random)\n" +
-            ");";
+            ")";
     
     private static final String ALTER_RULE = "ALTER READWRITE_SPLITTING RULE ms_group_0 (\n" +
             "WRITE_RESOURCE=ds_0,\n" +
             "READ_RESOURCES(ds_1),\n" +
             "TYPE(NAME=random,PROPERTIES(read_weight='2:0'))\n" +
-            ");";
+            ")";
     
     private static final String DROP_RULE = "DROP READWRITE_SPLITTING RULE ms_group_0;\n";
     
-    private static final String SHOW_RULE = "show readwrite_splitting rules";
+    private static final String SHOW_RULE = "SHOW READWRITE_SPLITTING RULES";
     
     @Override
     public void init(Statement statement) {
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/resource/ResourceExecutor.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/resource/ResourceExecutor.java
index c92290bad22..7cfa763c27b 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/resource/ResourceExecutor.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/resource/ResourceExecutor.java
@@ -41,7 +41,7 @@ public final class ResourceExecutor extends AbstractFeatureExecutor {
             "    USER=root,\n" +
             "    PASSWORD=root,\n" +
             "    PROPERTIES(\"maximumPoolSize\"=10,\"idleTimeout\"=\"30000\")\n" +
-            ");";
+            ")";
     
     private static final String ALTER_RESOURCE = "ALTER RESOURCE resource_0 (\n" +
             "    HOST=127.0.0.1,\n" +
@@ -49,11 +49,11 @@ public final class ResourceExecutor extends AbstractFeatureExecutor {
             "    DB=demo_ds,\n" +
             "    USER=root,\n" +
             "    PASSWORD=root\n" +
-            ");";
+            ")";
     
-    private static final String DROP_RESOURCE = "DROP RESOURCE resource_0, resource_1;";
+    private static final String DROP_RESOURCE = "DROP RESOURCE resource_0, resource_1";
     
-    private static final String SHOW_RESOURCE = "show schema resources;";
+    private static final String SHOW_RESOURCE = "SHOW SCHEMA RESOURCES";
     
     @Override
     public void init(Statement statement) {
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/shadow/ShadowExecutor.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/shadow/ShadowExecutor.java
index 985380313f1..51b4b4c2f6d 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/shadow/ShadowExecutor.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/shadow/ShadowExecutor.java
@@ -34,28 +34,28 @@ public final class ShadowExecutor extends AbstractFeatureExecutor {
     private static final String ADD_RULE = "CREATE SHADOW RULE shadow_rule(\n" +
             "SOURCE=ds_0,\n" +
             "SHADOW=ds_1,\n" +
-            "t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES(\"shadow\"=\"true\", foo=\"bar\"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES(\"operation\"=\"insert\",\"column\"=\"user_id\", \"regex\"='[1]')))), \n" +
-            "t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\")))));";
+            "t_order((simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES(\"shadow\"=\"true\", foo=\"bar\"))),(TYPE(NAME=REGEX_MATCH, PROPERTIES(\"operation\"=\"insert\",\"column\"=\"user_id\", \"regex\"='[1]')))), \n" +
+            "t_order_item((TYPE(NAME=SIMPLE_HINT, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\")))));";
     
     private static final String ALTER_RULE = "ALTER SHADOW RULE shadow_rule(\n" +
             "SOURCE=ds_1,\n" +
             "SHADOW=ds_0,\n" +
-            "t_order((simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES(\"shadow\"=\"true\", foo=\"bar\"))),(TYPE(NAME=COLUMN_REGEX_MATCH, PROPERTIES(\"operation\"=\"insert\",\"column\"=\"user_id\", \"regex\"='[1]')))), \n" +
-            "t_order_item((TYPE(NAME=SIMPLE_NOTE, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\")))))";
+            "t_order((simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES(\"shadow\"=\"true\", foo=\"bar\"))),(TYPE(NAME=REGEX_MATCH, PROPERTIES(\"operation\"=\"insert\",\"column\"=\"user_id\", \"regex\"='[1]')))), \n" +
+            "t_order_item((TYPE(NAME=SIMPLE_HINT, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\")))))";
     
     private static final String ALTER_ALGORITHM = "ALTER SHADOW ALGORITHM \n" +
-            "(simple_note_algorithm, TYPE(NAME=SIMPLE_NOTE, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\"))), \n" +
-            "(shadow_rule_t_order_column_regex_match, TYPE(NAME=COLUMN_REGEX_MATCH,PROPERTIES(\"operation\"=\"insert\", \"column\"=\"user_id\", \"regex\"='[1]')));";
+            "(simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES(\"shadow\"=\"true\", \"foo\"=\"bar\"))), \n" +
+            "(shadow_rule_t_order_regex_match, TYPE(NAME=REGEX_MATCH,PROPERTIES(\"operation\"=\"insert\", \"column\"=\"user_id\", \"regex\"='[1]')))";
     
-    private static final String DROP_RULE = "DROP SHADOW RULE shadow_rule;";
+    private static final String DROP_RULE = "DROP SHADOW RULE shadow_rule";
     
-    private static final String DROP_ALGORITHM = "DROP shadow algorithm simple_note_algorithm,shadow_rule_t_order_column_regex_match,shadow_rule_t_order_item_simple_note;";
+    private static final String DROP_ALGORITHM = "DROP SHADOW ALGORITHM simple_hint_algorithm,shadow_rule_t_order_regex_match,shadow_rule_t_order_item_simple_hint";
     
-    private static final String SHOW_RULE = "show shadow rules;";
+    private static final String SHOW_RULE = "SHOW SHADOW RULES";
     
-    private static final String SHOW_TABLE_RULE = "show shadow table rules;";
+    private static final String SHOW_TABLE_RULE = "SHOW SHADOW TABLE RULES";
     
-    private static final String SHOW_ALGORITHM = "show shadow algorithms";
+    private static final String SHOW_ALGORITHM = "SHOW SHADOW ALGORITHMS";
     
     @Override
     public void init(Statement statement) {
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/sharding/ShardingExecutor.java b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/sharding/ShardingExecutor.java
index 82a16154202..85d8ae888e7 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/sharding/ShardingExecutor.java
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/java/org/apache/shardingsphere/example/proxy/distsql/feature/sharding/ShardingExecutor.java
@@ -36,22 +36,26 @@ public final class ShardingExecutor extends AbstractFeatureExecutor {
             "SHARDING_COLUMN=order_id,\n" +
             "TYPE(NAME=hash_mod,PROPERTIES(\"sharding-count\"=4)),\n" +
             "KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME=snowflake))\n" +
-            ");";
+            ")";
     
     private static final String ALTER_RULE = "ALTER SHARDING TABLE RULE t_order (\n" +
             "RESOURCES(ds_0,ds_1),\n" +
             "SHARDING_COLUMN=order_id,\n" +
             "TYPE(NAME=hash_mod,PROPERTIES(\"sharding-count\"=5)),\n" +
             "KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME=snowflake))\n" +
-            ");";
+            ")";
     
-    private static final String DROP_RULE = "DROP SHARDING TABLE RULE t_order;\n";
+    private static final String DROP_RULE = "DROP SHARDING TABLE RULE t_order";
     
     private static final String DROP_ALGORITHM = "DROP SHARDING ALGORITHM t_order_hash_mod";
     
-    private static final String SHOW_RULE = "show sharding table rules;";
+    private static final String SHOW_RULE = "SHOW SHARDING TABLE RULES";
     
-    private static final String SHOW_ALGORITHM = "show sharding algorithms";
+    private static final String SHOW_ALGORITHM = "SHOW SHARDING ALGORITHMS";
+    
+    private static final String DROP_KEY_GENERATOR = "DROP SHARDING KEY GENERATOR t_order_snowflake";
+    
+    private static final String SHOW_KEY_GENERATORS = "SHOW SHARDING KEY GENERATORS";
     
     @Override
     public void init(Statement statement) {
@@ -72,6 +76,9 @@ public final class ShardingExecutor extends AbstractFeatureExecutor {
         executeDropAlgorithm();
         executeShowRule();
         executeShowAlgorithm();
+        executeShowKeyGenerators();
+        executeDropKeyGenerator();
+        executeShowKeyGenerators();
     }
     
     private void executeShowRule() throws SQLException {
@@ -105,4 +112,15 @@ public final class ShardingExecutor extends AbstractFeatureExecutor {
         log.info("drop algorithm...");
         statement.execute(DROP_ALGORITHM);
     }
+    
+    private void executeShowKeyGenerators() throws SQLException {
+        log.info("show sharding key generators...");
+        ResultSet resultSet = statement.executeQuery(SHOW_KEY_GENERATORS);
+        log.info(new Gson().toJson(getResultData(resultSet)));
+    }
+    
+    private void executeDropKeyGenerator() throws SQLException {
+        log.info("drop sharding key generator...");
+        statement.execute(DROP_KEY_GENERATOR);
+    }
 }