hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r614588 - in /lucene/hadoop/trunk/src/contrib/hbase: ./ src/java/org/apache/hadoop/hbase/ src/test/org/apache/hadoop/hbase/
Date Wed, 23 Jan 2008 17:43:27 GMT
Author: stack
Date: Wed Jan 23 09:43:22 2008
New Revision: 614588

URL: http://svn.apache.org/viewvc?rev=614588&view=rev
Log:
HADOOP-2686 Removed tables stick around in .META.

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConstants.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInfo.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestToString.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Wed Jan 23 09:43:22 2008
@@ -145,6 +145,7 @@
                hadoop instead
    HADOOP-2668 Documentation and improved logging so fact that hbase now
                requires migration comes as less of a surprise
+   HADOOP-2686 Removed tables stick around in .META.
    
   IMPROVEMENTS
    HADOOP-2401 Add convenience put method that takes writable

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConstants.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConstants.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConstants.java
Wed Jan 23 09:43:22 2008
@@ -149,6 +149,12 @@
   
   /** the upper half of a split region */
   static final Text COL_SPLITB = new Text(COLUMN_FAMILY_STR + "splitB");
+  
+  /** All the columns in the catalog -ROOT- and .META. tables.
+   */
+  static final Text[] ALL_META_COLUMNS = {COL_REGIONINFO, COL_SERVER,
+    COL_STARTCODE, COL_SPLITA, COL_SPLITB};
+
   // Other constants
 
   /**

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java Wed
Jan 23 09:43:22 2008
@@ -332,19 +332,13 @@
       
       if (!hasReferencesA && !hasReferencesB) {
         LOG.info("Deleting region " + parent.getRegionName() +
-        " because daughter splits no longer hold references");
+          " because daughter splits no longer hold references");
         if (!HRegion.deleteRegion(fs, rootdir, parent)) {
           LOG.warn("Deletion of " + parent.getRegionName() + " failed");
         }
         
-        BatchUpdate b = new BatchUpdate(rand.nextLong());
-        long lockid = b.startUpdate(parent.getRegionName());
-        b.delete(lockid, COL_REGIONINFO);
-        b.delete(lockid, COL_SERVER);
-        b.delete(lockid, COL_STARTCODE);
-        b.delete(lockid, COL_SPLITA);
-        b.delete(lockid, COL_SPLITB);
-        srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
+        HRegion.removeRegionFromMETA(srvr, metaRegionName,
+          parent.getRegionName());
         result = true;
       } else if (LOG.isDebugEnabled()) {
         // If debug, note we checked and current state of daughters.
@@ -2069,7 +2063,7 @@
             break;
           }
           LOG.info(info.getRegionName() + " was on shutdown server <" +
-              serverName + "> (or server is null). Marking unassigned if " +
+              serverName + "> (or server is null). Marking unassigned in " +
           "meta and clearing pendingRegions");
 
           if (info.isMetaTable()) {
@@ -2126,19 +2120,13 @@
         }
       }
 
-      // Remove server from root/meta entries
+      // Update server in root/meta entries
       for (ToDoEntry e: toDoList) {
-        BatchUpdate b = new BatchUpdate(rand.nextLong());
-        long lockid = b.startUpdate(e.row);
         if (e.deleteRegion) {
-          b.delete(lockid, COL_REGIONINFO);
-        } else if (e.regionOffline) {
-          e.info.setOffline(true);
-          b.put(lockid, COL_REGIONINFO, Writables.getBytes(e.info));
+          HRegion.removeRegionFromMETA(server, regionName, e.row);
+        } else {
+          HRegion.offlineRegionInMETA(server, regionName, e.info);
         }
-        b.delete(lockid, COL_SERVER);
-        b.delete(lockid, COL_STARTCODE);
-        server.batchUpdate(regionName, System.currentTimeMillis(), b);
       }
 
       // Get regions reassigned
@@ -2384,22 +2372,14 @@
           return true;
         }
 
-        HRegionInterface server = getMetaServer();
         try {
-          BatchUpdate b = new BatchUpdate(rand.nextLong());
-          long lockid = b.startUpdate(regionInfo.getRegionName());
-
           if (deleteRegion) {
-            b.delete(lockid, COL_REGIONINFO);
-
-          } else if (!reassignRegion ) {
-            regionInfo.setOffline(true);
-            b.put(lockid, COL_REGIONINFO, Writables.getBytes(regionInfo));
+            HRegion.removeRegionFromMETA(getMetaServer(), metaRegionName,
+              regionInfo.getRegionName());
+          } else {
+            HRegion.offlineRegionInMETA(getMetaServer(), metaRegionName,
+              regionInfo);
           }
-          b.delete(lockid, COL_SERVER);
-          b.delete(lockid, COL_STARTCODE);
-          server.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
-
           break;
 
         } catch (IOException e) {
@@ -3012,9 +2992,11 @@
 
     @Override
     protected void updateRegionInfo(BatchUpdate b,
-        @SuppressWarnings("unused") HRegionInfo i) {
-      
-      b.delete(lockid, COL_REGIONINFO);
+        @SuppressWarnings("unused") HRegionInfo info) {
+      for (int i = 0; i < ALL_META_COLUMNS.length; i++) {
+        // Be sure to clean all columns
+        b.delete(lockid, ALL_META_COLUMNS[i]);
+      }
     }
   }
 

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java Wed
Jan 23 09:43:22 2008
@@ -1816,6 +1816,7 @@
    * @param r HRegion to add to <code>meta</code>
    *
    * @throws IOException
+   * @see {@link #removeRegionFromMETA(HRegion, HRegion)}
    */
   static void addRegionToMETA(HRegion meta, HRegion r) throws IOException {
     meta.checkResources();
@@ -1833,7 +1834,52 @@
       meta.releaseRowLock(row);
     }
   }
-  
+
+  /**
+   * Delete a region's meta information from the passed
+   * <code>meta</code> region.
+   * 
+   * @param srvr META server to be updated
+   * @param metaRegionName Meta region name
+   * @param regionNmae HRegion to remove from <code>meta</code>
+   *
+   * @throws IOException
+   * @see {@link #addRegionToMETA(HRegion, HRegion)}
+   */
+  static void removeRegionFromMETA(final HRegionInterface srvr,
+      final Text metaRegionName, final Text regionName)
+  throws IOException {
+    BatchUpdate b = new BatchUpdate(rand.nextLong());
+    long lockid = b.startUpdate(regionName);
+    for (int i = 0; i < ALL_META_COLUMNS.length; i++) {
+      b.delete(lockid, ALL_META_COLUMNS[i]);
+    }
+    srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
+  }
+
+  /**
+   * Utility method used by HMaster marking regions offlined.
+   * @param srvr META server to be updated
+   * @param metaRegionName Meta region name
+   * @param info HRegion to update in <code>meta</code>
+   *
+   * @throws IOException
+   * @see {@link #addRegionToMETA(HRegion, HRegion)}
+   */
+  static void offlineRegionInMETA(final HRegionInterface srvr,
+      final Text metaRegionName, final HRegionInfo info)
+  throws IOException {
+    BatchUpdate b = new BatchUpdate(rand.nextLong());
+    long lockid = b.startUpdate(info.getRegionName());
+    info.setOffline(true);
+    b.put(lockid, COL_REGIONINFO, Writables.getBytes(info));
+    b.delete(lockid, COL_SERVER);
+    b.delete(lockid, COL_STARTCODE);
+    // If carrying splits, they'll be in place when we show up on new
+    // server.
+    srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
+  }
+
   /**
    * Deletes all the files for a HRegion
    * 

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInfo.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInfo.java
Wed Jan 23 09:43:22 2008
@@ -252,7 +252,7 @@
   public String toString() {
     return "regionname: " + this.regionName.toString() + ", startKey: <" +
       this.startKey.toString() + ">, endKey: <" + this.endKey.toString() + 
-      ">, encodedName(" + getEncodedName() + ")" +
+      ">, encodedName: " + getEncodedName() + "," +
       (isOffline()? " offline: true,": "") + (isSplit()? " split: true,": "") +
       " tableDesc: {" + this.tableDesc.toString() + "}";
   }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
Wed Jan 23 09:43:22 2008
@@ -132,6 +132,9 @@
    * @param family HColumnDescriptor of familyto add.
    */
   public void addFamily(HColumnDescriptor family) {
+    if (family.getName() == null || family.getName().getLength() <= 0) {
+      throw new NullPointerException("Family name cannot be null or empty");
+    }
     families.put(family.getName(), family);
   }
 

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestToString.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestToString.java?rev=614588&r1=614587&r2=614588&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestToString.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestToString.java
Wed Jan 23 09:43:22 2008
@@ -55,7 +55,7 @@
     HRegionInfo hri = HRegionInfo.rootRegionInfo;
     System.out.println(hri.toString());
     assertEquals("HRegionInfo", 
-      "regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName(70236052)
tableDesc: " +
+      "regionname: -ROOT-,,0, startKey: <>, endKey: <>, encodedName: 70236052,
tableDesc: " +
       "{name: -ROOT-, families: {info:={name: info, max versions: 1, " +
       "compression: NONE, in memory: false, max length: 2147483647, bloom " +
       "filter: none}}}", hri.toString());



Mime
View raw message