Search in sources :

Example 66 with Promise

use of org.nustaq.kontraktor.Promise in project kontraktor by RuedigerMoeller.

the class RemotingTest method fromRemote.

private void fromRemote(ConnectableActor con) {
    RemotingTA remote = (RemotingTA) con.connect().await();
    IPromise fin = new Promise();
    AtomicInteger count = new AtomicInteger();
    Integer expect = remote.sayHello(10, (str, err) -> {
        if (Actors.isCont(err)) {
            System.out.println("received:" + str);
            count.incrementAndGet();
        } else {
            fin.complete();
        }
    }).await();
    fin.await();
    Assert.assertTrue(expect.intValue() == count.intValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) SerializerType(org.nustaq.kontraktor.remoting.encoding.SerializerType) TCPPublisher(org.nustaq.kontraktor.remoting.tcp.TCPPublisher) Test(org.junit.Test) Promise(org.nustaq.kontraktor.Promise) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) IPromise(org.nustaq.kontraktor.IPromise) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) ConnectableActor(org.nustaq.kontraktor.remoting.base.ConnectableActor) Http4K(org.nustaq.kontraktor.remoting.http.undertow.Http4K) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Actors(org.nustaq.kontraktor.Actors) HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) Assert(org.junit.Assert) Promise(org.nustaq.kontraktor.Promise) IPromise(org.nustaq.kontraktor.IPromise) IPromise(org.nustaq.kontraktor.IPromise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 67 with Promise

use of org.nustaq.kontraktor.Promise in project kontraktor by RuedigerMoeller.

the class _JSR356ServerConnector method Publish.

public static IPromise<ActorServer> Publish(Actor facade, String path, Coding coding) {
    _JSR356ServerConnector connector = new _JSR356ServerConnector();
    try {
        ActorServer actorServer = new ActorServer(connector, facade, coding);
        actorServer.start();
        ContainerProvider.getWebSocketContainer().connectToServer(connector, /*new DefaultClientEndpointConfig(),*/
        new URI(path));
        return new Promise<>(actorServer);
    } catch (Exception e) {
        e.printStackTrace();
        return new Promise<>(null, e);
    }
}
Also used : Promise(org.nustaq.kontraktor.Promise) IPromise(org.nustaq.kontraktor.IPromise) ActorServer(org.nustaq.kontraktor.remoting.base.ActorServer) URI(java.net.URI) IOException(java.io.IOException)

Aggregations

Promise (org.nustaq.kontraktor.Promise)67 IPromise (org.nustaq.kontraktor.IPromise)62 Test (org.junit.Test)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 Actor (org.nustaq.kontraktor.Actor)6 Remoted (org.nustaq.kontraktor.annotations.Remoted)6 IOException (java.io.IOException)4 Actors (org.nustaq.kontraktor.Actors)4 RateMeasure (org.nustaq.kontraktor.util.RateMeasure)4 JsonObject (com.eclipsesource.json.JsonObject)3 ByteBuffer (java.nio.ByteBuffer)3 KeyManagementException (java.security.KeyManagementException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 CertificateException (java.security.cert.CertificateException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Consumer (java.util.function.Consumer)3 ActorServer (org.nustaq.kontraktor.remoting.base.ActorServer)3 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)3 TableSpaceActor (org.nustaq.reallive.impl.tablespace.TableSpaceActor)3 EOFException (java.io.EOFException)2