hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1543179 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
Date Mon, 18 Nov 2013 21:44:35 GMT
Author: mbertozzi
Date: Mon Nov 18 21:44:35 2013
New Revision: 1543179

URL: http://svn.apache.org/r1543179
Log:
HBASE-9973 Users with 'Admin' ACL permission will lose permissions after upgrade to 0.96.x
from 0.94.x or 0.92.x (Himanshu Vashishtha)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java?rev=1543179&r1=1543178&r2=1543179&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
Mon Nov 18 21:44:35 2013
@@ -32,6 +32,8 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -39,6 +41,10 @@ import org.apache.hadoop.hbase.Namespace
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionFileSystem;
@@ -400,10 +406,9 @@ public class NamespaceUpgrade implements
                 oldDesc,
                 null);
         region.initialize();
-        //Run major compaction to archive old stores
-        //to keep any snapshots to _acl_ unbroken
-        region.compactStores(true);
-        region.waitForFlushesAndCompactions();
+        updateAcls(region);
+        // closing the region would flush it so we don't need an explicit flush to save
+        // acl changes.
         region.close();
 
         //Create new region dir
@@ -443,6 +448,28 @@ public class NamespaceUpgrade implements
     }
   }
 
+  /**
+   * Deletes the old _acl_ entry, and inserts a new one using namespace.
+   * @param region
+   * @throws IOException
+   */
+  private void updateAcls(HRegion region) throws IOException {
+    byte[] rowKey = Bytes.toBytes(NamespaceUpgrade.OLD_ACL);
+    // get the old _acl_ entry, if present.
+    Get g = new Get(rowKey);
+    Result r = region.get(g);
+    if (r == null || r.size() == 0) return;
+    // create a put for new _acl_ entry with rowkey as hbase:acl
+    Put p = new Put(AccessControlLists.ACL_GLOBAL_NAME);
+    for (Cell c : r.rawCells()) {
+      p.add(CellUtil.cloneFamily(c), CellUtil.cloneQualifier(c), CellUtil.cloneValue(c));
+    }
+    region.put(p);
+    // delete the old entry
+    Delete del = new Delete(rowKey);
+    region.delete(del);
+  }
+
   //Culled from FSTableDescriptors
   private static HTableDescriptor readTableDescriptor(FileSystem fs,
                                                       FileStatus status) throws IOException
{



Mime
View raw message