Skip to content

Commit

Permalink
[pulsar-client-api] Fix Unavailable Hash Range Condition (apache#9041)
Browse files Browse the repository at this point in the history
### Motivation
https://github.com/apache/pulsar/blob/3b2c8526a96fc90e948dbeb510e8400a628c749a/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/KeySharedPolicy.java#L110-L112

When range is [0, 65536], the above condition is false.

### Modification
Change from `range1.getEnd() > DEFAULT_HASH_RANGE_SIZE` to `range1.getEnd() >= DEFAULT_HASH_RANGE_SIZE`.
  • Loading branch information
k2la authored Dec 24, 2020
1 parent 7ca2b44 commit 48779bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void testSendAndReceiveWithHashRangeExclusiveStickyKeyConsumerSelector(bo

@Cleanup
Consumer<Integer> consumer3 = createConsumer(topic, KeySharedPolicy.stickyHashRange()
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE)));
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE-1)));

@Cleanup
Producer<Integer> producer = createProducer(topic, enableBatch);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void testNonKeySendAndReceiveWithHashRangeExclusiveStickyKeyConsumerSelec

@Cleanup
Consumer<Integer> consumer3 = createConsumer(topic, KeySharedPolicy.stickyHashRange()
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE)));
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE-1)));

@Cleanup
Producer<Integer> producer = createProducer(topic, enableBatch);
Expand Down Expand Up @@ -362,7 +362,7 @@ public void testOrderingKeyWithHashRangeExclusiveStickyKeyConsumerSelector(boole

@Cleanup
Consumer<Integer> consumer3 = createConsumer(topic, KeySharedPolicy.stickyHashRange()
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE)));
.ranges(Range.of(40001, KeySharedPolicy.DEFAULT_HASH_RANGE_SIZE-1)));

@Cleanup
Producer<Integer> producer = createProducer(topic, enableBatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void validate() {
}
for (int i = 0; i < ranges.size(); i++) {
Range range1 = ranges.get(i);
if (range1.getStart() < 0 || range1.getEnd() > DEFAULT_HASH_RANGE_SIZE) {
if (range1.getStart() < 0 || range1.getEnd() >= DEFAULT_HASH_RANGE_SIZE) {
throw new IllegalArgumentException("Ranges must be [0, 65535] but provided range is " + range1);
}
for (int j = 0; j < ranges.size(); j++) {
Expand Down

0 comments on commit 48779bd

Please sign in to comment.