LeonBein commented on a change in pull request #15109: URL: https://github.com/apache/flink/pull/15109#discussion_r595548853
########## File path: flink-connectors/flink-connector-hbase/src/main/java/org/apache/flink/connector/hbase/source/hbaseendpoint/HBaseEndpoint.java ########## @@ -0,0 +1,290 @@ +/* + * 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.connector.hbase.source.hbaseendpoint; + +import org.apache.flink.connector.base.source.reader.synchronization.FutureCompletingBlockingQueue; +import org.apache.flink.connector.hbase.source.HBaseSourceOptions; +import org.apache.flink.connector.hbase.source.reader.HBaseSourceEvent; +import org.apache.flink.connector.hbase.util.HBaseConfigurationUtil; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellScanner; +import org.apache.hadoop.hbase.Server; +import org.apache.hadoop.hbase.ServerName; +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.ConnectionFactory; +import org.apache.hadoop.hbase.ipc.FifoRpcScheduler; +import org.apache.hadoop.hbase.ipc.HBaseRpcController; +import org.apache.hadoop.hbase.ipc.RpcServer; +import org.apache.hadoop.hbase.ipc.RpcServerFactory; +import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; +import org.apache.hadoop.hbase.replication.ReplicationPeerDescription; +import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; +import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper; +import org.apache.hadoop.hbase.zookeeper.ZKUtil; +import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; +import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException; +import org.apache.zookeeper.CreateMode; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.ZooDefs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.ExecutionException; + +/** Consumer of HBase WAL edits. */ +public class HBaseEndpoint implements ReplicationTargetInterface { + + private static final Logger LOG = LoggerFactory.getLogger(HBaseEndpoint.class); + private final String clusterKey; + /** The id under which the replication target is made known to the source cluster. */ + private final String replicationPeerId; + + private final Configuration hbaseConf; + private final RecoverableZooKeeper zooKeeper; + private final RpcServer rpcServer; + private final FutureCompletingBlockingQueue<HBaseSourceEvent> walEdits; + private final String hostName; + private final String tableName; + private boolean isRunning = false; + + public HBaseEndpoint(byte[] serializedConfig, Properties properties) + throws IOException, KeeperException, InterruptedException { + this(HBaseConfigurationUtil.deserializeConfiguration(serializedConfig, null), properties); + } + + public HBaseEndpoint(Configuration hbaseConf, Properties properties) + throws InterruptedException, KeeperException, IOException { + this(UUID.randomUUID().toString().substring(0, 5), hbaseConf, properties); + } + + public HBaseEndpoint(String peerId, Configuration hbaseConf, Properties properties) + throws IOException, KeeperException, InterruptedException { + this.hbaseConf = hbaseConf; + this.clusterKey = peerId + "_clusterKey"; + this.replicationPeerId = peerId; + this.hostName = HBaseSourceOptions.getHostName(properties); + this.tableName = HBaseSourceOptions.getTableName(properties); + int queueCapacity = HBaseSourceOptions.getEndpointQueueCapacity(properties); + this.walEdits = new FutureCompletingBlockingQueue<>(queueCapacity); + + // Setup + zooKeeper = connectToZooKeeper(); + rpcServer = createServer(); + registerAtZooKeeper(); + } Review comment: ✅ changes in 4fb1b8d6b4bc7e6728c1f864d114fd0ba45b9228 reduce to one constructor ---------------------------------------------------------------- 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