private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final String regionServer, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings .addAll(fromThrottle(userName, tableName, namespace, regionServer, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings .add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, regionServer, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
SpaceQuotaSnapshot masterSnapshot = null; Quotas quota = QuotaTableUtil.getTableQuota(master.getConnection(), tn); if (quota == null || !quota.hasSpace()) { quota = QuotaTableUtil.getNamespaceQuota(master.getConnection(), tn.getNamespaceAsString()); if (quota != null) { masterSnapshot = master.getQuotaObserverChore().getTableQuotaSnapshots().get(tn); if (quota != null && quota.hasSpace()) { SpaceQuota spaceQuota = quota.getSpace();
if (quotaManager.isQuotaInitialized()) { Quotas quotaForTable = QuotaUtil.getTableQuota(getConnection(), tableName); if (quotaForTable != null && quotaForTable.hasSpace()) { SpaceViolationPolicy policy = quotaForTable.getSpace().getViolationPolicy(); if (SpaceViolationPolicy.DISABLE == policy) {
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasBypassGlobals()) { hash = (37 * hash) + BYPASS_GLOBALS_FIELD_NUMBER; hash = (53 * hash) + org.apache.hbase.thirdparty.com.google.protobuf.Internal.hashBoolean( getBypassGlobals()); } if (hasThrottle()) { hash = (37 * hash) + THROTTLE_FIELD_NUMBER; hash = (53 * hash) + getThrottle().hashCode(); } if (hasSpace()) { hash = (37 * hash) + SPACE_FIELD_NUMBER; hash = (53 * hash) + getSpace().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas.getDefaultInstance()) return this; if (other.hasBypassGlobals()) { setBypassGlobals(other.getBypassGlobals()); } if (other.hasThrottle()) { mergeThrottle(other.getThrottle()); } if (other.hasSpace()) { mergeSpace(other.getSpace()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public static boolean isEmptyQuota(final Quotas quotas) { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); // Only when there is a space quota, make sure there's actually both fields provided // Otherwise, it's a noop. if (quotas.hasSpace()) { hasSettings |= (quotas.getSpace().hasSoftLimit() && quotas.getSpace().hasViolationPolicy()); } return !hasSettings; }
private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings.addAll(fromThrottle(userName, tableName, namespace, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
private void assertSpaceQuota( long sizeLimit, SpaceViolationPolicy violationPolicy, Cell cell) throws Exception { Quotas q = QuotaTableUtil.quotasFromData( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); assertTrue("Quota should have space quota defined", q.hasSpace()); QuotaProtos.SpaceQuota spaceQuota = q.getSpace(); assertEquals(sizeLimit, spaceQuota.getSoftLimit()); assertEquals(violationPolicy, ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy())); }
private static List<QuotaSettings> fromQuotas(final String userName, final TableName tableName, final String namespace, final Quotas quotas) { List<QuotaSettings> settings = new ArrayList<>(); if (quotas.hasThrottle()) { settings.addAll(fromThrottle(userName, tableName, namespace, quotas.getThrottle())); } if (quotas.getBypassGlobals() == true) { settings.add(new QuotaGlobalsSettingsBypass(userName, tableName, namespace, true)); } if (quotas.hasSpace()) { settings.add(fromSpace(tableName, namespace, quotas.getSpace())); } return settings; }
public static boolean isEmptyQuota(final Quotas quotas) { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); // Only when there is a space quota, make sure there's actually both fields provided // Otherwise, it's a noop. if (quotas.hasSpace()) { hasSettings |= (quotas.getSpace().hasSoftLimit() && quotas.getSpace().hasViolationPolicy()); } return !hasSettings; }
@Override public void postDeleteTable( ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) throws IOException { // Do nothing if quotas aren't enabled if (!quotasEnabled) { return; } final Connection conn = ctx.getEnvironment().getConnection(); Quotas quotas = QuotaUtil.getTableQuota(conn, tableName); if (quotas != null){ if (quotas.hasSpace()){ QuotaSettings settings = QuotaSettingsFactory.removeTableSpaceLimit(tableName); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } if (quotas.hasThrottle()){ QuotaSettings settings = QuotaSettingsFactory.unthrottleTable(tableName); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } } }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas)) { return super.equals(obj); } org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas other = (org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas) obj; boolean result = true; result = result && (hasBypassGlobals() == other.hasBypassGlobals()); if (hasBypassGlobals()) { result = result && (getBypassGlobals() == other.getBypassGlobals()); } result = result && (hasThrottle() == other.hasThrottle()); if (hasThrottle()) { result = result && getThrottle() .equals(other.getThrottle()); } result = result && (hasSpace() == other.hasSpace()); if (hasSpace()) { result = result && getSpace() .equals(other.getSpace()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@Override public void postDeleteNamespace( ObserverContext<MasterCoprocessorEnvironment> ctx, String namespace) throws IOException { // Do nothing if quotas aren't enabled if (!quotasEnabled) { return; } final Connection conn = ctx.getEnvironment().getConnection(); Quotas quotas = QuotaUtil.getNamespaceQuota(conn, namespace); if (quotas != null) { if (quotas.hasSpace()) { QuotaSettings settings = QuotaSettingsFactory.removeNamespaceSpaceLimit(namespace); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } if (quotas.hasThrottle()) { QuotaSettings settings = QuotaSettingsFactory.unthrottleNamespace(namespace); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } } } }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasBypassGlobals()) { hash = (37 * hash) + BYPASS_GLOBALS_FIELD_NUMBER; hash = (53 * hash) + org.apache.hbase.thirdparty.com.google.protobuf.Internal.hashBoolean( getBypassGlobals()); } if (hasThrottle()) { hash = (37 * hash) + THROTTLE_FIELD_NUMBER; hash = (53 * hash) + getThrottle().hashCode(); } if (hasSpace()) { hash = (37 * hash) + SPACE_FIELD_NUMBER; hash = (53 * hash) + getSpace().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas.getDefaultInstance()) return this; if (other.hasBypassGlobals()) { setBypassGlobals(other.getBypassGlobals()); } if (other.hasThrottle()) { mergeThrottle(other.getThrottle()); } if (other.hasSpace()) { mergeSpace(other.getSpace()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Override public SpaceQuota getSpaceQuota(TableName subject) throws IOException { Quotas quotas = getQuotaForTable(subject); if (quotas != null && quotas.hasSpace()) { return quotas.getSpace(); } return null; } /**
public static boolean isEmptyQuota(final Quotas quotas) { boolean hasSettings = false; hasSettings |= quotas.hasThrottle(); hasSettings |= quotas.hasBypassGlobals(); // Only when there is a space quota, make sure there's actually both fields provided // Otherwise, it's a noop. if (quotas.hasSpace()) { hasSettings |= (quotas.getSpace().hasSoftLimit() && quotas.getSpace().hasViolationPolicy()); } return !hasSettings; }
@Override public SpaceQuota getSpaceQuota(String namespace) throws IOException { Quotas quotas = getQuotaForNamespace(namespace); if (quotas != null && quotas.hasSpace()) { return quotas.getSpace(); } return null; }
protected GlobalQuotaSettingsImpl(String username, TableName tableName, String namespace, String regionServer, QuotaProtos.Quotas quotas) { this(username, tableName, namespace, regionServer, (quotas != null && quotas.hasThrottle() ? quotas.getThrottle() : null), (quotas != null && quotas.hasBypassGlobals() ? quotas.getBypassGlobals() : null), (quotas != null && quotas.hasSpace() ? quotas.getSpace() : null)); }
private void assertSpaceQuota( long sizeLimit, SpaceViolationPolicy violationPolicy, Cell cell) throws Exception { Quotas q = QuotaTableUtil.quotasFromData( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); assertTrue("Quota should have space quota defined", q.hasSpace()); QuotaProtos.SpaceQuota spaceQuota = q.getSpace(); assertEquals(sizeLimit, spaceQuota.getSoftLimit()); assertEquals(violationPolicy, ProtobufUtil.toViolationPolicy(spaceQuota.getViolationPolicy())); }