SharedData sharedData = new SharedData(); sharedData = SharedData.getInstance(); sharedData.setSrc_latitude(latitude); sharedData.setEnd_longitude(longitude);
/** * Get the shared data object. There is a single instance of SharedData per Vertx instance. * @return the shared data object */ public io.vertx.rxjava.core.shareddata.SharedData sharedData() { if (cached_2 != null) { return cached_2; } io.vertx.rxjava.core.shareddata.SharedData ret = io.vertx.rxjava.core.shareddata.SharedData.newInstance(delegate.sharedData()); cached_2 = ret; return ret; }
SharedData data1 = new SharedData(); data1.setLoginName(Username_Login.getText().toString()); MainFrame frame = new MainFrame(data1);
public static SharedData newInstance(io.vertx.core.shareddata.SharedData arg) { return arg != null ? new SharedData(arg) : null; } }
public void voidAsyncOpToBlocking(Func1<AsyncMap, Observable> asyncOp) { CompletableFuture<Void> future = new CompletableFuture<>(); rxVertx.sharedData().getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .map(asyncOp) .subscribe(result -> future.complete(null)); try { future.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException |TimeoutException e) { throw new TechnicalException(e); } } }
/** * Get the cluster wide map with the specified name. The map is accessible to all nodes in the cluster and data * put into the map from any node is visible to to any other node. * @param name the name of the map * @return * @deprecated use {@link #rxGetClusterWideMap} instead */ @Deprecated() public <K, V> Observable<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> getClusterWideMapObservable(String name) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); getClusterWideMap(name, resultHandler.toHandler()); return resultHandler; }
/** * Get an asynchronous counter. The counter will be passed to the handler. * @param name the name of the counter. * @return * @deprecated use {@link #rxGetCounter} instead */ @Deprecated() public Observable<io.vertx.rxjava.core.shareddata.Counter> getCounterObservable(String name) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.core.shareddata.Counter> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); getCounter(name, resultHandler.toHandler()); return resultHandler; }
/** * Get an asynchronous lock with the specified name. The lock will be passed to the handler when it is available. * <p> * In general lock acquision is unordered, so that sequential attempts to acquire a lock, * even from a single thread, can happen in non-sequential order. * </p> * @param name the name of the lock * @return * @deprecated use {@link #rxGetLock} instead */ @Deprecated() public Observable<io.vertx.rxjava.core.shareddata.Lock> getLockObservable(String name) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.core.shareddata.Lock> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); getLock(name, resultHandler.toHandler()); return resultHandler; }
/** * Get the {@link io.vertx.rxjava.core.shareddata.AsyncMap} with the specified name. When clustered, the map is accessible to all nodes in the cluster * and data put into the map from any node is visible to to any other node. * <p> * <strong>WARNING</strong>: In clustered mode, asynchronous shared maps rely on distributed data structures provided by the cluster manager. * Beware that the latency relative to asynchronous shared maps operations can be much higher in clustered than in local mode. * </p> * @param name the name of the map * @return * @deprecated use {@link #rxGetAsyncMap} instead */ @Deprecated() public <K, V> Observable<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> getAsyncMapObservable(String name) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); getAsyncMap(name, resultHandler.toHandler()); return resultHandler; }
/** * Like {@link io.vertx.rxjava.core.shareddata.SharedData#getLock} but specifying a timeout. If the lock is not obtained within the timeout * a failure will be sent to the handler. * <p> * In general lock acquision is unordered, so that sequential attempts to acquire a lock, * even from a single thread, can happen in non-sequential order. * </p> * @param name the name of the lock * @param timeout the timeout in ms * @return * @deprecated use {@link #rxGetLockWithTimeout} instead */ @Deprecated() public Observable<io.vertx.rxjava.core.shareddata.Lock> getLockWithTimeoutObservable(String name, long timeout) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.core.shareddata.Lock> resultHandler = io.vertx.rx.java.RxHelper.observableFuture(); getLockWithTimeout(name, timeout, resultHandler.toHandler()); return resultHandler; }
return vertx.sharedData().rxGetCounter(key) .flatMap(counter -> counter.rxCompareAndSet(0, 1)) .flatMapCompletable(success -> {
private static SharedData instance = new SharedData(); \\ Initialize here private SharedData() { // Make it private.... // randomizeServers(); } // data to be shared private double src_latitude = -1; private double src_longitude = -1; private double end_latitude = -1; private double end_longitude = -1; //Getter-Setters public static SharedData getInstance() { return instance; }
public void voidAsyncOpToBlocking(Func1<AsyncMap, Observable> asyncOp) { CompletableFuture<Void> future = new CompletableFuture<>(); rxVertx.sharedData().getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .map(asyncOp) .subscribe(result -> future.complete(null)); try { future.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException |TimeoutException e) { throw new TechnicalException(e); } } }
/** * Get the cluster wide map with the specified name. The map is accessible to all nodes in the cluster and data * put into the map from any node is visible to to any other node. * @param name the name of the map * @return */ public <K, V> Single<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> rxGetClusterWideMap(String name) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { getClusterWideMap(name, fut); })); }
/** * Get an asynchronous counter. The counter will be passed to the handler. * @param name the name of the counter. * @return */ public Single<io.vertx.rxjava.core.shareddata.Counter> rxGetCounter(String name) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { getCounter(name, fut); })); }
/** * Get an asynchronous lock with the specified name. The lock will be passed to the handler when it is available. * <p> * In general lock acquision is unordered, so that sequential attempts to acquire a lock, * even from a single thread, can happen in non-sequential order. * </p> * @param name the name of the lock * @return */ public Single<io.vertx.rxjava.core.shareddata.Lock> rxGetLock(String name) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { getLock(name, fut); })); }
/** * Get the {@link io.vertx.rxjava.core.shareddata.AsyncMap} with the specified name. When clustered, the map is accessible to all nodes in the cluster * and data put into the map from any node is visible to to any other node. * <p> * <strong>WARNING</strong>: In clustered mode, asynchronous shared maps rely on distributed data structures provided by the cluster manager. * Beware that the latency relative to asynchronous shared maps operations can be much higher in clustered than in local mode. * </p> * @param name the name of the map * @return */ public <K, V> Single<io.vertx.rxjava.core.shareddata.AsyncMap<K, V>> rxGetAsyncMap(String name) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { getAsyncMap(name, fut); })); }
/** * Like {@link io.vertx.rxjava.core.shareddata.SharedData#getLock} but specifying a timeout. If the lock is not obtained within the timeout * a failure will be sent to the handler. * <p> * In general lock acquision is unordered, so that sequential attempts to acquire a lock, * even from a single thread, can happen in non-sequential order. * </p> * @param name the name of the lock * @param timeout the timeout in ms * @return */ public Single<io.vertx.rxjava.core.shareddata.Lock> rxGetLockWithTimeout(String name, long timeout) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { getLockWithTimeout(name, timeout, fut); })); }
public static SharedData newInstance(io.vertx.core.shareddata.SharedData arg) { return arg != null ? new SharedData(arg) : null; } }
@Override public V get(K key) { voidAsyncOpToBlocking(map -> map.getObservable((key))); final CompletableFuture<V> valueFuture = new CompletableFuture<>(); rxVertx.sharedData().<K, V>getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .flatMap(map -> map.getObservable(key)) .subscribe(valueFuture::complete); try { return valueFuture.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException|TimeoutException e) { throw new TechnicalException(e); } }