Search in sources :

Example 6 with TCPConnectable

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

the class ServiceActor method RunTCP.

/**
 * run & connect a service with given cmdline args and classes
 *
 * @param args
 * @param serviceClazz
 * @param argsClazz
 * @return
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public static ServiceActor RunTCP(String[] args, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz) {
    ServiceActor myService = AsActor(serviceClazz);
    ServiceArgs options = null;
    try {
        options = ServiceRegistry.parseCommandLine(args, argsClazz.newInstance());
    } catch (Exception e) {
        FSTUtil.rethrow(e);
    }
    TCPConnectable connectable = new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort());
    myService.init(connectable, options, true).await(30_000);
    Log.Info(myService.getClass(), "Init finished");
    return myService;
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable)

Example 7 with TCPConnectable

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

the class DataShard method main.

public static void main(String[] args) {
    DataShard ds = Actors.AsActor(DataShard.class, 256000);
    DataShardArgs options = (DataShardArgs) ServiceRegistry.parseCommandLine(args, new DataShardArgs());
    // .await(); fail ..
    ds.init(new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort()), options, true);
    Log.Info(ds.getClass(), "Init finished");
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) ServiceRegistry(org.nustaq.kontraktor.services.ServiceRegistry)

Example 8 with TCPConnectable

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

the class RxJava method remotingToJ8Streams.

@Test
public void remotingToJ8Streams() {
    Observable<Integer> range = Observable.range(0, NUM_MSG / 4);
    Publisher<Integer> pub = RxReactiveStreams.toPublisher(range);
    KxReactiveStreams.get().asKxPublisher(pub).serve(new TCPNIOPublisher().port(3457));
    RateMeasure rm = new RateMeasure("events");
    Promise<Integer> finished = new Promise<>();
    KxReactiveStreams.get().connect(Integer.class, new TCPConnectable().host("localhost").port(3457)).stream(stream -> {
        long count = stream.map(i -> {
            rm.count();
            return i;
        }).count();
        finished.resolve((int) count);
    });
    Assert.assertTrue(finished.await(50000) == NUM_MSG / 4);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) Publisher(org.reactivestreams.Publisher) Test(org.junit.Test) Promise(org.nustaq.kontraktor.Promise) KxPublisher(org.nustaq.kontraktor.reactivestreams.KxPublisher) KxReactiveStreams(org.nustaq.kontraktor.reactivestreams.KxReactiveStreams) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) RateMeasure(org.nustaq.kontraktor.util.RateMeasure) Observable(rx.Observable) TimeUnit(java.util.concurrent.TimeUnit) MyEvent(examples.MyEvent) CountDownLatch(java.util.concurrent.CountDownLatch) RxReactiveStreams(rx.RxReactiveStreams) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Actors(org.nustaq.kontraktor.Actors) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) Assert(org.junit.Assert) Promise(org.nustaq.kontraktor.Promise) 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 9 with TCPConnectable

use of org.nustaq.kontraktor.remoting.tcp.TCPConnectable 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 10 with TCPConnectable

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

the class TableSpaceTest method simpleRemoteNoServer.

@Test
public void simpleRemoteNoServer() {
    TableSpaceActor remoteTS = (TableSpaceActor) new TCPConnectable(TableSpaceActor.class, "localhost", 5432).connect((disc, err) -> System.out.println("client disc " + disc + " " + err)).await();
    Assert.assertTrue(runSimpleTest(remoteTS, () -> createTableDescription()) == EXPECT_SIMPLECOUNT);
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) TableSpaceActor(org.nustaq.reallive.impl.tablespace.TableSpaceActor) Test(org.junit.Test)

Aggregations

TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)25 Test (org.junit.Test)9 TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Actors (org.nustaq.kontraktor.Actors)5 Promise (org.nustaq.kontraktor.Promise)4 TCPPublisher (org.nustaq.kontraktor.remoting.tcp.TCPPublisher)4 RateMeasure (org.nustaq.kontraktor.util.RateMeasure)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)3 JCommander (com.beust.jcommander.JCommander)2 UnknownHostException (java.net.UnknownHostException)2 Date (java.util.Date)2 TimeUnit (java.util.concurrent.TimeUnit)2 Actor (org.nustaq.kontraktor.Actor)2 IPromise (org.nustaq.kontraktor.IPromise)2 KxPublisher (org.nustaq.kontraktor.reactivestreams.KxPublisher)2 KxReactiveStreams (org.nustaq.kontraktor.reactivestreams.KxReactiveStreams)2 HttpConnectable (org.nustaq.kontraktor.remoting.http.HttpConnectable)2 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)2