You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/11/04 18:57:44 UTC

[GitHub] [hbase] apurtell commented on a change in pull request #781: HBASE-18095: Zookeeper-less client connection implementation

apurtell commented on a change in pull request #781: HBASE-18095: Zookeeper-less client connection implementation
URL: https://github.com/apache/hbase/pull/781#discussion_r342214392
 
 

 ##########
 File path: hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHMasterAsyncRegistry.java
 ##########
 @@ -0,0 +1,140 @@
+/**
+ * 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 org.apache.commons.io.IOUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.testclassification.ClientTests;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hbase.thirdparty.com.google.common.base.Joiner;
+import org.apache.hbase.thirdparty.com.google.common.net.HostAndPort;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.apache.hadoop.hbase.HConstants.META_REPLICAS_NUM;
+import static org.junit.Assert.assertEquals;
+
+@Category({ LargeTests.class, ClientTests.class })
+public class TestHMasterAsyncRegistry {
+  private static final Logger LOG = LoggerFactory.getLogger(TestHMasterAsyncRegistry.class);
+  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+  private static final TableName TEST_TABLE = TableName.valueOf("foo");
+  private static final byte[] COL_FAM = Bytes.toBytes("cf");
+  private static final byte[] QUALIFIER = Bytes.toBytes("col");
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+      HBaseClassTestRule.forClass(TestHMasterAsyncRegistry.class);
+
+  // Automatically cleaned up on cluster shutdown.
+  private static AsyncClusterConnection customConnection;
+  private static HMasterAsyncRegistry REGISTRY;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    TEST_UTIL.getConfiguration().setInt(META_REPLICAS_NUM, 3);
+    TEST_UTIL.startMiniCluster(3);
+    Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
+    List<HostAndPort> hostAndPorts = new ArrayList<>();
+    String masterHostName =
+        TEST_UTIL.getMiniHBaseCluster().getMaster().getServerName().getHostname();
+    int masterPort = TEST_UTIL.getMiniHBaseCluster().getMaster().getServerName().getPort();
+    // Add some invalid hostAndPort configs. The implementation should be resilient enough to
+    // skip those and probe for the only working master.
+    // 1. Valid hostname but invalid port
+    hostAndPorts.add(HostAndPort.fromParts(masterHostName, 10001));
+    // 2. Invalid hostname but valid port
+    hostAndPorts.add(HostAndPort.fromParts("foo.bar", masterPort));
+    // 3. Invalid hostname and port.
+    hostAndPorts.add(HostAndPort.fromParts("foo.bar", 10003));
+    // 4. Finally valid host:port
+    hostAndPorts.add(HostAndPort.fromParts(masterHostName, masterPort));
+    final String config = Joiner.on(",").join(hostAndPorts);
+    conf.set(HMasterAsyncRegistry.CONF_KEY, config);
+    conf.set(AsyncRegistryFactory.REGISTRY_IMPL_CONF_KEY, HMasterAsyncRegistry.class.getName());
 
 Review comment:
   Should somehow distinguish between master and not-master roles and choose the right one, allowing for custom config override.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services