Repository: hbase Updated Branches: refs/heads/0.98 f8d50681f -> dde62f16d
HBASE-11435 Visibility labelled cells fail to getting replicated. (Anoop) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/dde62f16 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/dde62f16 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/dde62f16 Branch: refs/heads/0.98 Commit: dde62f16d244a6d313232eb548fcd6e3c94a0a60 Parents: f8d5068 Author: anoopsjohn <[email protected]> Authored: Tue Jul 1 18:42:47 2014 +0530 Committer: anoopsjohn <[email protected]> Committed: Tue Jul 1 18:42:47 2014 +0530 ---------------------------------------------------------------------- .../security/visibility/VisibilityController.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/dde62f16/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java index ad15466..e634840 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java @@ -154,6 +154,8 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb private Map<InternalScanner,String> scannerOwners = new MapMaker().weakKeys().makeMap(); + List<String> superUsers; + static { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); @@ -202,6 +204,7 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb // ScanLabelGenerator to be instantiated only with Region Observer. scanLabelGenerators = VisibilityUtils.getScanLabelGenerators(this.conf); } + this.superUsers = getSystemAndSuperUsers(); } @Override @@ -620,8 +623,7 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb Put p = new Put(Bytes.toBytes(SYSTEM_LABEL_ORDINAL)); p.addImmutable(LABELS_TABLE_FAMILY, LABEL_QUALIFIER, Bytes.toBytes(SYSTEM_LABEL)); // Set auth for "system" label for all super users. - List<String> superUsers = getSystemAndSuperUsers(); - for (String superUser : superUsers) { + for (String superUser : this.superUsers) { p.addImmutable( LABELS_TABLE_FAMILY, Bytes.toBytes(superUser), DUMMY_VALUE, LABELS_TABLE_TAGS); } @@ -800,6 +802,12 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb // Checks whether cell contains any tag with type as VISIBILITY_TAG_TYPE. // This tag type is reserved and should not be explicitly set by user. private boolean checkForReservedVisibilityTagPresence(Cell cell) throws IOException { + // Bypass this check when the operation is done by a system/super user. + // This is done because, while Replication, the Cells coming to the peer cluster with reserved + // typed tags and this is fine and should get added to the peer cluster table + if (isSystemOrSuperUser()) { + return true; + } if (cell.getTagsLength() > 0) { Iterator<Tag> tagsItr = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength()); @@ -1059,9 +1067,8 @@ public class VisibilityController extends BaseRegionObserver implements MasterOb } private boolean isSystemOrSuperUser() throws IOException { - List<String> superUsers = getSystemAndSuperUsers(); User activeUser = getActiveUser(); - return superUsers.contains(activeUser.getShortName()); + return this.superUsers.contains(activeUser.getShortName()); } @Override
