io.vertx.core.spi.cluster.RegistrationUpdateEvent Java Examples

The following examples show how to use io.vertx.core.spi.cluster.RegistrationUpdateEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubsMapHelper.java    From vertx-ignite with Apache License 2.0 6 votes vote down vote up
public SubsMapHelper(Ignite ignite, NodeSelector nodeSelector) {
  map = ignite.getOrCreateCache("__vertx.subs");

  ignite.events().localListen((IgnitePredicate<Event>) event -> {
    if (!(event instanceof CacheEvent)) {
      return true;
    }
    CacheEvent cacheEvent = (CacheEvent) event;
    if (!Objects.equals(cacheEvent.cacheName(), map.getName())) {
      return true;
    }
    String address = cacheEvent.<IgniteRegistrationInfo>key().address();
    Promise<List<RegistrationInfo>> promise = Promise.promise();
    promise.future().onSuccess(registrationInfos -> {
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, registrationInfos));
    });
    get(address, promise);
    return true;
  }, EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_REMOVED);
}
 
Example #2
Source File: SubsCacheHelper.java    From vertx-infinispan with Apache License 2.0 5 votes vote down vote up
private void fireRegistrationUpdateEvent(String address) {
  get(address).whenComplete((registrationInfos, throwable) -> {
    if (throwable == null) {
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, registrationInfos));
    } else {
      log.trace("A failure occured while retrieving the updated registrations", throwable);
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, Collections.emptyList()));
    }
  });
}
 
Example #3
Source File: SubsMapHelper.java    From vertx-hazelcast with Apache License 2.0 5 votes vote down vote up
private void fireRegistrationUpdateEvent(EntryEvent<String, HazelcastRegistrationInfo> event) {
  String address = event.getKey();
  vertx.<List<RegistrationInfo>>executeBlocking(prom -> {
    prom.complete(get(address));
  }, false, ar -> {
    if (ar.succeeded()) {
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, ar.result()));
    } else {
      log.trace("A failure occured while retrieving the updated registrations", ar.cause());
      nodeSelector.registrationsUpdated(new RegistrationUpdateEvent(address, Collections.emptyList()));
    }
  });
}