Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toViolationPolicy()

The following examples show how to use org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toViolationPolicy() . 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: NamespaceQuotaSnapshotStore.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public SpaceQuotaSnapshot getTargetState(
    String subject, SpaceQuota spaceQuota) throws IOException {
  rlock.lock();
  try {
    final long sizeLimitInBytes = spaceQuota.getSoftLimit();
    long sum = 0L;
    for (Entry<RegionInfo,Long> entry : filterBySubject(subject)) {
      sum += entry.getValue();
    }
    // Add in the size for any snapshots against this table
    sum += QuotaTableUtil.getNamespaceSnapshotSize(conn, subject);
    // Observance is defined as the size of the table being less than the limit
    SpaceQuotaStatus status = sum <= sizeLimitInBytes ? SpaceQuotaStatus.notInViolation()
        : new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy()));
    return new SpaceQuotaSnapshot(status, sum, sizeLimitInBytes);
  } finally {
    rlock.unlock();
  }
}
 
Example 2
Source File: TableQuotaSnapshotStore.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public SpaceQuotaSnapshot getTargetState(
    TableName table, SpaceQuota spaceQuota) throws IOException {
  rlock.lock();
  try {
    final long sizeLimitInBytes = spaceQuota.getSoftLimit();
    long sum = 0L;
    for (Entry<RegionInfo,Long> entry : filterBySubject(table)) {
      sum += entry.getValue();
    }
    // Add in the size for any snapshots against this table
    sum += getSnapshotSizesForTable(table);
    // Observance is defined as the size of the table being less than the limit
    SpaceQuotaStatus status = sum <= sizeLimitInBytes ? SpaceQuotaStatus.notInViolation()
        : new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy()));
    return new SpaceQuotaSnapshot(status, sum, sizeLimitInBytes);
  } finally {
    rlock.unlock();
  }
}
 
Example 3
Source File: SpaceQuotaSnapshot.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static SpaceQuotaStatus toStatus(QuotaProtos.SpaceQuotaStatus proto) {
  if (proto.getInViolation()) {
    return new SpaceQuotaStatus(ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));
  } else {
    return NOT_IN_VIOLATION;
  }
}
 
Example 4
Source File: QuotaTableUtil.java    From hbase with Apache License 2.0 4 votes vote down vote up
protected static SpaceViolationPolicy getViolationPolicy(SpaceQuota proto) {
  if (!proto.hasViolationPolicy()) {
    throw new IllegalArgumentException("Protobuf SpaceQuota does not have violation policy.");
  }
  return ProtobufUtil.toViolationPolicy(proto.getViolationPolicy());
}
 
Example 5
Source File: SpaceLimitSettings.java    From hbase with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and tablename.
 *
 * @param tableName The target tablename for the limit.
 * @param proto The protobuf representation.
 * @return A QuotaSettings.
 */
static SpaceLimitSettings fromSpaceQuota(
    final TableName tableName, final QuotaProtos.SpaceQuota proto) {
  validateProtoArguments(proto);
  return new SpaceLimitSettings(tableName, proto.getSoftLimit(),
      ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));
}
 
Example 6
Source File: SpaceLimitSettings.java    From hbase with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a {@link SpaceLimitSettings} from the provided protobuf message and namespace.
 *
 * @param namespace The target namespace for the limit.
 * @param proto The protobuf representation.
 * @return A QuotaSettings.
 */
static SpaceLimitSettings fromSpaceQuota(
    final String namespace, final QuotaProtos.SpaceQuota proto) {
  validateProtoArguments(proto);
  return new SpaceLimitSettings(namespace, proto.getSoftLimit(),
      ProtobufUtil.toViolationPolicy(proto.getViolationPolicy()));
}