Search in sources :

Example 21 with TCPConnectable

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

the class Pong method main.

public static void main(String[] args) {
    Pong pong = AsActor(Pong.class);
    new TCPNIOPublisher().port(9080).serType(SerializerType.FSTSer).facade(pong).publish(x -> Log.Info(Pong.class, "disconnected " + x));
    // we need to initiate ping pong. Assumes Ping is already running
    Ping ping = (Ping) new TCPConnectable().host("localhost").port(9080).actorClass(Ping.class).serType(SerializerType.FSTSer).connect().await();
    ping.receivePong(pong);
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)

Example 22 with TCPConnectable

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

the class ServiceClient method run.

public void run() {
    MyServiceInterface service = (MyServiceInterface) new TCPConnectable().actorClass(MyServiceInterface.class).host("localhost").port(6789).connect((connector, error) -> {
        System.out.println("Disconnected from service .. exiting");
        System.exit(0);
    }).await();
    service.addPerson(new Person("Hickory", "Heinz", 13, Sex.MALE));
    service.addPerson(new Person("Blob", "Jim", 13, Sex.MALE));
    service.addPerson(new Person("Gerstenbroich-Huckerbühl", "Mareike", 17, Sex.MALE));
    service.listPersons(null, null, 13, (p, err) -> {
        if (!Actor.isErrorOrComplete(err))
            System.out.println("found: " + p);
        else {
            System.out.println("query finished");
            System.exit(0);
        }
    });
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) MyServiceInterface(service.common.MyServiceInterface)

Example 23 with TCPConnectable

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

the class PlainService method initPlainService.

public IPromise<PlainService> initPlainService(String name, String[] requiredServices, ServiceArgs options) {
    if (requiredServices == null) {
        this.requiredServices = new String[0];
    } else {
        this.requiredServices = requiredServices;
    }
    this.serviceName = name;
    Promise p = new Promise();
    self().init(new TCPConnectable(ServiceRegistry.class, options.getRegistryHost(), options.getRegistryPort()), options, true).then((r, e) -> {
        if (e == null) {
            p.resolve(self());
        } else {
            p.reject(e);
        }
    });
    return p;
}
Also used : IPromise(org.nustaq.kontraktor.IPromise) Promise(org.nustaq.kontraktor.Promise) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable)

Example 24 with TCPConnectable

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

the class RemotingTest method runnitTCP.

public void runnitTCP(CountDownLatch l, Coding coding) throws Exception {
    RemotingTestService client = (RemotingTestService) new TCPConnectable().actorClass(RemotingTestService.class).host("localhost").port(8081).coding(coding).connect().await();
    runWithClient(client, l);
    // wait for outstanding callbacks
    Thread.sleep(2000);
    client.close();
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable)

Example 25 with TCPConnectable

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

the class RemotingTest method test.

@Test
public void test() {
    RemotingTA serv = Actors.AsActor(RemotingTA.class);
    // websocket
    WebSocketPublisher pub = new WebSocketPublisher().facade(serv).hostName("0.0.0.0").urlPath("/websocket").port(7777).serType(SerializerType.FSTSer);
    pub.publish().await();
    WebSocketConnectable con = new WebSocketConnectable().actorClass(RemotingTA.class).url("ws://localhost:7777/websocket");
    fromRemote(con);
    // TCP NIO
    new TCPNIOPublisher(serv, 7778).publish().await();
    fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7778));
    // TCP Sync
    new TCPPublisher(serv, 7780).publish().await();
    fromRemote(new TCPConnectable(RemotingTA.class, "localhost", 7780));
    // Http-Longpoll
    new HttpPublisher(serv, "0.0.0.0", "/httpapi", 7779).publish().await();
    fromRemote(new HttpConnectable(RemotingTA.class, "http://localhost:7779/httpapi"));
}
Also used : HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) TCPPublisher(org.nustaq.kontraktor.remoting.tcp.TCPPublisher) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) 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