com-poorbar commented on a change in pull request #12792:
URL: https://github.com/apache/pulsar/pull/12792#discussion_r752877510



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/HashRangeAutoSplitStickyKeyConsumerSelector.java
##########
@@ -96,9 +104,20 @@ public synchronized void removeConsumer(Consumer consumer) {
                 rangeMap.put(removeRange, lowerEntry.getValue());
                 rangeMap.remove(lowerEntry.getKey());
                 consumerRange.put(lowerEntry.getValue(), removeRange);
+                // notify change for effected consumer
+                lowerEntry.getValue().notifyActiveConsumerChange(
+                        
generateSpecialPredicate(lowerEntry.getValue()).encode());
             } else {
                 rangeMap.remove(removeRange);
+                // notify change for effected consumer.
+                Map.Entry<Integer, Consumer> lowerEntry = 
rangeMap.higherEntry(removeRange);
+                if (lowerEntry != null) {
+                    lowerEntry.getValue().notifyActiveConsumerChange(
+                            
generateSpecialPredicate(lowerEntry.getValue()).encode());
+                }
             }
+//            // notify removed consumer change

Review comment:
       Already revised

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ConsistentHashingStickyKeyConsumerSelector.java
##########
@@ -148,4 +156,29 @@ public Consumer select(int hash) {
     Map<Integer, List<Consumer>> getRangeConsumer() {
         return Collections.unmodifiableMap(hashRing);
     }
+
+    @Override
+    public StickyKeyConsumerPredicate generateSpecialPredicate(final Consumer 
consumer){
+        NavigableMap<Integer, List<String>> cpHashRing = new 
ConcurrentSkipListMap<>();
+        for (Map.Entry<Integer, List<Consumer>> entry: hashRing.entrySet()) {
+            if (CollectionUtils.isEmpty(entry.getValue())) {
+                continue;
+            }
+            cpHashRing.put(entry.getKey(), entry.getValue()
+                    .stream()
+                    .map(v -> v == consumer ? 
StickyKeyConsumerPredicate.SPECIAL_CONSUMER_MARK
+                            : StickyKeyConsumerPredicate.OTHER_CONSUMER_MARK)
+                    .collect(Collectors.toList())
+            );
+        }
+        return new 
StickyKeyConsumerPredicate.Predicate4ConsistentHashingStickyKeyConsumerSelector(cpHashRing);
+    }
+
+    private void notifyActiveConsumerChanged() {
+        // TODO add configuration for this events in future
+        Set<Consumer> consumerSet = new HashSet<>(hashRing.values().stream()

Review comment:
       Already revised

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
##########
@@ -421,7 +421,8 @@ public Clock getClientClock() {
                     "Read compacted can only be used with exclusive or 
failover persistent subscriptions"));
         }
 
-        if (conf.getConsumerEventListener() != null && 
conf.getSubscriptionType() != SubscriptionType.Failover) {
+        if (conf.getConsumerEventListener() != null && 
conf.getSubscriptionType() != SubscriptionType.Failover
+                && conf.getSubscriptionType() != SubscriptionType.Key_Shared) {
             return FutureUtil.failedFuture(new 
PulsarClientException.InvalidConfigurationException(

Review comment:
       Already revised




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to