public Observable<R> toObservableWithStateCopiedInto(final AbstractCommand<R> commandToCopyStateInto) { final AtomicBoolean completionLogicRun = new AtomicBoolean(false); return cachedObservable .doOnError(new Action1<Throwable>() { @Override public void call(Throwable throwable) { if (completionLogicRun.compareAndSet(false, true)) { commandCompleted(commandToCopyStateInto); } } }) .doOnCompleted(new Action0() { @Override public void call() { if (completionLogicRun.compareAndSet(false, true)) { commandCompleted(commandToCopyStateInto); } } }) .doOnUnsubscribe(new Action0() { @Override public void call() { if (completionLogicRun.compareAndSet(false, true)) { commandUnsubscribed(commandToCopyStateInto); } } }); }
doDeletes( node, scope, maxVersion.get(), timestamp ).doOnCompleted( () -> { try { nodeSerialization.delete( scope, node, maxVersion.get()).execute();
}).doOnCompleted(new Action0() {
/** * Time the obserable with the specified timer */ public static <T> Observable<T> time( final Observable<T> observable, final Timer timer ) { final ObservableTimer proxy = new ObservableTimer( timer ); //attach to the observable return observable.doOnSubscribe( () -> proxy.start() ).doOnCompleted( () -> proxy.stop() ); } }
private void _writeStreamToChannel(final Subscriber<? super Void> subscriber, final long startTimeNanos) { final ChannelFuture writeFuture = nettyChannel.write(msgs.doOnCompleted(new Action0() { @Override public void call() {
.doOnCompleted(() -> writeStateMeta( jobId, Status.COMPLETE, count.get(), System.currentTimeMillis() )) .subscribeOn( Schedulers.io() ).subscribe();
@Override public void call(Subscriber<? super Void> subscriber) { if (!isUsable()) { PooledConnection.this.owner.discard(PooledConnection.this) .unsafeSubscribe(subscriber); } else { Long keepAliveTimeout = unsafeNettyChannel().attr(DYNAMIC_CONN_KEEP_ALIVE_TIMEOUT_MS).get(); if (null != keepAliveTimeout) { PooledConnection.this.maxIdleTimeMillis = keepAliveTimeout; } markAwarePipeline.reset(); // Reset pipeline state, if changed, on release. PooledConnection.this.owner.release(PooledConnection.this) .doOnCompleted(new Action0() { @Override public void call() { releasedAtLeastOnce = true; lastReturnToPoolTimeMillis = System.currentTimeMillis(); } }) .unsafeSubscribe(subscriber); } } }).onErrorResumeNext(discard());
.doOnCompleted(new Action0() { @Override public void call() {
.doOnCompleted(() -> {
.doOnCompleted(() ->{ if( isForCollection ){ writeStateMetaForCollection(
@Test @Category(ExperimentalTest.class ) public void testPublish() throws InterruptedException { final int count = 10; final CountDownLatch latch = new CountDownLatch( count+1 ); final Subscription connectedObservable = Observable.range( 0, count ) .doOnNext( integer -> latch.countDown() ) .doOnCompleted( () -> latch.countDown() ).subscribeOn( Schedulers.io() ) .subscribe(); final boolean completed = latch.await( 3, TimeUnit.SECONDS ); assertTrue( "publish1 behaves as expected", completed ); final boolean completedSubscription = connectedObservable.isUnsubscribed(); assertTrue( "Subscription complete", completedSubscription ); }
@Override public void run( ProgressObserver observer ) { final int version = migrationInfoSerialization.getVersion( getName() ); if ( version == getMaxVersion() ) { if (logger.isDebugEnabled()) { logger.debug("Skipping Migration Plugin: {}", getName()); } return; } observer.start(); AtomicInteger count = new AtomicInteger(); //get old app infos to migrate final Observable<Entity> oldAppInfos = getOldAppInfos(); oldAppInfos.doOnNext( oldAppInfoEntity -> { migrateAppInfo( oldAppInfoEntity, observer ); count.incrementAndGet(); } ) //we want a doOnError to catch something going wrong, otherwise we'll mark as complete .doOnError( error -> { logger.error( "Unable to migrate applications, an error occurred. Please try again", error ); observer.failed( getMaxVersion(), "Unable to migrate applications", error ); } ) //if we complete successfully, set the version and notify the observer .doOnCompleted( () -> { migrationInfoSerialization.setVersion( getName(), getMaxVersion() ); observer.complete(); } ).subscribe();//let this run through since it handles errors }
.doOnCompleted(fireOnCompletedHook);
observer.failed(getMaxVersion(),"failed to update",t); }) .doOnCompleted(() -> { migrationInfoSerialization.setVersion(getName(), getMaxVersion()); observer.complete();
.doOnCompleted(new Action0() { @Override public void call() {
.doOnCompleted(new Action0() { @Override public void call() {
} ).doOnCompleted( () -> {
.lift(new DeprecatedOnFallbackHookApplication(_cmd)) .doOnNext(markFallbackEmit) .doOnCompleted(markFallbackCompleted) .onErrorResumeNext(handleFallbackError) .doOnTerminate(singleSemaphoreRelease)
.doOnCompleted( () -> { try { if ( oldAppEntity != null ) {
.doOnCompleted(markOnCompleted) .onErrorResumeNext(handleFallback) .doOnEach(setRequestContext);