@Override public int hashCode() { return Objects.hash(getTableName(), getNamespace(), proto); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof SpaceLimitSettings)) { return false; } // o is non-null and an instance of SpaceLimitSettings SpaceLimitSettings other = (SpaceLimitSettings) o; return Objects.equals(getTableName(), other.getTableName()) && Objects.equals(getNamespace(), other.getNamespace()) && Objects.equals(proto, other.proto); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TYPE => SPACE"); if (getTableName() != null) { sb.append(", TABLE => ").append(getTableName()); } if (getNamespace() != null) { sb.append(", NAMESPACE => ").append(getNamespace()); } if (proto.getQuota().getRemove()) { sb.append(", REMOVE => ").append(proto.getQuota().getRemove()); } else { sb.append(", LIMIT => ").append(sizeToString(proto.getQuota().getSoftLimit())); sb.append(", VIOLATION_POLICY => ").append(proto.getQuota().getViolationPolicy()); } return sb.toString(); }
@Override protected QuotaSettings merge(QuotaSettings newSettings) { if (newSettings instanceof SpaceLimitSettings) { SpaceLimitSettings settingsToMerge = (SpaceLimitSettings) newSettings; // The message contained the expect SpaceQuota object if (settingsToMerge.proto.hasQuota()) { SpaceQuota quotaToMerge = settingsToMerge.proto.getQuota(); if (quotaToMerge.getRemove()) { return settingsToMerge; } else { // Validate that the two settings are for the same target. // SpaceQuotas either apply to a table or a namespace (no user spacequota). if (!Objects.equals(getTableName(), settingsToMerge.getTableName()) && !Objects.equals(getNamespace(), settingsToMerge.getNamespace())) { throw new IllegalArgumentException("Cannot merge " + newSettings + " into " + this); } // Create a builder from the old settings SpaceQuota.Builder mergedBuilder = this.proto.getQuota().toBuilder(); // Build a new SpaceQuotas object from merging in the new settings return new SpaceLimitSettings( getTableName(), getNamespace(), buildProtoFromQuota(mergedBuilder.mergeFrom(quotaToMerge).build())); } } // else, we don't know what to do, so return the original object } return this; }
void partitionTablesByQuotaTarget(Multimap<TableName,QuotaSettings> quotas, Set<TableName> tablesWithTableQuota, Set<TableName> tablesWithNamespaceQuota) { // Partition the tables with quotas by table and ns quota for (Entry<TableName, QuotaSettings> entry : quotas.entries()) { SpaceLimitSettings settings = (SpaceLimitSettings) entry.getValue(); TableName tn = entry.getKey(); if (settings.getTableName() != null) { tablesWithTableQuota.add(tn); } if (settings.getNamespace() != null) { tablesWithNamespaceQuota.add(tn); } if (settings.getTableName() == null && settings.getNamespace() == null) { fail("Unexpected table name with null tableName and namespace: " + tn); } } }
@Override public int hashCode() { return Objects.hash(getTableName(), getNamespace(), proto); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof SpaceLimitSettings)) { return false; } // o is non-null and an instance of SpaceLimitSettings SpaceLimitSettings other = (SpaceLimitSettings) o; return Objects.equals(getTableName(), other.getTableName()) && Objects.equals(getNamespace(), other.getNamespace()) && Objects.equals(proto, other.proto); }
&& !Objects.equals(getNamespace(), settingsToMerge.getNamespace())) { throw new IllegalArgumentException( "Cannot merge " + settingsToMerge + " into " + this);
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TYPE => SPACE"); if (getTableName() != null) { sb.append(", TABLE => ").append(getTableName()); } if (getNamespace() != null) { sb.append(", NAMESPACE => ").append(getNamespace()); } if (proto.getQuota().getRemove()) { sb.append(", REMOVE => ").append(proto.getQuota().getRemove()); } else { sb.append(", LIMIT => ").append(sizeToString(proto.getQuota().getSoftLimit())); sb.append(", VIOLATION_POLICY => ").append(proto.getQuota().getViolationPolicy()); } return sb.toString(); }
@Override protected QuotaSettings merge(QuotaSettings newSettings) { if (newSettings instanceof SpaceLimitSettings) { SpaceLimitSettings settingsToMerge = (SpaceLimitSettings) newSettings; // The message contained the expect SpaceQuota object if (settingsToMerge.proto.hasQuota()) { SpaceQuota quotaToMerge = settingsToMerge.proto.getQuota(); if (quotaToMerge.getRemove()) { return settingsToMerge; } else { // Validate that the two settings are for the same target. // SpaceQuotas either apply to a table or a namespace (no user spacequota). if (!Objects.equals(getTableName(), settingsToMerge.getTableName()) && !Objects.equals(getNamespace(), settingsToMerge.getNamespace())) { throw new IllegalArgumentException("Cannot merge " + newSettings + " into " + this); } // Create a builder from the old settings SpaceQuota.Builder mergedBuilder = this.proto.getQuota().toBuilder(); // Build a new SpaceQuotas object from merging in the new settings return new SpaceLimitSettings( getTableName(), getNamespace(), buildProtoFromQuota(mergedBuilder.mergeFrom(quotaToMerge).build())); } } // else, we don't know what to do, so return the original object } return this; } }
assertEquals(tn, spaceLimit.getTableName()); assertNull("Username should be null", spaceLimit.getUserName()); assertNull("Namespace should be null", spaceLimit.getNamespace()); assertNull("RegionServer should be null", spaceLimit.getRegionServer()); assertTrue("SpaceLimitSettings should have a SpaceQuota", spaceLimit.getProto().hasQuota());
@Override public int hashCode() { return Objects.hash(getTableName(), getNamespace(), proto); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof SpaceLimitSettings)) { return false; } // o is non-null and an instance of SpaceLimitSettings SpaceLimitSettings other = (SpaceLimitSettings) o; return Objects.equals(getTableName(), other.getTableName()) && Objects.equals(getNamespace(), other.getNamespace()) && Objects.equals(proto, other.proto); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TYPE => SPACE"); if (getTableName() != null) { sb.append(", TABLE => ").append(getTableName()); } if (getNamespace() != null) { sb.append(", NAMESPACE => ").append(getNamespace()); } if (proto.getQuota().getRemove()) { sb.append(", REMOVE => ").append(proto.getQuota().getRemove()); } else { sb.append(", LIMIT => ").append(proto.getQuota().getSoftLimit()); sb.append(", VIOLATION_POLICY => ").append(proto.getQuota().getViolationPolicy()); } return sb.toString(); }
void partitionTablesByQuotaTarget(Multimap<TableName,QuotaSettings> quotas, Set<TableName> tablesWithTableQuota, Set<TableName> tablesWithNamespaceQuota) { // Partition the tables with quotas by table and ns quota for (Entry<TableName, QuotaSettings> entry : quotas.entries()) { SpaceLimitSettings settings = (SpaceLimitSettings) entry.getValue(); TableName tn = entry.getKey(); if (settings.getTableName() != null) { tablesWithTableQuota.add(tn); } if (settings.getNamespace() != null) { tablesWithNamespaceQuota.add(tn); } if (settings.getTableName() == null && settings.getNamespace() == null) { fail("Unexpected table name with null tableName and namespace: " + tn); } } }
@Override protected QuotaSettings merge(QuotaSettings newSettings) { if (newSettings instanceof SpaceLimitSettings) { SpaceLimitSettings settingsToMerge = (SpaceLimitSettings) newSettings; // The message contained the expect SpaceQuota object if (settingsToMerge.proto.hasQuota()) { SpaceQuota quotaToMerge = settingsToMerge.proto.getQuota(); if (quotaToMerge.getRemove()) { return settingsToMerge; } else { // Validate that the two settings are for the same target. // SpaceQuotas either apply to a table or a namespace (no user spacequota). if (!Objects.equals(getTableName(), settingsToMerge.getTableName()) && !Objects.equals(getNamespace(), settingsToMerge.getNamespace())) { throw new IllegalArgumentException("Cannot merge " + newSettings + " into " + this); } // Create a builder from the old settings SpaceQuota.Builder mergedBuilder = this.proto.getQuota().toBuilder(); // Build a new SpaceQuotas object from merging in the new settings return new SpaceLimitSettings( getTableName(), getNamespace(), buildProtoFromQuota(mergedBuilder.mergeFrom(quotaToMerge).build())); } } // else, we don't know what to do, so return the original object } return this; } }
assertEquals(tn, spaceLimit.getTableName()); assertNull("Username should be null", spaceLimit.getUserName()); assertNull("Namespace should be null", spaceLimit.getNamespace()); assertTrue("SpaceLimitSettings should have a SpaceQuota", spaceLimit.getProto().hasQuota()); assertEquals(spaceQuota, spaceLimit.getProto().getQuota());