コード例 #1
0
 @Override
 public void registerTopicSubscriber(
     @NotNull RequestContext rc, @NotNull TopicSubscriber subscriber) {
   addToStats("topicSubscription");
   Boolean bootstrap = rc.bootstrap();
   topicSubscribers.add((TopicSubscriber<K, V>) subscriber);
   if (bootstrap != Boolean.FALSE && kvStore != null) {
     try {
       for (int i = 0; i < kvStore.segments(); i++)
         kvStore.entriesFor(i, e -> subscriber.onMessage(e.getKey(), e.getValue()));
     } catch (InvalidSubscriberException dontAdd) {
       topicSubscribers.remove(subscriber);
     }
   }
 }
コード例 #2
0
 @Override
 public void registerKeySubscriber(
     @NotNull RequestContext rc, @NotNull Subscriber<K> subscriber, @NotNull Filter<K> filter) {
   addToStats("keySubscription");
   final Boolean bootstrap = rc.bootstrap();
   final Subscriber<K> sub = subscriber(subscriber, filter);
   keySubscribers.add(sub);
   if (bootstrap != Boolean.FALSE && kvStore != null) {
     try {
       for (int i = 0; i < kvStore.segments(); i++) kvStore.keysFor(i, sub::onMessage);
       if (TRUE.equals(rc.endSubscriptionAfterBootstrap())) {
         sub.onEndOfSubscription();
         keySubscribers.remove(sub);
       }
     } catch (InvalidSubscriberException e) {
       keySubscribers.remove(sub);
     }
   }
 }
コード例 #3
0
  private void registerSubscriber0(
      @NotNull RequestContext rc,
      @NotNull Subscriber<MapEvent<K, V>> subscriber,
      @NotNull Filter<MapEvent<K, V>> filter) {
    addToStats("subscription");
    final Subscriber<MapEvent<K, V>> sub = subscriber(subscriber, filter);
    this.subscribers.add(sub);
    Boolean bootstrap = rc.bootstrap();
    if (bootstrap != Boolean.FALSE && kvStore != null) {
      try {
        for (int i = 0; i < kvStore.segments(); i++) kvStore.entriesFor(i, sub::onMessage);

        if (TRUE.equals(rc.endSubscriptionAfterBootstrap())) {

          sub.onEndOfSubscription();
          LOG.info("onEndOfSubscription");
          this.subscribers.remove(sub);
        }

      } catch (InvalidSubscriberException e) {
        this.subscribers.remove(sub);
      }
    }
  }