Search in sources :

Example 11 with TCPNIOPublisher

use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.

the class Basics method testConnectionCloseOnCompleteNIO.

@Test
public void testConnectionCloseOnCompleteNIO() throws InterruptedException {
    TCPNIOPublisher publisher = new TCPNIOPublisher().port(7854);
    TCPConnectable connectable = new TCPConnectable().host("localhost").port(7854);
    concloseTest(publisher, connectable);
    Thread.sleep(5000);
    System.out.println("break");
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) Test(org.junit.Test)

Example 12 with TCPNIOPublisher

use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.

the class RxJava method remotingTest.

@Test
public void remotingTest() {
    Observable<Integer> range = Observable.range(0, NUM_MSG / 4);
    Publisher<Integer> pub = RxReactiveStreams.toPublisher(range);
    KxReactiveStreams.get().asKxPublisher(pub).serve(new TCPNIOPublisher().port(3456));
    RateMeasure rm = new RateMeasure("events");
    AtomicInteger cnt = new AtomicInteger(0);
    Promise<Integer> finished = new Promise<>();
    KxReactiveStreams.get().connect(Integer.class, new TCPConnectable().host("localhost").port(3456)).subscribe((r, e) -> {
        rm.count();
        if (Actors.isResult(e))
            cnt.incrementAndGet();
        else
            finished.resolve(cnt.get());
    });
    Assert.assertTrue(finished.await(50000) == NUM_MSG / 4);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Promise(org.nustaq.kontraktor.Promise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) RateMeasure(org.nustaq.kontraktor.util.RateMeasure) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) Test(org.junit.Test)

Example 13 with TCPNIOPublisher

use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.

the class RxJava method remotingRxToRx.

@Test
public void remotingRxToRx() throws InterruptedException {
    Observable<Integer> range = Observable.range(0, NUM_MSG / 4);
    Publisher<Integer> pub = RxReactiveStreams.toPublisher(range);
    KxReactiveStreams.get().asKxPublisher(pub).serve(new TCPNIOPublisher().port(3458));
    RateMeasure rm = new RateMeasure("events");
    KxPublisher<Integer> remoteStream = KxReactiveStreams.get().connect(Integer.class, new TCPConnectable().host("localhost").port(3458));
    CountDownLatch cnt = new CountDownLatch(NUM_MSG / 4);
    RxReactiveStreams.toObservable(remoteStream).forEach(i -> {
        rm.count();
        cnt.countDown();
    });
    cnt.await(50, TimeUnit.SECONDS);
    Assert.assertTrue(cnt.getCount() == 0);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) RateMeasure(org.nustaq.kontraktor.util.RateMeasure) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 14 with TCPNIOPublisher

use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.

the class TableSpaceTest method startShardServer.

@Test
public void startShardServer() throws InterruptedException {
    startServer();
    TableSpaceActor ts = Actors.AsActor(TableSpaceActor.class);
    ts.init();
    new TCPNIOPublisher(ts, 5433).publish(actor -> System.out.println("sidconnected: " + actor));
    Thread.sleep(1000000);
}
Also used : TableSpaceActor(org.nustaq.reallive.impl.tablespace.TableSpaceActor) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) Test(org.junit.Test)

Example 15 with TCPNIOPublisher

use of org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher in project kontraktor by RuedigerMoeller.

the class TableSpaceTest method startServer.

public TableSpaceActor startServer() {
    TableSpaceActor ts = Actors.AsActor(TableSpaceActor.class);
    ts.init();
    new TCPNIOPublisher(ts, 5432).publish(actor -> System.out.println("sidconnected: " + actor));
    return ts;
}
Also used : TableSpaceActor(org.nustaq.reallive.impl.tablespace.TableSpaceActor) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)

Aggregations

TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)17 Test (org.junit.Test)8 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)8 Actors (org.nustaq.kontraktor.Actors)4 Promise (org.nustaq.kontraktor.Promise)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Actor (org.nustaq.kontraktor.Actor)3 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)3 RateMeasure (org.nustaq.kontraktor.util.RateMeasure)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Ignore (org.junit.Ignore)2 IPromise (org.nustaq.kontraktor.IPromise)2 KxPublisher (org.nustaq.kontraktor.reactivestreams.KxPublisher)2 KxReactiveStreams (org.nustaq.kontraktor.reactivestreams.KxReactiveStreams)2 HttpPublisher (org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)2 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)2 TableSpaceActor (org.nustaq.reallive.impl.tablespace.TableSpaceActor)2 JCommander (com.beust.jcommander.JCommander)1 MyEvent (examples.MyEvent)1