public static TimeoutStream newInstance(io.vertx.core.TimeoutStream arg) { return arg != null ? new TimeoutStream(arg) : null; } }
public synchronized rx.Observable<Long> toObservable() { if (observable == null) { observable = io.vertx.rx.java.RxHelper.toObservable(this.getDelegate()); } return observable; }
/** * Returns a periodic timer as a read stream. The timer will be fired every <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the periodic stream */ public io.vertx.rxjava.core.TimeoutStream periodicStream(long delay) { io.vertx.rxjava.core.TimeoutStream ret = io.vertx.rxjava.core.TimeoutStream.newInstance(delegate.periodicStream(delay)); return ret; }
private Observable<Integer> waitForExit() { return rxVertx.timerStream(POLLING_INTERVAL_IN_MS).toObservable() .flatMap(x -> { if (process.isAlive()) { return waitForExit(); } else { if (process.exitValue() != expectedResultCode) { printStream(process.getInputStream(), false); throw new IllegalStateException(printStream(process.getErrorStream(), true)); } else { printStream(process.getInputStream(), false); } return just(process.exitValue()); } }); }
private Observable<DeployRequest> doPoll(DeployRequest request) { return rxVertx.timerStream(POLLING_INTERVAL_IN_MS).toObservable() .flatMap(x -> awsAsUtil.pollForInstanceState()) .flatMap(awsState -> { if (LocalDateTime.now().isAfter(timeout)) { LOG.error("[{} - {}]: Timeout while waiting for instance to reach {} ", LogConstants.AWS_AS_REQUEST, request.getId(), awsState.name()); throw new IllegalStateException(); } LOG.info("[{} - {}]: Instance {} in auto scaling group {} in state {}", LogConstants.AWS_AS_REQUEST, request.getId(), awsAsUtil.getInstanceId(), request.getAutoScalingGroup(), awsState.name()); if (acceptedStates.contains(awsState)) { return Observable.just(request); } else { return doPoll(request); } } ); }
private Observable<DeployRequest> doPoll(DeployRequest request, String elb) { return rxVertx.timerStream(POLLING_INTERVAL_IN_MS).toObservable() .flatMap(x -> awsElbUtil.pollForInstanceState(elb)) .flatMap(awsState -> { if (!requestStillActive.apply(deployId)) { LOG.error("[{} - {}]: Request canceled, stopping poller {} ", LogConstants.AWS_ELB_REQUEST, request.getId(), awsState.name()); throw new IllegalStateException(); } if (LocalDateTime.now().isAfter(timeout)) { LOG.error("[{} - {}]: Timeout while waiting for instance to reach {} ", LogConstants.AWS_ELB_REQUEST, request.getId(), awsState.name()); throw new IllegalStateException(); } LOG.info("[{} - {}]: Instance {} on elb {} in state {}", LogConstants.AWS_ELB_REQUEST, request.getId(), awsElbUtil.getInstanceId(), elb, awsState.name()); if (acceptedStates.contains(awsState)) { return Observable.just(request); } else { return doPoll(request, elb); } } ); }
/** * Returns a periodic timer as a read stream. The timer will be fired every <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the periodic stream */ public io.vertx.rxjava.core.TimeoutStream periodicStream(long delay) { io.vertx.rxjava.core.TimeoutStream ret = io.vertx.rxjava.core.TimeoutStream.newInstance(delegate.periodicStream(delay)); return ret; }
public synchronized rx.Observable<Long> toObservable() { if (observable == null) { observable = io.vertx.rx.java.RxHelper.toObservable(this.getDelegate()); } return observable; }
public static TimeoutStream newInstance(io.vertx.core.TimeoutStream arg) { return arg != null ? new TimeoutStream(arg) : null; } }
private Observable<DeployApplicationRequest> doPoll(DeployApplicationRequest request) { return rxVertx.timerStream(POLLING_INTERVAL_IN_MS).toObservable() .flatMap(x -> processUtils.checkModuleRunning(request)) .flatMap(result -> { if (LocalDateTime.now().isAfter(timeout)) { LOG.error("[{} - {}]: Timeout while waiting for application to stop. ", LogConstants.DEPLOY_REQUEST, request.getId()); throw new IllegalStateException(); } if (!request.isRunning()) { LOG.info("[{} - {}]: Application {} stopped.", LogConstants.DEPLOY_REQUEST, request.getId(), request.getMavenArtifactId()); return just(request); } else { LOG.trace("[{} - {}]: Application {} still running.", LogConstants.DEPLOY_REQUEST, request.getId(), request.getMavenArtifactId()); return doPoll(request); } } ) .doOnError(t -> LOG.info("[{} - {}]: Error while Waiting for module '{}' with applicationId '{}' to stop -> '{}'.", LogConstants.DEPLOY_REQUEST, request.getId(), request.getModuleId(), t)); } }
/** * Returns a one-shot timer as a read stream. The timer will be fired after <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the timer stream */ public io.vertx.rxjava.core.TimeoutStream timerStream(long delay) { io.vertx.rxjava.core.TimeoutStream ret = io.vertx.rxjava.core.TimeoutStream.newInstance(delegate.timerStream(delay)); return ret; }
@Test public void testConcatOperator() { Observable<Long> o1 = vertx.timerStream(100).toObservable(); Observable<Long> o2 = vertx.timerStream(100).toObservable(); Observable<Long> obs = Observable.concat(o1, o2); AtomicInteger count = new AtomicInteger(); obs.subscribe(msg -> count.incrementAndGet(), err -> fail(), () -> { assertEquals(2, count.get()); testComplete(); }); await(); }
/** * Returns a one-shot timer as a read stream. The timer will be fired after <code>delay</code> milliseconds after * the has been called. * @param delay the delay in milliseconds, after which the timer will fire * @return the timer stream */ public io.vertx.rxjava.core.TimeoutStream timerStream(long delay) { io.vertx.rxjava.core.TimeoutStream ret = io.vertx.rxjava.core.TimeoutStream.newInstance(delegate.timerStream(delay)); return ret; }
@Test public void testObservablePeriodic() throws Exception { Vertx vertx = new Vertx(this.vertx); Observable<Long> stream = vertx.periodicStream(1).toObservable(); stream.subscribe(new Subscriber<Long>() { @Override public void onNext(Long aLong) { unsubscribe(); testComplete(); } @Override public void onCompleted() { fail(); } @Override public void onError(Throwable e) { fail(e.getMessage()); } }); await(); } }