use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class WebSocketPublisher method publish.
@Override
public IPromise<ActorServer> publish(Consumer<Actor> disconnectCallback) {
Promise finished = new Promise();
try {
ActorServer publisher = new ActorServer(new UndertowWebsocketServerConnector(urlPath, port, hostName).sendStrings(sendStringMessages).sendSid(sendSid), facade, coding);
facade.execute(() -> {
try {
publisher.start(disconnectCallback);
finished.resolve(publisher);
} catch (Exception e) {
finished.reject(e);
}
});
} catch (Exception e) {
e.printStackTrace();
return new Promise(null, e);
}
return finished;
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method testBlockingMany.
@Test
public void testBlockingMany() throws Exception {
checkSequenceErrors = false;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = TCPServerConnector.Publish(service, 8081, null).await();
ExecutorService exec = Executors.newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
exec.execute(() -> {
try {
runnitTCP(latch, null);
} catch (Exception e) {
e.printStackTrace();
}
});
}
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method testWSJSR.
// fixme: add connect-from-actor tests
// fixme: add minbin tests
// fixme: increase basic test coverage
@Test
@Ignore
public void testWSJSR() throws Exception {
checkSequenceErrors = true;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = _JSR356ServerConnector.Publish(service, "ws://localhost:8081/ws", null).await();
RemotingTestService client = (RemotingTestService) new WebSocketConnectable(RemotingTestService.class, "ws://localhost:8081/ws").connect().await(9999999);
CountDownLatch latch = new CountDownLatch(1);
runWithClient(client, latch);
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method testNIOMany.
@Test
public void testNIOMany() throws Exception {
checkSequenceErrors = false;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
ActorServer publisher = NIOServerConnector.Publish(service, 8081, null).await();
ExecutorService exec = Executors.newCachedThreadPool();
CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
exec.execute(() -> {
try {
runnitTCP(latch, null);
} catch (Exception e) {
e.printStackTrace();
}
});
}
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
use of org.nustaq.kontraktor.remoting.base.ActorServer in project kontraktor by RuedigerMoeller.
the class RemotingTest method testBlocking.
@Test
public void testBlocking() throws Exception {
checkSequenceErrors = true;
RemotingTestService service = Actors.AsActor(RemotingTestService.class, Q_SIZE);
Coding coding = new Coding(SerializerType.FSTSer);
ActorServer publisher = TCPServerConnector.Publish(service, 8081, coding).await();
CountDownLatch latch = new CountDownLatch(1);
runnitTCP(latch, coding);
latch.await();
// wait for outstanding callbacks
Thread.sleep(2000);
publisher.close();
}
Aggregations