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

The following examples show how to use io.vertx.core.spi.cluster.NodeSelector. 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
public SubsCacheHelper(DefaultCacheManager cacheManager, NodeSelector nodeSelector) {
  @SuppressWarnings("unchecked")
  MultimapCacheManager<String, byte[]> multimapCacheManager = EmbeddedMultimapCacheManagerFactory.from(cacheManager);
  subsCache = (EmbeddedMultimapCache<String, byte[]>) multimapCacheManager.get("__vertx.subs");
  this.nodeSelector = nodeSelector;
  entryListener = new EntryListener();
  Set<Class<? extends Annotation>> filterAnnotations = Stream.<Class<? extends Annotation>>builder()
    .add(CacheEntryCreated.class)
    .add(CacheEntryModified.class)
    .add(CacheEntryRemoved.class)
    .build()
    .collect(toSet());
  subsCache.getCache()
    .addFilteredListener(entryListener, new EventFilter(), new EventConverter(), filterAnnotations);
}
 
Example #3
Source File: SubsMapHelper.java    From vertx-hazelcast with Apache License 2.0 4 votes vote down vote up
public SubsMapHelper(VertxInternal vertx, HazelcastInstance hazelcast, NodeSelector nodeSelector) {
  this.vertx = vertx;
  map = hazelcast.getMultiMap("__vertx.subs");
  this.nodeSelector = nodeSelector;
  listenerId = map.addEntryListener(this, false);
}