You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2013/11/18 22:44:34 UTC
svn commit: r1543178 -
/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
Author: mbertozzi
Date: Mon Nov 18 21:44:34 2013
New Revision: 1543178
URL: http://svn.apache.org/r1543178
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/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java?rev=1543178&r1=1543177&r2=1543178&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java (original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java Mon Nov 18 21:44:34 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 {