hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r950700 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/HMaster.java src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
Date Wed, 02 Jun 2010 18:12:11 GMT
Author: todd
Date: Wed Jun  2 18:12:11 2010
New Revision: 950700

URL: http://svn.apache.org/viewvc?rev=950700&view=rev
Log:
HBASE-2560. Fix IllegalArgumentException when manually splitting table from web UI

Added:
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=950700&r1=950699&r2=950700&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Jun  2 18:12:11 2010
@@ -368,6 +368,8 @@ Release 0.21.0 - Unreleased
    HBASE-2620  REST tests don't use ephemeral ports
    HBASE-2635  ImmutableBytesWritable ignores offset in several cases
    HBASE-2654  Add additional maven repository temporarily to fetch Guava
+   HBASE-2560  Fix IllegalArgumentException when manually splitting table
+               from web UI
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=950700&r1=950699&r2=950700&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed Jun  2 18:12:11
2010
@@ -808,7 +808,7 @@ public class HMaster extends Thread impl
   }
 
   // TODO: Redo so this method does not duplicate code with subsequent methods.
-  private List<Pair<HRegionInfo,HServerAddress>> getTableRegions(
+  List<Pair<HRegionInfo,HServerAddress>> getTableRegions(
       final byte [] tableName)
   throws IOException {
     List<Pair<HRegionInfo,HServerAddress>> result =
@@ -834,7 +834,7 @@ public class HMaster extends Thread impl
               data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
           if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
             byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
-            if (value != null) {
+            if (value != null && value.length > 0) {
               HServerAddress server = new HServerAddress(Bytes.toString(value));
               result.add(new Pair<HRegionInfo,HServerAddress>(info, server));
             }
@@ -849,7 +849,7 @@ public class HMaster extends Thread impl
     return result;
   }
 
-  private Pair<HRegionInfo,HServerAddress> getTableRegionClosest(
+  Pair<HRegionInfo,HServerAddress> getTableRegionClosest(
       final byte [] tableName, final byte [] rowKey)
   throws IOException {
     Set<MetaRegion> regions =
@@ -873,7 +873,7 @@ public class HMaster extends Thread impl
             if ((Bytes.compareTo(info.getStartKey(), rowKey) >= 0) &&
                 (Bytes.compareTo(info.getEndKey(), rowKey) < 0)) {
                 byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
-                if (value != null) {
+                if (value != null && value.length > 0) {
                   HServerAddress server =
                     new HServerAddress(Bytes.toString(value));
                   return new Pair<HRegionInfo,HServerAddress>(info, server);
@@ -890,7 +890,7 @@ public class HMaster extends Thread impl
     return null;
   }
 
-  private Pair<HRegionInfo,HServerAddress> getTableRegionFromName(
+  Pair<HRegionInfo,HServerAddress> getTableRegionFromName(
       final byte [] regionName)
   throws IOException {
     byte [] tableName = HRegionInfo.parseRegionName(regionName)[0];
@@ -906,7 +906,7 @@ public class HMaster extends Thread impl
       HRegionInfo info = Writables.getHRegionInfo(
           data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
       byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
-      if(value != null) {
+      if(value != null && value.length > 0) {
         HServerAddress server =
           new HServerAddress(Bytes.toString(value));
         return new Pair<HRegionInfo,HServerAddress>(info, server);

Added: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java?rev=950700&view=auto
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java (added)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java Wed Jun  2 18:12:11
2010
@@ -0,0 +1,128 @@
+/**
+ * Copyright 2010 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.master;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.hadoop.hbase.HMsg;
+import org.apache.hadoop.hbase.HServerInfo;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Pair;
+
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class TestMaster {
+  private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+  private static final Log LOG = LogFactory.getLog(TestMasterWithDisabling.class);
+  private static final byte[] TABLENAME = Bytes.toBytes("TestMaster");
+  private static final byte[] FAMILYNAME = Bytes.toBytes("fam");
+
+  @BeforeClass
+  public static void beforeAllTests() throws Exception {
+    // Start a cluster of two regionservers.
+    TEST_UTIL.startMiniCluster(1);
+  }
+
+  @AfterClass
+  public static void afterAllTests() throws IOException {
+    TEST_UTIL.shutdownMiniCluster();
+  }
+
+  @Test
+  public void testMasterOpsWhileSplitting() throws Exception {
+    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+    HMaster m = cluster.getMaster();
+    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+
+    TEST_UTIL.createTable(TABLENAME, FAMILYNAME);
+    TEST_UTIL.loadTable(new HTable(TABLENAME), FAMILYNAME);
+
+    CountDownLatch aboutToOpen = new CountDownLatch(1);
+    CountDownLatch proceed = new CountDownLatch(1);
+    RegionOpenListener list = new RegionOpenListener(aboutToOpen, proceed);
+    m.getRegionServerOperationQueue().registerRegionServerOperationListener(list);
+
+    admin.split(TABLENAME);
+    aboutToOpen.await(60, TimeUnit.SECONDS);
+
+    try {
+      m.getTableRegions(TABLENAME);
+      Pair<HRegionInfo,HServerAddress> pair =
+        m.getTableRegionClosest(TABLENAME, Bytes.toBytes("cde"));
+      assertNull(pair);
+      /**
+       * TODO: these methods return null when the regions are not deployed.
+       * These tests should be uncommented after HBASE-2656.
+      assertNotNull(pair);
+      m.getTableRegionFromName(pair.getFirst().getRegionName());
+      */
+    } finally {
+      proceed.countDown();
+    }
+  }
+
+  static class RegionOpenListener implements RegionServerOperationListener {
+    CountDownLatch aboutToOpen, proceed;
+
+    public RegionOpenListener(
+      CountDownLatch aboutToOpen, CountDownLatch proceed)
+    {
+      this.aboutToOpen = aboutToOpen;
+      this.proceed = proceed;
+    }
+
+    @Override
+    public boolean process(HServerInfo serverInfo, HMsg incomingMsg) {
+      if (!incomingMsg.isType(HMsg.Type.MSG_REPORT_OPEN)) {
+        return true;
+      }
+      try {
+        aboutToOpen.countDown();
+        proceed.await(60, TimeUnit.SECONDS);
+      } catch (InterruptedException ie) {
+        throw new RuntimeException(ie);
+      }
+      return true;
+    }
+
+    @Override
+    public boolean process(RegionServerOperation op) throws IOException {
+      return true;
+    }
+
+    @Override
+    public void processed(RegionServerOperation op) {
+    }
+  }
+
+}



Mime
View raw message