io.vertx.core.spi.cluster.RegistrationInfo Java Examples
The following examples show how to use
io.vertx.core.spi.cluster.RegistrationInfo.
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 |
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: SubsMapHelper.java From vertx-ignite with Apache License 2.0 | 5 votes |
public void get(String address, Promise<List<RegistrationInfo>> promise) { try { List<RegistrationInfo> infos = map.query(new ScanQuery<IgniteRegistrationInfo, Boolean>((k, v) -> k.address().equals(address))) .getAll().stream() .map(Cache.Entry::getKey) .map(IgniteRegistrationInfo::registrationInfo) .collect(toList()); promise.complete(infos); } catch (IllegalStateException | CacheException e) { promise.fail(new VertxException(e)); } }
Example #3
Source File: SubsMapHelper.java From vertx-ignite with Apache License 2.0 | 5 votes |
public Future<Void> put(String address, RegistrationInfo registrationInfo) { try { map.put(new IgniteRegistrationInfo(address, registrationInfo), Boolean.TRUE); } catch (IllegalStateException | CacheException e) { return Future.failedFuture(new VertxException(e)); } return Future.succeededFuture(); }
Example #4
Source File: SubsMapHelper.java From vertx-ignite with Apache License 2.0 | 5 votes |
public void remove(String address, RegistrationInfo registrationInfo, Promise<Void> promise) { try { map.remove(new IgniteRegistrationInfo(address, registrationInfo)); promise.complete(); } catch (IllegalStateException | CacheException e) { promise.fail(new VertxException(e)); } }
Example #5
Source File: SubsOpSerializer.java From vertx-infinispan with Apache License 2.0 | 5 votes |
public void execute(BiFunction<String, RegistrationInfo, CompletableFuture<Void>> op, String address, RegistrationInfo registrationInfo, Promise<Void> promise) { if (Vertx.currentContext() != context) { context.runOnContext(v -> execute(op, address, registrationInfo, promise)); return; } tasks.add(new Task(op, address, registrationInfo, promise)); if (tasks.size() == 1) { processTask(tasks.peek()); } }
Example #6
Source File: SubsOpSerializer.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public void execute(BiConsumer<String, RegistrationInfo> op, String address, RegistrationInfo registrationInfo, Promise<Void> promise) { taskQueue.execute(() -> { try { op.accept(address, registrationInfo); promise.complete(); } catch (Exception e) { promise.fail(e); } }, vertx.getWorkerPool()); }
Example #7
Source File: SubsMapHelper.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
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())); } }); }
Example #8
Source File: SubsMapHelper.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public void republishOwnSubs() { Lock writeLock = republishLock.writeLock(); writeLock.lock(); try { for (Map.Entry<String, Set<RegistrationInfo>> entry : ownSubs.entrySet()) { String address = entry.getKey(); for (RegistrationInfo registrationInfo : entry.getValue()) { map.put(address, new HazelcastRegistrationInfo(registrationInfo)); } } } finally { writeLock.unlock(); } }
Example #9
Source File: SubsMapHelper.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public void remove(String address, RegistrationInfo registrationInfo) { Lock readLock = republishLock.readLock(); readLock.lock(); try { ownSubs.computeIfPresent(address, (add, curr) -> { curr.remove(registrationInfo); return curr.isEmpty() ? null : curr; }); map.remove(address, new HazelcastRegistrationInfo(registrationInfo)); } finally { readLock.unlock(); } }
Example #10
Source File: SubsMapHelper.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public void put(String address, RegistrationInfo registrationInfo) { Lock readLock = republishLock.readLock(); readLock.lock(); try { ownSubs.compute(address, (add, curr) -> { Set<RegistrationInfo> res = curr != null ? curr : new CopyOnWriteArraySet<>(); res.add(registrationInfo); return res; }); map.put(address, new HazelcastRegistrationInfo(registrationInfo)); } finally { readLock.unlock(); } }
Example #11
Source File: SubsMapHelper.java From vertx-hazelcast with Apache License 2.0 | 5 votes |
public List<RegistrationInfo> get(String address) { Lock readLock = republishLock.readLock(); readLock.lock(); try { List<RegistrationInfo> list = new ArrayList<>(); for (HazelcastRegistrationInfo registrationInfo : map.get(address)) { list.add(registrationInfo.unwrap()); } return list; } finally { readLock.unlock(); } }
Example #12
Source File: HazelcastRegistrationInfo.java From vertx-hazelcast with Apache License 2.0 | 4 votes |
@Override public void readData(ObjectDataInput dataInput) throws IOException { registrationInfo = new RegistrationInfo(dataInput.readUTF(), dataInput.readLong(), dataInput.readBoolean()); }
Example #13
Source File: HazelcastRegistrationInfo.java From vertx-hazelcast with Apache License 2.0 | 4 votes |
public RegistrationInfo unwrap() { return registrationInfo; }
Example #14
Source File: HazelcastRegistrationInfo.java From vertx-hazelcast with Apache License 2.0 | 4 votes |
public HazelcastRegistrationInfo(RegistrationInfo registrationInfo) { this.registrationInfo = Objects.requireNonNull(registrationInfo); }
Example #15
Source File: SubsCacheHelper.java From vertx-infinispan with Apache License 2.0 | 4 votes |
public void removeAllForNode(String nodeId) { subsCache.remove((SerializablePredicate<byte[]>) value -> nodeId.equals(DataConverter.<RegistrationInfo>fromCachedObject(value).nodeId())); }
Example #16
Source File: SubsCacheHelper.java From vertx-infinispan with Apache License 2.0 | 4 votes |
public CompletableFuture<Void> remove(String address, RegistrationInfo registrationInfo) { return subsCache.remove(address, DataConverter.toCachedObject(registrationInfo)) .thenApply(v -> null); }
Example #17
Source File: SubsCacheHelper.java From vertx-infinispan with Apache License 2.0 | 4 votes |
public CompletableFuture<Void> put(String address, RegistrationInfo registrationInfo) { return subsCache.put(address, DataConverter.toCachedObject(registrationInfo)); }
Example #18
Source File: SubsCacheHelper.java From vertx-infinispan with Apache License 2.0 | 4 votes |
public CompletableFuture<List<RegistrationInfo>> get(String address) { return subsCache.get(address) .thenApply(collection -> collection.stream().map(DataConverter::<RegistrationInfo>fromCachedObject).collect(toList())); }
Example #19
Source File: SubsOpSerializer.java From vertx-infinispan with Apache License 2.0 | 4 votes |
Task(BiFunction<String, RegistrationInfo, CompletableFuture<Void>> op, String address, RegistrationInfo registrationInfo, Promise<Void> promise) { this.op = op; this.address = address; this.registrationInfo = registrationInfo; this.promise = promise; }
Example #20
Source File: IgniteRegistrationInfo.java From vertx-ignite with Apache License 2.0 | 4 votes |
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException { address = reader.readString("address"); registrationInfo = new RegistrationInfo(reader.readString("nodeId"), reader.readLong("seq"), reader.readBoolean("isLocalOnly")); }
Example #21
Source File: IgniteRegistrationInfo.java From vertx-ignite with Apache License 2.0 | 4 votes |
public RegistrationInfo registrationInfo() { return registrationInfo; }
Example #22
Source File: IgniteRegistrationInfo.java From vertx-ignite with Apache License 2.0 | 4 votes |
public IgniteRegistrationInfo(String address, RegistrationInfo registrationInfo) { this.address = Objects.requireNonNull(address); this.registrationInfo = Objects.requireNonNull(registrationInfo); }