Skip to content

Commit

Permalink
[issue apache#13439][backlogQuota] Allow both limit and limitsize be …
Browse files Browse the repository at this point in the history
…null (apache#13557)

Fixes apache#13439 
### Motivation
Now we only constraint `limit` or `limitSize` be set on pulsar-admin, we don't limit it on rest endpoint. So there are situtations that both `limit` and `limitSize` be null

### Verifying this change

This change added tests and can be verified as follows:
  - *Added test method in `BacklogQuotaCompatibilityTest`
  • Loading branch information
hezhangjian authored Jan 7, 2022
1 parent b38d850 commit 33491bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BacklogQuotaImpl implements BacklogQuota {
* @since 2.9.1
*/
@Deprecated
private Long limit;
private long limit;

/**
* backlog quota by size in byte.
Expand All @@ -57,7 +57,6 @@ public BacklogQuotaImpl(long limitSize, int limitTime, RetentionPolicy policy) {
@Deprecated
public long getLimit() {
if (limitSize == null) {
// the limitSize and limit can't be both null
return limit;
}
return limitSize;
Expand All @@ -71,7 +70,6 @@ public void setLimit(long limit) {

public long getLimitSize() {
if (limitSize == null) {
// the limitSize and limit can't be both null
return limit;
}
return limitSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,24 @@ public void testBackwardCompatibility() throws IOException {
BacklogQuota.RetentionPolicy.consumer_backlog_eviction);
}

@Test
public void testBackwardCompatibilityNullLimitAndLimitSize() throws IOException {
String oldPolicyStr = "{\"auth_policies\":{\"namespace_auth\":{},\"destination_auth\":{},"
+ "\"subscription_auth_roles\":{}},\"replication_clusters\":[],\"backlog_quota_map\":"
+ "{\"destination_storage\":{\"policy\":\"consumer_backlog_eviction\"}},"
+ "\"clusterDispatchRate\":{},\"topicDispatchRate\":{},\"subscriptionDispatchRate\":{},"
+ "\"replicatorDispatchRate\":{},\"clusterSubscribeRate\":{},\"publishMaxMessageRate\":{},"
+ "\"latency_stats_sample_rate\":{},\"subscription_expiration_time_minutes\":0,\"deleted\":false,"
+ "\"encryption_required\":false,\"subscription_auth_mode\":\"None\","
+ "\"max_consumers_per_subscription\":0,\"offload_threshold\":-1,"
+ "\"schema_auto_update_compatibility_strategy\":\"Full\",\"schema_compatibility_strategy\":"
+ "\"UNDEFINED\",\"is_allow_auto_update_schema\":true,\"schema_validation_enforced\":false,"
+ "\"subscription_types_enabled\":[]}\n";
Policies policies = simpleType.deserialize(null, oldPolicyStr.getBytes(), null);
assertEquals(policies.backlog_quota_map.get(BacklogQuota.BacklogQuotaType.destination_storage).getLimitSize(),
0);
assertEquals(policies.backlog_quota_map.get(BacklogQuota.BacklogQuotaType.destination_storage).getLimitTime(),
0);
}

}

0 comments on commit 33491bc

Please sign in to comment.