rx.subjects.ReplaySubject Java Examples

The following examples show how to use rx.subjects.ReplaySubject. 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: BizkeeperHandlerDelegate.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
protected HystrixObservable<Response> forceFallbackCommand(Invocation invocation) {
  return new HystrixObservable<Response>() {
    @Override
    public Observable<Response> observe() {
      ReplaySubject<Response> subject = ReplaySubject.create();
      final Subscription sourceSubscription = toObservable().subscribe(subject);
      return subject.doOnUnsubscribe(sourceSubscription::unsubscribe);
    }

    @Override
    public Observable<Response> toObservable() {
      return Observable.create(f -> {
        try {
          f.onNext(FallbackPolicyManager.getFallbackResponse(handler.groupname, null, invocation));
        } catch (Exception e) {
          f.onError(e);
        }
      });
    }
  };
}
 
Example #2
Source File: ObservableQueue.java    From Jockey with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an Observable stream from this queue. There should only ever be one subscriber to
 * this method. Calling this method twice will complete any previously opened observable
 * (leaving unprocessed elements in the queue).
 * @return An observable containing the contents of the queue in order
 */
public Observable<T> toObservable() {
    synchronized (mLock) {
        if (mSubject != null) {
            mSubject.onCompleted();
        }

        if (mQueue.isEmpty()) {
            mSubject = ReplaySubject.create();
        } else {
            mSubject = ReplaySubject.create(mQueue.size());

            for (T data : mQueue) {
                mSubject.onNext(data);
            }
        }
    }

    return mSubject.map(item -> {
        mQueue.remove();
        return item;
    }).asObservable();
}
 
Example #3
Source File: Publisher.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Builds and validates the structure of the expected header then
 * returns an {@link Observable} that can be used to submit info to the
 * {@link Network}
 * @return  a new Publisher
 */
public Publisher build() {
    subject = ReplaySubject.createWithSize(3);
    for(int i = 0;i < HEADER_SIZE;i++) {
        if(lines[i] == null) {
            throw new IllegalStateException("Header not properly formed (must contain 3 lines) see Header.java");
        }
        subject.onNext(lines[i]);
    }
    
    Publisher p = new Publisher();
    p.subject = subject;
    
    if(notifier != null) {
        notifier.accept(p);
    }
    
    return p;
}
 
Example #4
Source File: AppGoogleAds.java    From fyber_mobile_offers with MIT License 6 votes vote down vote up
@Override
public Observable<Boolean> getAdIdEnabledObservable() {
    // Observable that emits Google Tracking Enabled
    if (adIdEnabledSubscription == null || adIdEnabledSubscription.isUnsubscribed()) {
        adIdEnabledSubject = ReplaySubject.create();

        adIdEnabledSubscription = Observable
                .concat(getAdIdEnabledFromMemoryObservable(),
                        getAdIdEnabledFromGoogleObservable())
                .first(entity -> entity != null)
                // lets retry if something goes wrong!
                .retry(2)
                .subscribe(adIdEnabledSubject);
    }

    return adIdEnabledSubject.asObservable();
}
 
Example #5
Source File: AppGoogleAds.java    From fyber_mobile_offers with MIT License 6 votes vote down vote up
@Override
public Observable<String> getAdIdObservable() {
    // Observable that emits Google Advertising adIdSubscription
    if (adIdSubscription == null || adIdSubscription.isUnsubscribed()) {
        adIdSubject = ReplaySubject.create();

        adIdSubscription = Observable
                .concat(getAdIdFromMemoryObservable(),
                        getAdIdFromGoogleObservable())
                .first(entity -> entity != null)
                // lets retry if something goes wrong!
                .retry(2)
                .subscribe(adIdSubject);
    }

    return adIdSubject.asObservable();
}
 
Example #6
Source File: CoordinatedWeatherManager.java    From rain-or-shine with Apache License 2.0 6 votes vote down vote up
private Observable<List<String>> getCityNames() {
    if (cityNames == null) {
        cityNames = ReplaySubject.create(1);

        geoNamesClient.getCities()
                .flatMap(cities -> Observable.from(cities.geonames))
                .map(city -> {
                    String format = String.format("%s,%s", city.name, city.countrycode);
                    return format;
                })
                .toList()
                .subscribe(cityNames);
    }
    Log.d(TAG, "Returning city names");
    return cityNames.asObservable();
}
 
Example #7
Source File: RemoteObservableTest.java    From mantis with Apache License 2.0 5 votes vote down vote up
@Test
public void testServedMergedObservablesAddAfterServe() {
    // setup
    Observable<Integer> os1 = Observable.range(0, 100);
    Observable<Integer> os2 = Observable.range(100, 100);
    ReplaySubject<Observable<Integer>> subject = ReplaySubject.create();
    subject.onNext(os1);
    subject.onNext(os2);
    // serve
    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    int serverPort = portSelector.acquirePort();

    RemoteRxServer server = new RemoteRxServer.Builder()
            .port(serverPort)
            .addObservable(new ServeObservable.Builder<Integer>()
                    .encoder(Codecs.integer())
                    .observable(Observable.merge(subject))
                    .build())
            .build();
    server.start();

    // add after serve
    Observable<Integer> os3 = Observable.range(200, 101);
    subject.onNext(os3);
    subject.onCompleted();

    // connect
    Observable<Integer> oc = RemoteObservable.connect("localhost", serverPort, Codecs.integer());
    // assert
    MathObservable.sumInteger(oc).toBlocking().forEach(new Action1<Integer>() {
        @Override
        public void call(Integer t1) {
            Assert.assertEquals(45150, t1.intValue()); // sum of number 0-200
        }
    });
}
 
Example #8
Source File: HttpMetaRequest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public Observable<RibbonResponse<Observable<T>>> observe() {
    HystrixObservableCommandChain<T> commandChain = request.createHystrixCommandChain();
    Observable<ResultCommandPair<T>> notificationObservable = commandChain.toResultCommandPairObservable();
    notificationObservable = retainBufferIfNeeded(notificationObservable);
    ReplaySubject<ResultCommandPair<T>> subject = ReplaySubject.create();
    notificationObservable.subscribe(subject);
    return convertToRibbonResponse(commandChain, subject);
}
 
Example #9
Source File: DynamicConnectionSetTest.java    From mantis with Apache License 2.0 5 votes vote down vote up
@Test
public void testMergeInWithDeltaEndpointService() {
    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    final int server1Port = portSelector.acquirePort();
    final int server2Port = portSelector.acquirePort();

    // setup servers
    RemoteRxServer server1 = RemoteObservable.serve(server1Port, Observable.range(1, 50), Codecs.integer());
    RemoteRxServer server2 = RemoteObservable.serve(server2Port, Observable.range(51, 50), Codecs.integer());

    server1.start();
    server2.start();

    ReplaySubject<List<Endpoint>> subject = ReplaySubject.create();
    List<Endpoint> endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", server1Port));
    endpoints.add(new Endpoint("localhost", server2Port));
    subject.onNext(endpoints);
    subject.onCompleted();

    DynamicConnectionSet<Integer> cm
            = DynamicConnectionSet.create(new ConnectToObservable.Builder<Integer>()
            .decoder(Codecs.integer()));
    cm.setEndpointInjector(new ToDeltaEndpointInjector(subject));

    int sum = MathObservable.sumInteger(Observable.merge(cm.observables()))
            .toBlocking()
            .last();
    Assert.assertEquals(5050, sum);

}
 
Example #10
Source File: RemoteObservableTest.java    From mantis with Apache License 2.0 5 votes vote down vote up
@Test
public void testServedMergedObservables() {
    // setup
    Observable<Integer> os1 = Observable.range(0, 101);
    Observable<Integer> os2 = Observable.range(100, 101);
    ReplaySubject<Observable<Integer>> subject = ReplaySubject.create();
    subject.onNext(os1);
    subject.onNext(os2);
    subject.onCompleted();

    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    int port = portSelector.acquirePort();

    RemoteRxServer server = new RemoteRxServer.Builder()
            .port(port)
            .addObservable(new ServeObservable.Builder<Integer>()
                    .encoder(Codecs.integer())
                    .observable(Observable.merge(subject))
                    .build())
            .build();

    // serve
    server.start();

    // connect
    Observable<Integer> oc = RemoteObservable.connect("localhost", port, Codecs.integer());
    // assert
    MathObservable.sumInteger(oc).toBlocking().forEach(new Action1<Integer>() {
        @Override
        public void call(Integer t1) {
            Assert.assertEquals(20200, t1.intValue()); // sum of number 0-200
        }
    });
}
 
Example #11
Source File: ComposableFutures.java    From ob1k with Apache License 2.0 5 votes vote down vote up
/**
 * translate a list of eager futures into a hot Observable stream
 * the results of the futures will be stored in the stream for any future subscriber.
 *
 * @param futures     the list of eager futures
 * @param failOnError whether to close the stream upon a future error
 * @param <T>         the stream type
 * @return the stream
 */
public static <T> Observable<T> toHotObservable(final List<ComposableFuture<T>> futures, final boolean failOnError) {
  final ReplaySubject<T> subject = ReplaySubject.create(futures.size());
  final AtomicInteger counter = new AtomicInteger(futures.size());
  final AtomicBoolean errorTrigger = new AtomicBoolean(false);

  for (final ComposableFuture<T> future : futures) {
    future.consume(provideObserverResult(subject, counter, errorTrigger, failOnError));
  }

  return subject;
}
 
Example #12
Source File: FixedConnectionSetTest.java    From mantis with Apache License 2.0 5 votes vote down vote up
@Test
public void testMergeInWithDeltaEndpointService() {
    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    final int server1Port = portSelector.acquirePort();
    final int server2Port = portSelector.acquirePort();

    // setup servers
    RemoteRxServer server1 = RemoteObservable.serve(server1Port, Observable.range(1, 50), Codecs.integer());
    RemoteRxServer server2 = RemoteObservable.serve(server2Port, Observable.range(51, 50), Codecs.integer());

    server1.start();
    server2.start();

    ReplaySubject<List<Endpoint>> subject = ReplaySubject.create();
    List<Endpoint> endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", server1Port));
    endpoints.add(new Endpoint("localhost", server2Port));
    subject.onNext(endpoints);

    FixedConnectionSet<Integer> cm
            = FixedConnectionSet.create(2, new ConnectToObservable.Builder<Integer>()
                    .decoder(Codecs.integer()),
            new ToDeltaEndpointInjector(subject));

    int sum = MathObservable.sumInteger(Observable.merge(cm.getObservables()))
            .toBlocking()
            .last();
    Assert.assertEquals(5050, sum);

}
 
Example #13
Source File: HttpMetaRequest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
private Observable<RibbonResponse<Observable<T>>> convertToRibbonResponse(
        final HystrixObservableCommandChain<T> commandChain, final Observable<ResultCommandPair<T>> hystrixNotificationObservable) {
    return Observable.create(new OnSubscribe<RibbonResponse<Observable<T>>>() {
        @Override
        public void call(
                final Subscriber<? super RibbonResponse<Observable<T>>> t1) {
            final Subject<T, T> subject = ReplaySubject.create();
            hystrixNotificationObservable.materialize().subscribe(new Action1<Notification<ResultCommandPair<T>>>() {
                AtomicBoolean first = new AtomicBoolean(true);

                @Override
                public void call(Notification<ResultCommandPair<T>> notification) {
                    if (first.compareAndSet(true, false)) {
                        HystrixObservableCommand<T> command = notification.isOnError() ? commandChain.getLastCommand() : notification.getValue().getCommand();
                        t1.onNext(new ResponseWithSubject<T>(subject, command));
                        t1.onCompleted();
                    }
                    if (notification.isOnNext()) {
                        subject.onNext(notification.getValue().getResult());
                    } else if (notification.isOnCompleted()) {
                        subject.onCompleted();
                    } else { // onError
                        subject.onError(notification.getThrowable());
                    }
                }
            });
        }
    });
}
 
Example #14
Source File: IngressPolicies.java    From mantis with Apache License 2.0 5 votes vote down vote up
public static IngressPolicy allowOnlyLocalhost() {
    ReplaySubject<Set<String>> subject = ReplaySubject.create();
    Set<String> list = new HashSet<String>();
    list.add("127.0.0.1");
    subject.onNext(list);
    return new InetAddressWhiteListIngressPolicy(subject);
}
 
Example #15
Source File: HystrixCommandChainTest.java    From ribbon with Apache License 2.0 4 votes vote down vote up
@Override
protected Observable<String> construct() {
    Subject<String, String> subject = ReplaySubject.create();
    fireEvents(subject);
    return subject;
}
 
Example #16
Source File: HttpRequest.java    From ribbon with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<T> observe() {
    ReplaySubject<T> subject = ReplaySubject.create();
    getObservable().subscribe(subject);
    return subject;
}
 
Example #17
Source File: StatRequest.java    From couchbase-jvm-core with Apache License 2.0 4 votes vote down vote up
public StatRequest(final String key, final String hostname, final String bucket) {
    super(key, bucket, null, null, ReplaySubject.<CouchbaseResponse>create());
    this.hostname = hostname;
}
 
Example #18
Source File: MergedObservable.java    From mantis with Apache License 2.0 4 votes vote down vote up
public static <T> MergedObservable<T> createWithReplay(int expectedTerminalCount) {
    return new MergedObservable<T>(expectedTerminalCount, ReplaySubject.<Observable<T>>create());
}
 
Example #19
Source File: ClientToServerChannelHandler.java    From datamill with ISC License 4 votes vote down vote up
@Override
public void channelRead(ChannelHandlerContext context, Object message) {
    if (message instanceof HttpRequest) {
        HttpRequest request = (HttpRequest) message;

        if (HttpUtil.is100ContinueExpected(request)) {
            sendContinueResponse(context);
        }

        bodyStream = ReplaySubject.create();
        serverRequest = ServerRequestBuilder.buildServerRequest(request, bodyStream);

        processRequest(context, request);

        if (request.decoderResult().isFailure()) {
            bodyStream.onError(request.decoderResult().cause());
        }
    }

    if (message instanceof HttpContent) {
        HttpContent httpContent = (HttpContent) message;

        ByteBuf content = httpContent.content();
        if (content.isReadable()) {
            bodyStream.onNext(content.nioBuffer());

            if (httpContent.decoderResult().isFailure()) {
                bodyStream.onError(httpContent.decoderResult().cause());
            }
        }

        if (message instanceof LastHttpContent) {
            LastHttpContent trailer = (LastHttpContent) message;
            if (!trailer.trailingHeaders().isEmpty()) {
                serverRequest.setTrailingHeaders(ServerRequestBuilder.buildHeadersMap(trailer.trailingHeaders()));
            }

            bodyStream.onCompleted();
        }
    }
}
 
Example #20
Source File: EventTracker.java    From light-eventuate-4j with Apache License 2.0 4 votes vote down vote up
public ReplaySubject<T> getEvents() {
  return events;
}
 
Example #21
Source File: OffersInteractorImpl.java    From fyber_mobile_offers with MIT License 4 votes vote down vote up
@Override
public Observable<OfferResponse> loadOffers(int page,
                                            String format,
                                            int applicationId,
                                            String userId,
                                            String locale,
                                            String osVersion,
                                            long timestamp,
                                            String googleAdId,
                                            boolean googleAdIdLimitedTrackingEnabled,
                                            String ip,
                                            String pub0,
                                            int offerTypes,
                                            String device,
                                            String apiKey) {
    if (offersSubscription == null || offersSubscription.isUnsubscribed()) {
        offersSubject = ReplaySubject.create();

        String hashKey = new HashGenerator()
                .addParam(FyberApi.PAGE, page)
                .addParam(FyberApi.FORMAT, Constants.FORMAT_JSON)
                .addParam(FyberApi.APP_ID, applicationId)
                .addParam(FyberApi.USER_ID, userId)
                .addParam(FyberApi.LOCALE, locale)
                .addParam(FyberApi.OS_VERSION, osVersion)
                .addParam(FyberApi.TIMESTAMP, timestamp)
                .addParam(FyberApi.GOOGLE_AD_ID, googleAdId)
                .addParam(FyberApi.GOOGLE_AD_ID_LIMITED_TRACKING_ENABLED, googleAdIdLimitedTrackingEnabled)
                .addParam(FyberApi.IP, ip)
                .addParam(FyberApi.PUB0, pub0)
                .addParam(FyberApi.OFFER_TYPES, Constants.OFFER_TYPES)
                .addParam(FyberApi.DEVICE, device)
                .generate(apiKey);

        offersSubscription = api.getOffers(
                format,
                applicationId,
                userId,
                locale,
                osVersion,
                timestamp,
                hashKey,
                googleAdId,
                googleAdIdLimitedTrackingEnabled,
                ip,
                pub0,
                page,
                offerTypes,
                device)
                .subscribeOn(scheduler.backgroundThread())
                .observeOn(scheduler.mainThread())
                .subscribe(offersSubject);
    }

    return offersSubject.asObservable();
}
 
Example #22
Source File: RxJava1Proxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static RxJava1SubjProxy serializedReplaySubjectProxy() {
    return new RxJava1SubjProxy(ReplaySubject.create().toSerialized());
}
 
Example #23
Source File: RxJava1Proxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static RxJava1SubjProxy replaySubjectProxy() {
    return new RxJava1SubjProxy(ReplaySubject.create());
}
 
Example #24
Source File: JobScenarioBuilder.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private TaskHolder() {
    this.taskEventStream = ReplaySubject.create();
    this.taskScenarioBuilder = new TaskScenarioBuilder(titusOperations, JobScenarioBuilder.this, taskEventStream,
            schedulingService, diagnosticReporter);
}
 
Example #25
Source File: RemoteObservableTest.java    From mantis with Apache License 2.0 4 votes vote down vote up
@Test
public void testServedMergedObservablesAddAfterConnect() {
    // setup
    Observable<Integer> os1 = Observable.range(0, 100);
    Observable<Integer> os2 = Observable.range(100, 100);
    ReplaySubject<Observable<Integer>> subject = ReplaySubject.create();
    subject.onNext(os1);
    subject.onNext(os2);
    // serve
    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    int serverPort = portSelector.acquirePort();

    RemoteRxServer server = new RemoteRxServer.Builder()
            .port(serverPort)
            .addObservable(new ServeObservable.Builder<Integer>()
                    .encoder(Codecs.integer())
                    .observable(Observable.merge(subject))
                    .build())
            .build();
    server.start();

    // add after serve
    Observable<Integer> os3 = Observable.range(200, 100);
    subject.onNext(os3);

    // connect
    Observable<Integer> oc = RemoteObservable.connect("localhost", serverPort, Codecs.integer());

    // add after connect
    Observable<Integer> os4 = Observable.range(300, 101);
    subject.onNext(os4);
    subject.onCompleted();

    // assert
    MathObservable.sumInteger(oc).toBlocking().forEach(new Action1<Integer>() {
        @Override
        public void call(Integer t1) {
            Assert.assertEquals(80200, t1.intValue()); // sum of number 0-200
        }
    });
}
 
Example #26
Source File: ToDeltaEndpointInjectorTest.java    From mantis with Apache License 2.0 4 votes vote down vote up
@Test
public void deltaTestWithIds() {

    ReplaySubject<List<Endpoint>> subject = ReplaySubject.create();
    ToDeltaEndpointInjector service = new ToDeltaEndpointInjector(subject);

    // 1. add endpoints
    List<Endpoint> endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234, "abc"));
    endpoints.add(new Endpoint("localhost", 2468, "xyz"));
    subject.onNext(endpoints);
    // 2. nothing changes
    endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234, "abc"));
    endpoints.add(new Endpoint("localhost", 2468, "xyz"));
    subject.onNext(endpoints);
    // 3. remove endpoint by leaving out second endpoint
    endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234, "abc"));
    subject.onNext(endpoints);
    // 4. remove all
    endpoints = new LinkedList<Endpoint>();
    subject.onNext(endpoints);
    // 5. add back
    endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234, "abc"));
    endpoints.add(new Endpoint("localhost", 2468, "xyz"));
    subject.onNext(endpoints);
    subject.onCompleted();

    BlockingObservable<EndpointChange> be = service.deltas().toBlocking();

    Iterator<EndpointChange> iter = be.getIterator();
    Assert.assertTrue(iter.hasNext());

    EndpointChange ce2 = iter.next();
    Assert.assertEquals(ce2.getEndpoint().getSlotId(), "xyz");
    Assert.assertEquals(ce2.getType(), EndpointChange.Type.add);

    EndpointChange ce1 = iter.next();
    Assert.assertEquals(ce1.getEndpoint().getSlotId(), "abc");
    Assert.assertEquals(ce1.getType(), EndpointChange.Type.add);


    EndpointChange ce3 = iter.next();
    Assert.assertEquals(ce3.getEndpoint().getSlotId(), "xyz");
    Assert.assertEquals(ce3.getType(), EndpointChange.Type.complete);


    EndpointChange ce4 = iter.next();
    Assert.assertEquals(ce4.getEndpoint().getSlotId(), "abc");
    Assert.assertEquals(ce4.getType(), EndpointChange.Type.complete);

    EndpointChange ce6 = iter.next();
    Assert.assertEquals(ce6.getEndpoint().getSlotId(), "xyz");
    Assert.assertEquals(ce6.getType(), EndpointChange.Type.add);

    EndpointChange ce5 = iter.next();
    Assert.assertEquals(ce5.getEndpoint().getSlotId(), "abc");
    Assert.assertEquals(ce5.getType(), EndpointChange.Type.add);

}
 
Example #27
Source File: ToDeltaEndpointInjectorTest.java    From mantis with Apache License 2.0 4 votes vote down vote up
@Test
public void deltaTest() {

    ReplaySubject<List<Endpoint>> subject = ReplaySubject.create();
    ToDeltaEndpointInjector service = new ToDeltaEndpointInjector(subject);

    // 1 add endpoints
    List<Endpoint> endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234));
    endpoints.add(new Endpoint("localhost", 2468));
    subject.onNext(endpoints);
    // 2 remove endpoint by leaving out second endpoint
    endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234));
    subject.onNext(endpoints);
    // 3 remove other
    endpoints = new LinkedList<Endpoint>();
    subject.onNext(endpoints);
    // 4 add back
    endpoints = new LinkedList<Endpoint>();
    endpoints.add(new Endpoint("localhost", 1234));
    endpoints.add(new Endpoint("localhost", 2468));
    subject.onNext(endpoints);
    subject.onCompleted();

    BlockingObservable<EndpointChange> be = service.deltas().toBlocking();

    // check for two adds
    Iterator<EndpointChange> iter = be.getIterator();
    Assert.assertTrue(iter.hasNext());
    EndpointChange ce1 = iter.next();
    Assert.assertEquals(ce1.getEndpoint().getSlotId(), "localhost:1234");
    Assert.assertEquals(ce1.getType(), EndpointChange.Type.add);
    EndpointChange ce2 = iter.next();
    Assert.assertEquals(ce2.getEndpoint().getSlotId(), "localhost:2468");
    Assert.assertEquals(ce2.getType(), EndpointChange.Type.add);

    // check for complete
    EndpointChange ce3 = iter.next();
    Assert.assertEquals(ce3.getEndpoint().getSlotId(), "localhost:2468");
    Assert.assertEquals(ce3.getType(), EndpointChange.Type.complete);

    // check for complete
    EndpointChange ce4 = iter.next();
    Assert.assertEquals(ce4.getEndpoint().getSlotId(), "localhost:1234");
    Assert.assertEquals(ce4.getType(), EndpointChange.Type.complete);

    // check for add
    EndpointChange ce5 = iter.next();
    Assert.assertEquals(ce5.getEndpoint().getSlotId(), "localhost:1234");
    Assert.assertEquals(ce5.getType(), EndpointChange.Type.add);
    EndpointChange ce6 = iter.next();
    Assert.assertEquals(ce6.getEndpoint().getSlotId(), "localhost:2468");
    Assert.assertEquals(ce6.getType(), EndpointChange.Type.add);
}