diff --git src/main/java/org/apache/hadoop/hbase/master/HMaster.java src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 520eb14..6942abb 100644 --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -652,7 +652,8 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server { // Everafter, the HSI combination 'server name' is what uniquely identifies // the incoming RegionServer. InetSocketAddress address = new InetSocketAddress( - HBaseServer.getRemoteIp().getHostName(), + Strings.domainNamePointerToHostName( + HBaseServer.getRemoteIp().getHostName()), serverInfo.getServerAddress().getPort()); serverInfo.setServerAddress(new HServerAddress(address)); diff --git src/test/java/org/apache/hadoop/hbase/master/TestMaster.java src/test/java/org/apache/hadoop/hbase/master/TestMaster.java index 752c1ca..771a859 100644 --- src/test/java/org/apache/hadoop/hbase/master/TestMaster.java +++ src/test/java/org/apache/hadoop/hbase/master/TestMaster.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HServerAddress; +import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.hbase.catalog.MetaReader; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HTable; @@ -37,6 +38,7 @@ import org.apache.hadoop.hbase.util.Pair; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -66,6 +68,19 @@ public class TestMaster { } @Test + public void testMasterCorrectHostnameFormatForOnlineRegions() throws Exception { + MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); + HMaster m = cluster.getMaster(); + for (Map.Entry e: + m.getServerManager().getOnlineServers().entrySet()) { + HServerInfo hsi = e.getValue(); + String hostName = hsi.getHostname(); + LOG.info("Online region hostname: " + hostName); + assertFalse(hostName.endsWith(".")); + } + } + + @Test public void testMasterOpsWhileSplitting() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); HMaster m = cluster.getMaster(); diff --git src/test/java/org/apache/hadoop/hbase/util/TestStrings.java src/test/java/org/apache/hadoop/hbase/util/TestStrings.java new file mode 100644 index 0000000..193eef4 --- /dev/null +++ src/test/java/org/apache/hadoop/hbase/util/TestStrings.java @@ -0,0 +1,38 @@ +/* + * Copyright The Apache Software Foundation + * + * 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.util; + +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; + +import org.apache.hadoop.hbase.util.Strings; + +/** + * Tests functions in the Strings util class + */ +public class TestStrings { + + @Test + public void testDomainNamePointerToHostName() { + assertEquals(Strings.domainNamePointerToHostName("hbase.apache.org."), + "hbase.apache.org"); + } +}