You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2015/02/04 05:06:31 UTC

hbase git commit: HBASE-12957 region_mover#isSuccessfulScan may be extremely slow on region with lots of expired data (Hongyu Bi)

Repository: hbase
Updated Branches:
  refs/heads/master 5c1b08c5c -> 4388fed83


HBASE-12957 region_mover#isSuccessfulScan may be extremely slow on region with lots of expired data (Hongyu Bi)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4388fed8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4388fed8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4388fed8

Branch: refs/heads/master
Commit: 4388fed83028325cfe75fc0a8787183db2a58855
Parents: 5c1b08c
Author: tedyu <yu...@gmail.com>
Authored: Tue Feb 3 20:06:23 2015 -0800
Committer: tedyu <yu...@gmail.com>
Committed: Tue Feb 3 20:06:23 2015 -0800

----------------------------------------------------------------------
 bin/region_mover.rb                             |  6 +-
 .../regionserver/TestRegionServerHostname.java  | 98 ++++++++++++++++++++
 2 files changed, 102 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4388fed8/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 7a09854..78979d9 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -31,6 +31,8 @@ import org.apache.hadoop.hbase.client.Scan
 import org.apache.hadoop.hbase.client.HTable
 import org.apache.hadoop.hbase.client.HConnectionManager
 import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
+import org.apache.hadoop.hbase.filter.InclusiveStopFilter;
+import org.apache.hadoop.hbase.filter.FilterList;
 import org.apache.hadoop.hbase.util.Bytes
 import org.apache.hadoop.hbase.util.Writables
 import org.apache.hadoop.conf.Configuration
@@ -95,10 +97,10 @@ end
 # Trys to scan a row from passed region
 # Throws exception if can't
 def isSuccessfulScan(admin, r)
-  scan = Scan.new(r.getStartKey()) 
+  scan = Scan.new(r.getStartKey(), r.getStartKey())
   scan.setBatch(1)
   scan.setCaching(1)
-  scan.setFilter(FirstKeyOnlyFilter.new()) 
+  scan.setFilter(FilterList.new(FirstKeyOnlyFilter.new(),InclusiveStopFilter().new(r.getStartKey())))
   begin
     table = HTable.new(admin.getConfiguration(), r.getTableName())
     scanner = table.getScanner(scan)

http://git-wip-us.apache.org/repos/asf/hbase/blob/4388fed8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
new file mode 100644
index 0000000..523911b
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
@@ -0,0 +1,98 @@
+/**
+ * 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.regionserver;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RegionServerTests;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Tests for the hostname specification by region server
+ */
+@Category({RegionServerTests.class, MediumTests.class})
+public class TestRegionServerHostname {
+  private static final Log LOG = LogFactory.getLog(TestRegionServerHostname.class);
+  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+
+  @Test (timeout=30000)
+  public void testInvalidRegionServerHostname() throws Exception {
+    final int NUM_MASTERS = 1;
+    final int NUM_RS = 1;
+    String invalidHostname = "hostAddr";
+    TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, invalidHostname);
+    try {
+      TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
+    } catch (IOException ioe) {
+      Throwable t1 = ioe.getCause();
+      Throwable t2 = t1.getCause();
+      assertTrue(t2.getMessage().contains("Failed resolve of " + invalidHostname));
+      return;
+    } finally {
+      TEST_UTIL.shutdownMiniCluster();
+    }
+    assertTrue("Failed to validate against invalid hostname", false);
+  }
+
+  @Test(timeout=120000)
+  public void testRegionServerHostname() throws Exception {
+    final int NUM_MASTERS = 1;
+    final int NUM_RS = 1;
+    Enumeration<NetworkInterface> netInterfaceList = NetworkInterface.getNetworkInterfaces();
+
+    while (netInterfaceList.hasMoreElements()) {
+      NetworkInterface ni = netInterfaceList.nextElement();
+      Enumeration<InetAddress> addrList = ni.getInetAddresses();
+      // iterate through host addresses and use each as hostname
+      while (addrList.hasMoreElements()) {
+        InetAddress addr = addrList.nextElement();
+        if (addr.isLoopbackAddress() || addr.isLinkLocalAddress()) continue;
+        if (addr.isMulticastAddress()) continue;
+        String hostAddr = addr.getHostAddress();
+        LOG.info("Found " + hostAddr + " on " + ni);
+        
+        TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, hostAddr);
+        TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
+        try {
+          ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
+          List<String> servers = ZKUtil.listChildrenNoWatch(zkw, zkw.rsZNode);
+          assertTrue(servers.size() > 0);
+          for (String server : servers) {
+            assertTrue(server.startsWith(hostAddr+","));
+          }
+          zkw.close();
+        } finally {
+          TEST_UTIL.shutdownMiniCluster();
+        }
+      }
+    }
+  }
+}