Java Code Examples for org.apache.hadoop.hbase.client.Delete#getAttribute()

The following examples show how to use org.apache.hadoop.hbase.client.Delete#getAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SIObserver.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void preDelete(ObserverContext<RegionCoprocessorEnvironment> c, Delete delete, WALEdit edit, Durability durability) throws IOException {
    checkAccess();

    try {
        if(tableEnvMatch){
            if(delete.getAttribute(SIConstants.SUPPRESS_INDEXING_ATTRIBUTE_NAME)==null){
                TableName tableName=c.getEnvironment().getRegion().getTableDescriptor().getTableName();
                String message="Direct deletes are not supported under snapshot isolation. "+
                        "Instead a Put is expected that will set a record level tombstone. tableName="+tableName;
                throw new RuntimeException(message);
            }
        }
    } catch (Throwable t) {
        throw CoprocessorUtils.getIOException(t);
    }
}
 
Example 2
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 3
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 4
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 5
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
    final Delete delete, final WALEdit edit, final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 6
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 7
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 8
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 9
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 10
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
    final Delete delete, final WALEdit edit, final Durability durability)
    throws IOException {
  // An ACL on a delete is useless, we shouldn't allow it
  if (delete.getAttribute(AccessControlConstants.OP_ATTRIBUTE_ACL) != null) {
    throw new DoNotRetryIOException("ACL on delete has no effect: " + delete.toString());
  }
  // Require WRITE permissions on all cells covered by the delete. Unlike
  // for Puts we need to check all visible prior versions, because a major
  // compaction could remove them. If the user doesn't have permission to
  // overwrite any of the visible versions ('visible' defined as not covered
  // by a tombstone already) then we have to disallow this operation.
  RegionCoprocessorEnvironment env = c.getEnvironment();
  Map<byte[],? extends Collection<Cell>> families = delete.getFamilyCellMap();
  User user = getActiveUser(c);
  AuthResult authResult = permissionGranted(OpType.DELETE,
      user, env, families, Action.WRITE);
  AccessChecker.logResult(authResult);
  if (!authResult.isAllowed()) {
    if (cellFeaturesEnabled && !compatibleEarlyTermination) {
      delete.setAttribute(CHECK_COVERING_PERM, TRUE);
    } else if (authorizationEnabled) {
      throw new AccessDeniedException("Insufficient permissions " +
        authResult.toContextString());
    }
  }
}
 
Example 11
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
    final byte [] row, final byte [] family, final byte [] qualifier,
    final CompareOperator op,
    final ByteArrayComparable comparator, final Delete delete,
    final boolean result) throws IOException {
  // An ACL on a delete is useless, we shouldn't allow it
  if (delete.getAttribute(AccessControlConstants.OP_ATTRIBUTE_ACL) != null) {
    throw new DoNotRetryIOException("ACL on checkAndDelete has no effect: " +
        delete.toString());
  }
  // Require READ and WRITE permissions on the table, CF, and the KV covered
  // by the delete
  RegionCoprocessorEnvironment env = c.getEnvironment();
  Map<byte[],? extends Collection<byte[]>> families = makeFamilyMap(family, qualifier);
  User user = getActiveUser(c);
  AuthResult authResult = permissionGranted(
      OpType.CHECK_AND_DELETE, user, env, families, Action.READ, Action.WRITE);
  AccessChecker.logResult(authResult);
  if (!authResult.isAllowed()) {
    if (cellFeaturesEnabled && !compatibleEarlyTermination) {
      delete.setAttribute(CHECK_COVERING_PERM, TRUE);
    } else if (authorizationEnabled) {
      throw new AccessDeniedException("Insufficient permissions " +
        authResult.toContextString());
    }
  }
  return result;
}
 
Example 12
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndDeleteAfterRowLock(
    final ObserverContext<RegionCoprocessorEnvironment> c, final byte[] row,
    final byte[] family, final byte[] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Delete delete, final boolean result)
    throws IOException {
  if (delete.getAttribute(CHECK_COVERING_PERM) != null) {
    // We had failure with table, cf and q perm checks and now giving a chance for cell
    // perm check
    TableName table = c.getEnvironment().getRegion().getRegionInfo().getTable();
    Map<byte[], ? extends Collection<byte[]>> families = makeFamilyMap(family, qualifier);
    AuthResult authResult = null;
    User user = getActiveUser(c);
    if (checkCoveringPermission(user, OpType.CHECK_AND_DELETE, c.getEnvironment(),
        row, families, HConstants.LATEST_TIMESTAMP, Action.READ)) {
      authResult = AuthResult.allow(OpType.CHECK_AND_DELETE.toString(),
          "Covering cell set", user, Action.READ, table, families);
    } else {
      authResult = AuthResult.deny(OpType.CHECK_AND_DELETE.toString(),
          "Covering cell set", user, Action.READ, table, families);
    }
    AccessChecker.logResult(authResult);
    if (authorizationEnabled && !authResult.isAllowed()) {
      throw new AccessDeniedException("Insufficient permissions " + authResult.toContextString());
    }
  }
  return result;
}