wuchong commented on a change in pull request #9866: [FLINK-14349][hbase] 
Create a Connector Descriptor for HBase so that user can connect HBase by 
TableEnvironment#connect
URL: https://github.com/apache/flink/pull/9866#discussion_r333817211
 
 

 ##########
 File path: 
flink-connectors/flink-hbase/src/main/java/org/apache/flink/table/descriptors/HBase.java
 ##########
 @@ -0,0 +1,130 @@
+/*
+ * 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.flink.table.descriptors;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.util.TimeUtils;
+
+import java.time.Duration;
+import java.util.Map;
+
+import static 
org.apache.flink.table.descriptors.ConnectorDescriptorValidator.CONNECTOR_VERSION;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_TABLE_NAME;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_TYPE_VALUE_HBASE;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_WRITE_BUFFER_FLUSH_INTERVAL;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_WRITE_BUFFER_FLUSH_MAX_ROWS;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_WRITE_BUFFER_FLUSH_MAX_SIZE;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_ZK_NODE_PARENT;
+import static 
org.apache.flink.table.descriptors.HBaseValidator.CONNECTOR_ZK_QUORUM;
+
+/**
+ * Connector descriptor for Apache HBase.
+ */
+@PublicEvolving
+public class HBase extends ConnectorDescriptor {
+       private DescriptorProperties properties = new DescriptorProperties();
+
+       public HBase() {
+               super(CONNECTOR_TYPE_VALUE_HBASE, 1, true);
+       }
+
+       /**
+        * Set the Apache HBase version to be used. Required.
+        *
+        * @param version HBase version. E.g., "1.4.3".
+        */
+       public HBase version(String version) {
+               properties.putString(CONNECTOR_VERSION, version);
+               return this;
+       }
+
+       /**
+        * Set the HBase table name, Required.
+        *
+        * @param tableName Name of HBase table.  E.g., 
"testNamespace:testTable", "testDefaultTable"
+        */
+       public HBase tableName(String tableName) {
+               properties.putString(CONNECTOR_TABLE_NAME, tableName);
+               return this;
+       }
+
+       /**
+        * Set the zookeeper quorum address to connect the HBase cluster. 
Required.
+        *
+        * @param zookeeperQuorum zookeeper quorum address to connect the HBase 
cluster.
+        *                        E.g., 
"localhost:2181,localhost:2182,localhost:2183".
+        */
+       public HBase zookeeperQuorum(String zookeeperQuorum) {
+               properties.putString(CONNECTOR_ZK_QUORUM, zookeeperQuorum);
+               return this;
+       }
+
+       /**
+        * Set the zookeeper node parent path of HBase cluster. Default to use 
"/hbase", Optional.
+        *
+        * @param zookeeperNodeParent zookeeper node path of hbase cluster. 
E.g, "/hbase/example-root-znode".
+        */
+       public HBase zookeeperNodeParent(String zookeeperNodeParent) {
+               properties.putString(CONNECTOR_ZK_NODE_PARENT, 
zookeeperNodeParent);
+               return this;
+       }
+
+       /**
+        * Set threshold when to flush buffered request based on the memory 
byte size of rows currently added.
+        * Default to <code>2mb</code>. Optional.
+        *
+        * @param maxSize the maximum size (using the syntax of {@link 
MemorySize}).
+        */
+       public HBase writeBufferFlushMaxSize(String maxSize) {
+               properties.putMemorySize(CONNECTOR_WRITE_BUFFER_FLUSH_MAX_SIZE, 
MemorySize.parse(maxSize, MemorySize.MemoryUnit.BYTES));
+               return this;
+       }
+
+       /**
+        * Set threshold when to flush buffered request based on the number of 
rows currently added.
+        * Defaults to not set, i.e. won't flush based on the number of 
buffered rows. Optional.
+        *
+        * @param writeBufferFlushMaxRows number of added rows when begin the 
request flushing.
+        */
+       public HBase writeBufferFlushMaxRows(int writeBufferFlushMaxRows) {
+               properties.putInt(CONNECTOR_WRITE_BUFFER_FLUSH_MAX_ROWS, 
writeBufferFlushMaxRows);
+               return this;
+       }
+
+       /**
+        * Set an interval when to flushing buffered requesting if the interval 
passes, in milliseconds.
+        * Defaults to not set, i.e. won't flush based on flush interval. 
Optional.
+        *
+        * @param interval flush interval. The string should be in format 
"{length value}{time unit label}"
+        *                 E.g, "123ms", "1 s", If no time unit label is 
specified, it will be considered as
+        *                 milliseconds. For more details about the format, 
please see
+        *                 {@link TimeUtils#parseDuration(String)}}.
+        */
+       public HBase writeBufferFlushInterval(String interval) {
+               Duration duration = TimeUtils.parseDuration(interval);
+               properties.putLong(CONNECTOR_WRITE_BUFFER_FLUSH_INTERVAL, 
duration.toMillis());
 
 Review comment:
   We can keep the original interval text into the properties to make the 
property more readable. 
   In the future, we want to prohibit numeric if the property accepts a 
duration string, because numeric is ambiguous.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to