hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r796850 - in /hadoop/hbase/trunk/src: java/org/apache/hadoop/hbase/ java/org/apache/hadoop/hbase/regionserver/ java/org/apache/hadoop/hbase/util/ test/org/apache/hadoop/hbase/util/
Date Wed, 22 Jul 2009 19:33:04 GMT
Author: stack
Date: Wed Jul 22 19:33:04 2009
New Revision: 796850

URL: http://svn.apache.org/viewvc?rev=796850&view=rev
Log:
HBASE-1215 migration; metautils scan of meta region was broken; wouldn't see first row

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Migrate.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestBytes.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java?rev=796850&r1=796849&r2=796850&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java Wed Jul 22
19:33:04 2009
@@ -381,6 +381,13 @@
   }
 
   /**
+   * @param key Key whose key and value we're to remove from HCD parameters.
+   */
+  public void remove(final byte [] key) {
+    values.remove(new ImmutableBytesWritable(key));
+  }
+
+  /**
    * @param key The key.
    * @param value The value.
    */

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=796850&r1=796849&r2=796850&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed
Jul 22 19:33:04 2009
@@ -2042,10 +2042,10 @@
     }
     String lockName = String.valueOf(lockId);
     Integer rl = null;
-    synchronized(rowlocks) {
+    synchronized (rowlocks) {
       rl = rowlocks.get(lockName);
     }
-    if(rl == null) {
+    if (rl == null) {
       throw new IOException("Invalid row lock");
     }
     this.leases.renewLease(lockName);

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java?rev=796850&r1=796849&r2=796850&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/MetaUtils.java Wed Jul 22 19:33:04
2009
@@ -192,23 +192,33 @@
     if (this.rootRegion == null) {
       openRootRegion();
     }
+    scanMetaRegion(this.rootRegion, listener);
+  }
 
+  /**
+   * Scan the passed in metaregion <code>m</code> invoking the passed
+   * <code>listener</code> per row found.
+   * @param m
+   * @param listener
+   * @throws IOException
+   */
+  public void scanMetaRegion(final HRegion r, final ScannerListener listener)
+  throws IOException {
     Scan scan = new Scan();
     scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    InternalScanner rootScanner = this.rootRegion.getScanner(scan);
-
+    InternalScanner s = r.getScanner(scan);
     try {
       List<KeyValue> results = new ArrayList<KeyValue>();
       boolean hasNext = true;
       do {
-        hasNext = rootScanner.next(results);
+        hasNext = s.next(results);
         HRegionInfo info = null;
         for (KeyValue kv: results) {
           info = Writables.getHRegionInfoOrNull(kv.getValue());
           if (info == null) {
-            LOG.warn("region info is null for row " +
-                Bytes.toString(kv.getRow()) + " in table " +
-                HConstants.ROOT_TABLE_NAME);
+            LOG.warn("Region info is null for row " +
+              Bytes.toString(kv.getRow()) + " in table " +
+              r.getTableDesc().getNameAsString());
           }
           continue;
         }
@@ -218,7 +228,7 @@
         results.clear();
       } while (hasNext);
     } finally {
-      rootScanner.close();
+      r.close();
     }
   }
 
@@ -244,46 +254,6 @@
     scanMetaRegion(metaRegion, listener);
   }
 
-  /**
-   * Scan the passed in metaregion <code>m</code> invoking the passed
-   * <code>listener</code> per row found.
-   * @param m
-   * @param listener
-   * @throws IOException
-   */
-  public void scanMetaRegion(final HRegion m, final ScannerListener listener)
-  throws IOException {
-    
-    Scan scan = new Scan();
-    scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    InternalScanner metaScanner = m.getScanner(scan);
-    
-    try {
-      List<KeyValue> results = new ArrayList<KeyValue>();
-      while (metaScanner.next(results)) {
-        HRegionInfo info = null;
-        for (KeyValue kv: results) {
-          if(kv.matchingColumn(HConstants.CATALOG_FAMILY,
-              HConstants.REGIONINFO_QUALIFIER)) {
-            info = Writables.getHRegionInfoOrNull(kv.getValue());
-            if (info == null) {
-              LOG.warn("region info is null for row " +
-                Bytes.toString(kv.getRow()) +
-                " in table " + HConstants.META_TABLE_NAME);
-            }
-            break;
-          }
-        }
-        if (!listener.processRow(info)) {
-          break;
-        }
-        results.clear();
-      }
-    } finally {
-      metaScanner.close();
-    }
-  }
-
   private synchronized HRegion openRootRegion() throws IOException {
     if (this.rootRegion != null) {
       return this.rootRegion;

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Migrate.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Migrate.java?rev=796850&r1=796849&r2=796850&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Migrate.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/Migrate.java Wed Jul 22 19:33:04
2009
@@ -247,8 +247,9 @@
     final MetaUtils utils = new MetaUtils(this.conf);
     final List<HRegionInfo> metas = new ArrayList<HRegionInfo>();
     try {
+      // Rewrite root.
       rewriteHRegionInfo(utils.getRootRegion().getRegionInfo());
-      // Scan the root region
+      // Scan the root region to rewrite metas.
       utils.scanRootRegion(new MetaUtils.ScannerListener() {
         public boolean processRow(HRegionInfo info)
         throws IOException {
@@ -261,7 +262,7 @@
           return true;
         }
       });
-      // Scan meta.
+      // Scan meta to rewrite table stuff.
       for (HRegionInfo hri: metas) {
         final HRegion h = utils.getMetaRegion(hri);
         utils.scanMetaRegion(h, new MetaUtils.ScannerListener() {
@@ -432,8 +433,11 @@
       // Set compression to none.  Previous was 'none'.  Needs to be upper-case.
       // Any other compression we are turning off.  Have user enable it.
       hcd.setCompressionType(Algorithm.NONE);
+      // Remove the old MEMCACHE_FLUSHSIZE if present
+      hcd.remove(Bytes.toBytes("MEMCACHE_FLUSHSIZE"));
+      result = true;
     }
-    return true;
+    return result;
   }
 
 

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestBytes.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestBytes.java?rev=796850&r1=796849&r2=796850&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestBytes.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestBytes.java Wed Jul 22 19:33:04
2009
@@ -25,6 +25,17 @@
 import junit.framework.TestCase;
 
 public class TestBytes extends TestCase {
+  public void testNullHashCode() {
+    byte [] b = null;
+    Exception ee = null;
+    try {
+      Bytes.hashCode(b);
+    } catch (Exception e) {
+      ee = e;
+    }
+    assertNotNull(ee);
+  }
+
   public void testSplit() throws Exception {
     byte [] lowest = Bytes.toBytes("AAA");
     byte [] middle = Bytes.toBytes("CCC");



Mime
View raw message