Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.Tag


       throws IOException {
     List<Permission> results = Lists.newArrayList();
     byte[] tags = CellUtil.getTagArray(cell);
     Iterator<Tag> tagsIterator = CellUtil.tagsIterator(tags, 0, tags.length);
     while (tagsIterator.hasNext()) {
       Tag tag = tagsIterator.next();
       if (tag.getType() == ACL_TAG_TYPE) {
         // Deserialize the table permissions from the KV
         ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
           AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
             tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
         // Are there permissions for this user?
         List<Permission> userPerms = kvPerms.get(user.getShortName());
         if (userPerms != null) {
           results.addAll(userPerms);
         }
View Full Code Here


    Iterator<Tag> tagsItr = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLength());
    boolean visibilityTagPresent = false;
    while (tagsItr.hasNext()) {
      boolean includeKV = true;
      Tag tag = tagsItr.next();
      if (tag.getType() == VisibilityUtils.VISIBILITY_TAG_TYPE) {
        visibilityTagPresent = true;
        int offset = tag.getTagOffset();
        int endOffset = offset + tag.getTagLength();
        while (offset < endOffset) {
          Pair<Integer, Integer> result = StreamUtils.readRawVarint32(tag.getBuffer(), offset);
          int currLabelOrdinal = result.getFirst();
          if (currLabelOrdinal < 0) {
            // check for the absence of this label in the Scan Auth labels
            // ie. to check BitSet corresponding bit is 0
            int temp = -currLabelOrdinal;
View Full Code Here

    List<Tag> tags = new ArrayList<Tag>();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    if (node.isSingleNode()) {
      writeLabelOrdinalsToStream(node, dos);
      tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
      baos.reset();
    } else {
      NonLeafExpressionNode nlNode = (NonLeafExpressionNode) node;
      if (nlNode.getOperator() == Operator.OR) {
        for (ExpressionNode child : nlNode.getChildExps()) {
          writeLabelOrdinalsToStream(child, dos);
          tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
          baos.reset();
        }
      } else {
        writeLabelOrdinalsToStream(nlNode, dos);
        tags.add(new Tag(VisibilityUtils.VISIBILITY_TAG_TYPE, baos.toByteArray()));
        baos.reset();
      }
    }
    return tags;
  }
View Full Code Here

    }
    // Adding all other tags
    Iterator<Tag> tagsItr = CellUtil.tagsIterator(newCell.getTagsArray(), newCell.getTagsOffset(),
        newCell.getTagsLength());
    while (tagsItr.hasNext()) {
      Tag tag = tagsItr.next();
      if (tag.getType() != VisibilityUtils.VISIBILITY_TAG_TYPE) {
        tags.add(tag);
      }
    }
    try {
      tags.addAll(createVisibilityTags(cellVisibility.getExpression()));
View Full Code Here

    // Iterate over the entries in the familyMap, replacing the cells therein
    // with new cells including the ACL data
    for (Map.Entry<byte[], List<Cell>> e: familyMap.entrySet()) {
      List<Cell> newCells = Lists.newArrayList();
      for (Cell cell: e.getValue()) {
        List<Tag> tags = Lists.newArrayList(new Tag(AccessControlLists.ACL_TAG_TYPE, perms));
        byte[] tagBytes = CellUtil.getTagArray(cell);
        Iterator<Tag> tagIterator = CellUtil.tagsIterator(tagBytes, 0, tagBytes.length);
        while (tagIterator.hasNext()) {
          tags.add(tagIterator.next());
        }
View Full Code Here

    ListMultimap<String,Permission> perms = ArrayListMultimap.create();
    if (oldCell != null) {
      byte[] tagBytes = CellUtil.getTagArray(oldCell);
      Iterator<Tag> tagIterator = CellUtil.tagsIterator(tagBytes, 0, tagBytes.length);
      while (tagIterator.hasNext()) {
        Tag tag = tagIterator.next();
        if (tag.getType() != AccessControlLists.ACL_TAG_TYPE) {
          if (LOG.isTraceEnabled()) {
            LOG.trace("Carrying forward tag from " + oldCell + ": type " + tag.getType() +
              " length " + tag.getValue().length);
          }
          tags.add(tag);
        } else {
          ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
            AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
              tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
          perms.putAll(kvPerms);
        }
      }
    }

    // Do we have an ACL on the operation?
    byte[] aclBytes = mutation.getACL();
    if (aclBytes != null) {
      // Yes, use it
      tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE, aclBytes));
    } else {
      // No, use what we carried forward
      if (perms != null) {
        // TODO: If we collected ACLs from more than one tag we may have a
        // List<Permission> of size > 1, this can be collapsed into a single
        // Permission
        if (LOG.isTraceEnabled()) {
          LOG.trace("Carrying forward ACLs from " + oldCell + ": " + perms);
        }
        tags.add(new Tag(AccessControlLists.ACL_TAG_TYPE,
          ProtobufUtil.toUsersAndPermissions(perms).toByteArray()));
      }
    }

    // If we have no tags to add, just return
View Full Code Here

       throws IOException {
     List<Permission> results = Lists.newArrayList();
     Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLengthUnsigned());
     while (tagsIterator.hasNext()) {
       Tag tag = tagsIterator.next();
       if (tag.getType() == ACL_TAG_TYPE) {
         // Deserialize the table permissions from the KV
         ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
           AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
             tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
         // Are there permissions for this user?
         List<Permission> userPerms = kvPerms.get(user.getShortName());
         if (userPerms != null) {
           results.addAll(userPerms);
         }
View Full Code Here

     }
     List<Permission> results = Lists.newArrayList();
     Iterator<Tag> tagsIterator = CellUtil.tagsIterator(cell.getTagsArray(), cell.getTagsOffset(),
        cell.getTagsLength());
     while (tagsIterator.hasNext()) {
       Tag tag = tagsIterator.next();
       if (tag.getType() == ACL_TAG_TYPE) {
         // Deserialize the table permissions from the KV
         ListMultimap<String,Permission> kvPerms = ProtobufUtil.toUsersAndPermissions(
           AccessControlProtos.UsersAndPermissions.newBuilder().mergeFrom(
             tag.getBuffer(), tag.getTagOffset(), tag.getTagLength()).build());
         // Are there permissions for this user?
         List<Permission> userPerms = kvPerms.get(user.getShortName());
         if (userPerms != null) {
           results.addAll(userPerms);
         }
View Full Code Here

    if (newCell.getTagsLength() > 0) {
      // Carry forward all other tags
      Iterator<Tag> tagsItr = CellUtil.tagsIterator(newCell.getTagsArray(),
          newCell.getTagsOffset(), newCell.getTagsLength());
      while (tagsItr.hasNext()) {
        Tag tag = tagsItr.next();
        if (tag.getType() != TagType.VISIBILITY_TAG_TYPE
            && tag.getType() != TagType.VISIBILITY_EXP_SERIALIZATION_FORMAT_TAG_TYPE) {
          tags.add(tag);
        }
      }
    }
View Full Code Here

          LOG.info("Row not available");
          Thread.sleep(SLEEP_TIME);
        } else {
          assertArrayEquals(res.value(), ROW);
          assertEquals(1, TestCoprocessorForTagsAtSink.tags.size());
          Tag tag = TestCoprocessorForTagsAtSink.tags.get(0);
          assertEquals(TAG_TYPE, tag.getType());
          break;
        }
      }
    } finally {
      TestCoprocessorForTagsAtSink.tags = null;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.