private <K> Map<K, QuotaLimiter> setLimiter(Map<K, QuotaLimiter> limiters, final K key, final Quotas quotas) { if (limiters == null) { limiters = new HashMap<>(); } QuotaLimiter limiter = quotas.hasThrottle() ? QuotaLimiterFactory.fromThrottle(quotas.getThrottle()) : null; if (limiter != null && !limiter.isBypass()) { limiters.put(key, limiter); } else { limiters.remove(key); } return limiters; }
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; }
@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; }
@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; }
@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; }
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; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; if (hasThrottle()) { if (!getThrottle().isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
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; }
Quotas q = QuotaTableUtil .quotasFromData(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); assertTrue("Quota should have rpc quota defined", q.hasThrottle());
@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); } } } } }
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; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; if (hasThrottle()) { if (!getThrottle().isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
/** * Setup the global quota information. * (This operation is part of the QuotaState setup) */ public synchronized void setQuotas(final Quotas quotas) { if (quotas.hasThrottle()) { globalLimiter = QuotaLimiterFactory.fromThrottle(quotas.getThrottle()); } else { globalLimiter = NoopQuotaLimiter.get(); } }
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)); }