bharathv commented on a change in pull request #3550: URL: https://github.com/apache/hbase/pull/3550#discussion_r681325431
########## File path: hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcConnectionRegistry.java ########## @@ -0,0 +1,99 @@ +/** + * 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.hadoop.hbase.client; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseInterfaceAudience; +import org.apache.hadoop.hbase.ServerName; +import org.apache.yetus.audience.InterfaceAudience; + +import org.apache.hbase.thirdparty.com.google.common.base.Splitter; + +import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.GetBootstrapNodesRequest; +import org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.GetBootstrapNodesResponse; + +/** + * Rpc based connection registry. It will make use of the {@link ClientMetaService} to get registry + * information. + * <p/> + * It needs bootstrap node list when start up, and then it will use {@link ClientMetaService} to + * refresh the bootstrap node list periodically. + * <p/> + * Usually, you could set masters as the bootstrap nodes,as they will also implement the + * {@link ClientMetaService}, and then, we will switch to use region servers after refreshing the + * bootstrap nodes. + */ [email protected](HBaseInterfaceAudience.CONFIG) +public class RpcConnectionRegistry extends AbstractRpcBasedConnectionRegistry { + + /** Configuration key that controls the fan out of requests **/ + public static final String HEDGED_REQS_FANOUT_KEY = "hbase.client.rpc_registry.hedged.fanout"; + + public static final String PERIODIC_REFRESH_INTERVAL_SECS = + "hbase.client.rpc_registry.refresh_interval_secs"; + + public static final String MIN_SECS_BETWEEN_REFRESHES = + "hbase.client.rpc_registry.min_secs_between_refreshes"; + + public static final String BOOTSTRAP_NODES = "hbase.client.rpc_registry.bootstrap_nodes"; Review comment: nit: We can use a more simpler config hbase.client.bootstrap.servers or hbase.client.connection.boostrap.servers? I feel rpc_registry is an internal thing and not obvious to operators. Open to suggestions these are two things that that popped into my head (first one inspired by kafka.bootstrap.servers) ########## File path: hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterRegistry.java ########## @@ -79,36 +51,27 @@ * TODO: Handle changes to the configuration dynamically without having to restart the client. */ @InterfaceAudience.Private -public class MasterRegistry implements ConnectionRegistry { +public class MasterRegistry extends AbstractRpcBasedConnectionRegistry { /** Configuration key that controls the fan out of requests **/ public static final String MASTER_REGISTRY_HEDGED_REQS_FANOUT_KEY = "hbase.client.master_registry.hedged.fanout"; - /** Default value for the fan out of hedged requests. **/ - public static final int MASTER_REGISTRY_HEDGED_REQS_FANOUT_DEFAULT = 2; + public static final String MASTER_REGISTRY_PERIODIC_REFRESH_INTERVAL_SECS = + "hbase.client.master_registry.refresh_interval_secs"; - private static final String MASTER_ADDRS_CONF_SEPARATOR = ","; - - private final int hedgedReadFanOut; - - // Configured list of masters to probe the meta information from. - private volatile ImmutableMap<ServerName, ClientMetaService.Interface> masterAddr2Stub; - - // RPC client used to talk to the masters. - private final RpcClient rpcClient; - private final RpcControllerFactory rpcControllerFactory; - private final int rpcTimeoutMs; + public static final String MASTER_REGISTRY_MIN_SECS_BETWEEN_REFRESHES = + "hbase.client.master_registry.min_secs_between_refreshes"; - protected final MasterAddressRefresher masterAddressRefresher; + private static final String MASTER_ADDRS_CONF_SEPARATOR = ","; /** * Parses the list of master addresses from the provided configuration. Supported format is comma * separated host[:port] values. If no port number if specified, default master port is assumed. * @param conf Configuration to parse from. */ - private static Set<ServerName> parseMasterAddrs(Configuration conf) throws UnknownHostException { - Set<ServerName> masterAddrs = new HashSet<>(); + public static List<ServerName> parseMasterAddrs(Configuration conf) throws UnknownHostException { Review comment: nit: why set to list? Set was used to avoid duplicates fwiw. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
