You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "terrymanu (via GitHub)" <gi...@apache.org> on 2023/03/04 04:34:18 UTC

[GitHub] [shardingsphere] terrymanu commented on a diff in pull request #24401: Proxy For HBase add config

terrymanu commented on code in PR #24401:
URL: https://github.com/apache/shardingsphere/pull/24401#discussion_r1125314739


##########
infra/common/src/main/java/org/apache/shardingsphere/infra/hbase/HBaseCluster.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.hbase;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.apache.hadoop.hbase.client.Connection;
+
+@AllArgsConstructor
+@Getter
+public class HBaseCluster {

Review Comment:
   If a class is not designed for extension, please add the final keyword.



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/ProxyConfigurationLoader.java:
##########
@@ -65,8 +67,13 @@ public static YamlProxyConfiguration load(final String path) throws IOException
         YamlProxyServerConfiguration serverConfig = loadServerConfiguration(getResourceFile(String.join("/", path, SERVER_CONFIG_FILE)));
         File configPath = getResourceFile(path);
         Collection<YamlProxyDatabaseConfiguration> databaseConfigs = loadDatabaseConfigurations(configPath);
+        Collection<YamlHBaseConfiguration> hbaseConfigs = loadHBaseConfigurations(configPath);
         return new YamlProxyConfiguration(serverConfig, databaseConfigs.stream().collect(Collectors.toMap(
-                YamlProxyDatabaseConfiguration::getDatabaseName, each -> each, (oldValue, currentValue) -> oldValue, LinkedHashMap::new)));
+                YamlProxyDatabaseConfiguration::getDatabaseName, each -> each, (oldValue, currentValue) -> oldValue,
+                LinkedHashMap::new)), hbaseConfigs.stream().collect(
+                        Collectors.toMap(
+                                YamlHBaseConfiguration::getDatabaseName, each -> each, (oldValue, currentValue) -> oldValue,
+                                LinkedHashMap::new)));

Review Comment:
   HBase and JDBC DataSource should be process in pluggable way. I will refactor here after merged



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlHBaseParameter.java:
##########
@@ -0,0 +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.proxy.backend.config.yaml;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
+
+/**
+ * YAML Data source parameters for HBase.
+ */
+@Getter
+@Setter
+@EqualsAndHashCode

Review Comment:
   What is the useful?



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseBackgroundExecutorManager.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorThreadFactoryBuilder;
+import java.io.Closeable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * background executor.
+ */
+@Getter
+public class HBaseBackgroundExecutorManager implements Closeable {
+    
+    private final ScheduledExecutorService executorService;
+    
+    public HBaseBackgroundExecutorManager() {
+        executorService = getExecutorService();
+    }
+    
+    private ScheduledExecutorService getExecutorService() {
+        ThreadFactory threadFactory = ExecutorThreadFactoryBuilder.build("background");
+        return Executors.newScheduledThreadPool(1, threadFactory);
+    }
+    
+    /**
+     * submit background task.

Review Comment:
   The first letter should be upper case, and please keep a blank line between JavaDoc and @param



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseExecutor.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.shardingsphere.proxy.backend.context.HBaseContext;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+
+/**
+ * execute HBase operation.
+ */
+@Slf4j
+public final class HBaseExecutor {
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.

Review Comment:
   Please remove last `.`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseConnectionFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.shardingsphere.proxy.backend.config.YamlHBaseConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlHBaseParameter;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * HBase Connection Factory.
+ */
+public class HBaseConnectionFactory {

Review Comment:
   If a class is not designed for extension, please add the final keyword.



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseAdminCallback.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Admin;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ *
+ * @param <T> return type.

Review Comment:
   Please remove last `.`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseAdminCallback.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Admin;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ *
+ * @param <T> return type.
+ */
+public interface HBaseAdminCallback<T> {
+    
+    /**
+     * do operation in HBase.

Review Comment:
   The first letter should be upper case



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseConnectionFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.shardingsphere.proxy.backend.config.YamlHBaseConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlHBaseParameter;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * HBase Connection Factory.
+ */
+public class HBaseConnectionFactory {
+    
+    /**
+     * create HBase connection.
+     * @param yamlProxyHBaseConfiguration HBase config.
+     * @return A connection for per HBase cluster.
+     */
+    public static Map<String, Connection> createHBaseConnections(final YamlHBaseConfiguration yamlProxyHBaseConfiguration) {
+        Map<String, Connection> result = new LinkedHashMap<>(yamlProxyHBaseConfiguration.getDataSources().size());
+        for (Map.Entry<String, YamlHBaseParameter> entry : yamlProxyHBaseConfiguration.getDataSources().entrySet()) {
+            result.put(entry.getKey(), createConnection(entry.getValue()));
+        }
+        return result;
+    }
+    
+    private static Connection createConnection(final YamlHBaseParameter parameter) {
+        Configuration config = createConfiguration(parameter);
+        try {
+            if (StringUtils.isEmpty(parameter.getAccessUser())) {
+                return ConnectionFactory.createConnection(config);
+            } else {
+                return ConnectionFactory.createConnection(config, createUser(parameter.getAccessUser()));
+            }
+        } catch (IOException e) {
+            throw new HBaseOperationException(e.getMessage());
+        }
+    }
+    
+    private static User createUser(final String accessUser) {
+        return User.create(UserGroupInformation.createRemoteUser(accessUser));
+    }
+    
+    private static Configuration createConfiguration(final YamlHBaseParameter parameter) {
+        Configuration config = HBaseConfiguration.create();
+        config.set("fs.defaultFS", parameter.getFsDefaultFs());
+        config.set("hbase.rootdir", parameter.getHbaseRootDir());
+        config.setLong("hbase.rpc.timeout", parameter.getHbaseRpcTimeout());
+        config.setLong("hbase.client.operation.timeout", parameter.getHbaseClientOperationTimeout());
+        config.setLong("hbase.client.scanner.timeout.period", parameter.getHbaseClientScannerTimeoutPeriod());
+        config.set("hbase.zookeeper.property.dataDir", parameter.getHbaseZookeeperPropertyDataDir());
+        config.set("hbase.zookeeper.quorum", parameter.getHbaseZookeeperQuorum());
+        config.set("zookeeper.znode.parent", parameter.getZookeeperZNodeParent());
+        config.setInt("hbase.client.ipc.pool.size", parameter.getIpcPoolSize());
+        return config;

Review Comment:
   Return value should name as `result`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseExecutor.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.shardingsphere.proxy.backend.context.HBaseContext;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+
+/**
+ * execute HBase operation.
+ */
+@Slf4j
+public final class HBaseExecutor {
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.
+     * @param operation operation
+     *
+     */
+    public static void executeUpdate(final String tableName, final HBaseUpdateCallback operation) {
+        TableName backendTableName = TableName.valueOf(tableName);
+        try (Table table = HBaseContext.getInstance().getConnection(tableName).getTable(backendTableName)) {
+            try {
+                operation.executeInHBase(table);
+            } catch (IOException e) {
+                log.info(String.format("query hbase table: %s, execute hbase fail", tableName));
+                log.error(e.toString());
+                throw new HBaseOperationException(e.getMessage());
+            }
+        } catch (IOException e) {
+            log.info(String.format("query hbase table: %s, execute hbase fail", tableName));
+            log.error(e.toString());
+            throw new HBaseOperationException(e.getMessage());
+        }
+    }
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.
+     * @param operation operation
+     * @param <R> Result Type.
+     *
+     * @return result.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
pom.xml:
##########
@@ -678,6 +681,12 @@
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.hbase</groupId>
+            <artifactId>hbase-shaded-client</artifactId>
+            <version>${hbase.client.version}</version>

Review Comment:
   Please use the provide scope, otherwise, ShardingSphere's dependencies will become heavier and heavier.



##########
infra/common/src/main/java/org/apache/shardingsphere/infra/hbase/HBaseCluster.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.hbase;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.apache.hadoop.hbase.client.Connection;
+
+@AllArgsConstructor

Review Comment:
   Please use @RequiredArgsConstructor



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseQueryCallback.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Table;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ * 
+ * @param <T> return type.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseBackgroundExecutorManager.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorThreadFactoryBuilder;
+import java.io.Closeable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * background executor.
+ */
+@Getter
+public class HBaseBackgroundExecutorManager implements Closeable {
+    
+    private final ScheduledExecutorService executorService;
+    
+    public HBaseBackgroundExecutorManager() {
+        executorService = getExecutorService();
+    }
+    
+    private ScheduledExecutorService getExecutorService() {
+        ThreadFactory threadFactory = ExecutorThreadFactoryBuilder.build("background");
+        return Executors.newScheduledThreadPool(1, threadFactory);
+    }
+    
+    /**
+     * submit background task.
+     * @param runnable background task.
+     * @param interval Running interval.

Review Comment:
   Please remove last `.`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseTaskExecutorManager.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.backend.connector.hbase;
+
+import java.io.Closeable;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class HBaseTaskExecutorManager implements Closeable {
+    
+    private final ThreadPoolExecutor executorService;
+    
+    public HBaseTaskExecutorManager(final int poolSize) {
+        executorService = getExecutorService(poolSize);
+    }
+    
+    private ThreadPoolExecutor getExecutorService(final int poolSize) {
+        return new ThreadPoolExecutor(
+                poolSize, poolSize, 10,
+                TimeUnit.SECONDS,
+                new ArrayBlockingQueue<>(20000),
+                new ThreadPoolExecutor.CallerRunsPolicy());
+    }
+    
+    /**
+     * submit task.
+     * @param runnable task.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseExecutor.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.shardingsphere.proxy.backend.context.HBaseContext;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+
+/**
+ * execute HBase operation.
+ */
+@Slf4j
+public final class HBaseExecutor {
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.
+     * @param operation operation
+     *

Review Comment:
   Please remove empty line



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseConnectionFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.shardingsphere.proxy.backend.config.YamlHBaseConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlHBaseParameter;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * HBase Connection Factory.

Review Comment:
   The first letters of `Connection` and `Factory` should be lower case



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseBackgroundExecutorManager.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorThreadFactoryBuilder;
+import java.io.Closeable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * background executor.
+ */
+@Getter
+public class HBaseBackgroundExecutorManager implements Closeable {

Review Comment:
   If a class is not designed for extension, please add the final keyword.



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseBackgroundExecutorManager.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorThreadFactoryBuilder;
+import java.io.Closeable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * background executor.

Review Comment:
   The first letter should be upper case



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseTaskExecutorManager.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.backend.connector.hbase;
+
+import java.io.Closeable;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class HBaseTaskExecutorManager implements Closeable {
+    
+    private final ThreadPoolExecutor executorService;
+    
+    public HBaseTaskExecutorManager(final int poolSize) {
+        executorService = getExecutorService(poolSize);
+    }
+    
+    private ThreadPoolExecutor getExecutorService(final int poolSize) {
+        return new ThreadPoolExecutor(
+                poolSize, poolSize, 10,
+                TimeUnit.SECONDS,
+                new ArrayBlockingQueue<>(20000),
+                new ThreadPoolExecutor.CallerRunsPolicy());
+    }
+    
+    /**
+     * submit task.
+     * @param runnable task.
+     */
+    public void submit(final Runnable runnable) {
+        executorService.submit(runnable);
+    }
+    
+    /**
+     * close.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/HBaseOperationException.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.backend.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * HBase Operation exception.
+ */
+@AllArgsConstructor
+@Getter
+public class HBaseOperationException extends RuntimeException {

Review Comment:
   Please add final



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/context/HBaseMetaRefresher.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.backend.context;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+
+/**
+ * background thread to refresh meta data.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseAdminCallback.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Admin;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.

Review Comment:
   The first letter should be upper case



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseAdminCallback.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Admin;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ *
+ * @param <T> return type.
+ */
+public interface HBaseAdminCallback<T> {
+    
+    /**
+     * do operation in HBase.
+     *
+     * @param admin execute in HBase Table.

Review Comment:
   Please remove last `.`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseAdminCallback.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Admin;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ *
+ * @param <T> return type.
+ */
+public interface HBaseAdminCallback<T> {
+    
+    /**
+     * do operation in HBase.
+     *
+     * @param admin execute in HBase Table.
+     * @return result.
+     * @throws IOException exception.

Review Comment:
   Please remove last `.`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseConnectionFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.shardingsphere.proxy.backend.config.YamlHBaseConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlHBaseParameter;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * HBase Connection Factory.
+ */
+public class HBaseConnectionFactory {
+    
+    /**
+     * create HBase connection.
+     * @param yamlProxyHBaseConfiguration HBase config.
+     * @return A connection for per HBase cluster.
+     */
+    public static Map<String, Connection> createHBaseConnections(final YamlHBaseConfiguration yamlProxyHBaseConfiguration) {
+        Map<String, Connection> result = new LinkedHashMap<>(yamlProxyHBaseConfiguration.getDataSources().size());
+        for (Map.Entry<String, YamlHBaseParameter> entry : yamlProxyHBaseConfiguration.getDataSources().entrySet()) {

Review Comment:
   Please use `Entry` to instead of `Map.Entry`, just put `Map.Entry` in import list



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseExecutor.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.shardingsphere.proxy.backend.context.HBaseContext;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+
+/**
+ * execute HBase operation.
+ */
+@Slf4j
+public final class HBaseExecutor {
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseConnectionFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.shardingsphere.proxy.backend.config.YamlHBaseConfiguration;
+import org.apache.shardingsphere.proxy.backend.config.yaml.YamlHBaseParameter;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * HBase Connection Factory.
+ */
+public class HBaseConnectionFactory {
+    
+    /**
+     * create HBase connection.
+     * @param yamlProxyHBaseConfiguration HBase config.
+     * @return A connection for per HBase cluster.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseQueryCallback.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Table;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ * 
+ * @param <T> return type.
+ */
+public interface HBaseQueryCallback<T> {
+    
+    /**
+     * do operation in HBase.
+     * 
+     * @param table execute in HBase Table.
+     * @return result.
+     * @throws IOException exception.
+     * 

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseExecutor.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.backend.connector.hbase;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.shardingsphere.proxy.backend.context.HBaseContext;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+
+/**
+ * execute HBase operation.
+ */
+@Slf4j
+public final class HBaseExecutor {
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.
+     * @param operation operation
+     *
+     */
+    public static void executeUpdate(final String tableName, final HBaseUpdateCallback operation) {
+        TableName backendTableName = TableName.valueOf(tableName);
+        try (Table table = HBaseContext.getInstance().getConnection(tableName).getTable(backendTableName)) {
+            try {
+                operation.executeInHBase(table);
+            } catch (IOException e) {
+                log.info(String.format("query hbase table: %s, execute hbase fail", tableName));
+                log.error(e.toString());
+                throw new HBaseOperationException(e.getMessage());
+            }
+        } catch (IOException e) {
+            log.info(String.format("query hbase table: %s, execute hbase fail", tableName));
+            log.error(e.toString());
+            throw new HBaseOperationException(e.getMessage());
+        }
+    }
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param tableName tableName.
+     * @param operation operation
+     * @param <R> Result Type.
+     *
+     * @return result.
+     */
+    public static <R> R executeQuery(final String tableName, final HBaseQueryCallback<R> operation) {
+        TableName backendTableName = TableName.valueOf(tableName);
+        try (Table table = HBaseContext.getInstance().getConnection(tableName).getTable(backendTableName)) {
+            R result;
+            try {
+                result = operation.executeInHBase(table);
+            } catch (IOException e) {
+                throw new HBaseOperationException(e.getMessage());
+            }
+            return result;
+        } catch (IOException e) {
+            throw new HBaseOperationException(e.getMessage());
+        }
+    }
+    
+    /**
+     * do operation in HBase, wrapper HBase Exception.
+     * <p>If we need cache Table, do that in here.</p>
+     *
+     * @param connection HBase Connection.
+     * @param operation operation
+     * @param <R> Result Type.
+     *
+     * @return result.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseUpdateCallback.java:
##########
@@ -0,0 +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.proxy.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Table;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/context/HBaseRegionWarmUpContext.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.backend.context;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.shardingsphere.infra.hbase.HBaseCluster;
+import org.apache.shardingsphere.proxy.backend.connector.hbase.HBaseTaskExecutorManager;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Getter
+@Slf4j
+public class HBaseRegionWarmUpContext {

Review Comment:
   1. Please add javadoc
   2. Please add `final`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseTaskExecutorManager.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.backend.connector.hbase;
+
+import java.io.Closeable;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class HBaseTaskExecutorManager implements Closeable {

Review Comment:
   1. Please add javadoc
   2. Please add `final`



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/hbase/HBaseUpdateCallback.java:
##########
@@ -0,0 +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.proxy.backend.connector.hbase;
+
+import org.apache.hadoop.hbase.client.Table;
+import java.io.IOException;
+
+/**
+ * call back for HBase operation.
+ */
+public interface HBaseUpdateCallback {
+    
+    /**
+     * do operation in HBase.
+     *
+     * @param table execute in HBase Table.
+     * @throws IOException exception.
+     *

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/context/HBaseRegionWarmUpContext.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.backend.context;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.RegionLocator;
+import org.apache.shardingsphere.infra.hbase.HBaseCluster;
+import org.apache.shardingsphere.proxy.backend.connector.hbase.HBaseTaskExecutorManager;
+import org.apache.shardingsphere.proxy.backend.exception.HBaseOperationException;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Getter
+@Slf4j
+public class HBaseRegionWarmUpContext {
+    
+    private static final HBaseRegionWarmUpContext INSTANCE = new HBaseRegionWarmUpContext();
+    
+    private final AtomicInteger executeCount = new AtomicInteger(0);
+    
+    private final AtomicInteger tableCount = new AtomicInteger(0);
+    
+    private HBaseTaskExecutorManager executorManager;
+    
+    private long startWarmUpTime;
+    
+    /**
+     * Get instance of HBase context.
+     *
+     * @return instance of HBase context.
+     */
+    public static HBaseRegionWarmUpContext getInstance() {
+        return INSTANCE;
+    }
+    
+    /**
+     * init.
+     * @param poolSize mul execute size
+     */
+    public void init(final int poolSize) {
+        executorManager = new HBaseTaskExecutorManager(poolSize);
+    }
+    
+    /**
+     * submit region warm up task.
+     * @param tableName tableName
+     * @param hbaseCluster hbaseCluster
+     */
+    public void submitWarmUpTask(final String tableName, final HBaseCluster hbaseCluster) {
+        executorManager.submit(() -> loadRegionInfo(tableName, hbaseCluster));
+    }
+    
+    private void loadRegionInfo(final String tableName, final HBaseCluster hbaseCluster) {
+        try {
+            RegionLocator regionLocator = hbaseCluster.getConnection().getRegionLocator(TableName.valueOf(tableName));
+            regionLocator.getAllRegionLocations();
+            HBaseRegionWarmUpContext.getInstance().addExecuteCount();
+        } catch (IOException e) {
+            log.error(String.format("table: %s warm up error, getRegionLocator execute error reason is  %s", tableName, e));
+        }
+    }
+    
+    /**
+     * load one table region info.
+     * @param tableName tableName
+     * @param connection hbase connection

Review Comment:
   Please reference above code review comments to fix the javadoc



##########
proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/exception/HBaseOperationException.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.backend.exception;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * HBase Operation exception.
+ */
+@AllArgsConstructor

Review Comment:
   Please use @RequiredArgsConstructor



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org