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;
}
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");
}
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);
}
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");
}
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);
}
Aggregations