@Override public Observable<EntityIdScope> getEntities( final Observable<ApplicationScope> appScopes ) { return appScopes.flatMap( applicationScope -> { final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope ); final Id applicationId = applicationScope.getApplication(); //load all nodes that are targets of our application node. I.E. // entities that have been saved final Observable<Id> entityNodes = targetIdObservable.getTargetNodes( gm, applicationId ); //create our application node to emit since it's an entity as well final Observable<Id> applicationNode = Observable.just( applicationId ); //merge both the specified application node and the entity node // so they all get used return Observable.merge( applicationNode, entityNodes ). map( id -> new EntityIdScope( applicationScope, id ) ); } ); }
merge = current; else { merge = Observable.merge(merge,current);
Observable.merge(commands).subscribe(new Subscriber<Integer>() { @Override public void onCompleted() {
final Observable<BatchOperation> batchOps = Observable.merge(index, deIndex);
}); return Observable.merge( systemIds, appIds );
public Observable<Integer> receive( final ApplicationScope scope, final MarkedEdge edge, final UUID eventTimestamp ) { final long maxTimestamp = edge.getTimestamp(); return edgeDeleteRepair.repair( scope, edge, eventTimestamp ) .flatMap( markedEdge -> { Observable<Integer> sourceDelete = edgeMetaRepair .repairSources( scope, edge.getSourceNode(), edge.getType(), maxTimestamp ); Observable<Integer> targetDelete = edgeMetaRepair .repairTargets( scope, edge.getTargetNode(), edge.getType(), maxTimestamp ); return MathObservable.sumInteger( Observable.merge( sourceDelete, targetDelete ) ); } ); } }
return MathObservable.sumInteger( Observable.merge( checks ) ) .doOnNext( count -> {
Observable<String> overall = Observable.merge(observables);
Observable.merge(cmdResults).subscribe(new Subscriber<Boolean>() { @Override public void onCompleted() {
@Test public void testReactive() throws Exception { final Observable<User> u1 = userService.getUserByIdReactive("1"); final Observable<User> u2 = userService.getUserByIdReactive("2"); final Observable<User> u3 = userService.getUserByIdReactive("3"); final Observable<User> u4 = userService.getUserByIdReactive("4"); final Observable<User> u5 = userService.getUserByIdReactive("5"); final Iterable<User> users = Observable.merge(u1, u2, u3, u4, u5).toBlocking().toIterable(); Set<String> expectedIds = Sets.newHashSet("1", "2", "3", "4", "5"); for (User cUser : users) { assertEquals(expectedIds.remove(cUser.getId()), true); } assertEquals(expectedIds.isEmpty(), true); assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size()); HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest() .getAllExecutedCommands().iterator().next(); // assert the command is the one we're expecting assertEquals("getUserByIds", command.getCommandKey().name()); // confirm that it was a COLLAPSED command execution assertTrue(command.getExecutionEvents().contains(HystrixEventType.COLLAPSED)); // and that it was successful assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS)); }
final List<Boolean> blockingList = Observable.merge(results).toList().toBlocking().single();
int returned = Observable.merge( input1, input2 ).buffer( 1000 ) .flatMap( new Func1<List<Integer>, Observable<Integer>>() { @Override
Observable.merge(results) .subscribeOn(Schedulers.computation()) .subscribe(new Subscriber<Boolean>() {
final LatchedSemaphoreCommand command2 = new LatchedSemaphoreCommand(circuitBreaker, semaphore, startLatch, sharedLatch); Observable<Boolean> merged = Observable.merge(command1.toObservable(), command2.toObservable()) .subscribeOn(Schedulers.computation());
.merge( copyConnections, createNodeGraph, deleteAppFromIndex ) .doOnCompleted( () -> { try {
private static void mergingSyncMadeAsync() { // if you have something synchronous and want to make it async, you can schedule it like this // so here we see both executed concurrently Observable.merge(getDataSync(1).subscribeOn(Schedulers.io()), getDataSync(2).subscribeOn(Schedulers.io())).toBlocking().forEach(System.out::println); }
Observable.merge(result1, result2).toList().toBlocking().single(); //await the 2 latent commands
private static void mergingSync() { // here you'll see the delay as each is executed synchronously Observable.merge(getDataSync(1), getDataSync(2)).toBlocking().forEach(System.out::println); }
private static void mergingAsync() { Observable.merge(getDataAsync(1), getDataAsync(2)).toBlocking().forEach(System.out::println); }