Search in sources :

Example 1 with TCPNIOPublisher

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

the class ProcessStarter method main.

public static void main(String[] args) throws InterruptedException, IOException {
    BackOffStrategy.SLEEP_NANOS = 10 * 1000 * 1000;
    final ProcessStarterArgs options = new ProcessStarterArgs();
    final JCommander jCommander = new JCommander(options);
    jCommander.parse(args);
    if (options.isHelp()) {
        jCommander.usage();
        System.exit(0);
    }
    options.underride(locateProps(0, new File("./"), "troll.properties"));
    ProcessStarter ps = Actors.AsActor(ProcessStarter.class);
    ps.init(options);
    new TCPNIOPublisher().port(options.getPort()).facade(ps).publish(act -> {
        System.out.println("Discon " + act);
    }).then((r, e) -> {
        if (e == null) {
            System.out.println("started demon on all nics port " + options.getPort() + " sibling expected on " + options.getSiblingHost() + ":" + options.getSiblingPort());
        } else {
            System.out.println("error connecting " + e);
        }
    });
// testing
// ProcessStarter remote = (ProcessStarter) new TCPConnectable(ProcessStarter.class,options.getHost(),options.getPort()).connect( (x,y) -> System.out.println("client disc "+x)).await();
// ProcessInfo bash = remote.startProcess("/tmp", Collections.emptyMap(), "bash", "-c", "xclock -digital").await();
// 
// List<ProcessInfo> procs = remote.getProcesses().await();
// procs.forEach( proc -> System.out.println(proc));
// 
// Thread.sleep(3000);
// 
// 
// Object await = remote.terminateProcess(bash.getId(), true, 15).await();
// System.out.println("term result "+await);
// http://stackoverflow.com/questions/5740390/printing-my-macs-serial-number-in-java-using-unix-commands/5740673#5740673
// http://stackoverflow.com/questions/1980671/executing-untokenized-command-line-from-java/1980921#1980921
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) java.util(java.util) BackOffStrategy(org.nustaq.kontraktor.impl.BackOffStrategy) JCommander(com.beust.jcommander.JCommander) Promise(org.nustaq.kontraktor.Promise) Field(java.lang.reflect.Field) UnknownHostException(java.net.UnknownHostException) Collectors(java.util.stream.Collectors) InetAddress(java.net.InetAddress) TimeUnit(java.util.concurrent.TimeUnit) IPromise(org.nustaq.kontraktor.IPromise) java.io(java.io) ConnectableActor(org.nustaq.kontraktor.remoting.base.ConnectableActor) Actor(org.nustaq.kontraktor.Actor) Log(org.nustaq.kontraktor.util.Log) Actors(org.nustaq.kontraktor.Actors) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) JCommander(com.beust.jcommander.JCommander) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)

Example 2 with TCPNIOPublisher

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

the class MyServiceServerImpl method main.

public static void main(String[] a) {
    // give large queue to service
    MyServiceInterface myService = Actors.AsActor(MyServiceServerImpl.class, 128_000);
    new TCPNIOPublisher().facade(myService).port(6789).serType(SerializerType.FSTSer).publish().await();
    System.out.println("server started on " + 6789);
}
Also used : TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) MyServiceInterface(service.common.MyServiceInterface)

Example 3 with TCPNIOPublisher

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

the class ReconnectTest method test.

@Test
@Ignore
public void test() throws InterruptedException {
    ServiceA serviceA = Actors.AsActor(ServiceA.class);
    new TCPNIOPublisher(serviceA, 5678).publish(actor -> System.out.println("server side discon " + actor));
    ClientA cl = Actors.AsActor(ClientA.class);
    cl.init(5678);
    Thread.sleep(Integer.MAX_VALUE);
}
Also used : TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with TCPNIOPublisher

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

the class ReconnectTest method runService.

@Test
@Ignore
public void runService() throws InterruptedException {
    ServiceA serviceA = Actors.AsActor(ServiceA.class);
    new TCPNIOPublisher(serviceA, 5678).publish(actor -> System.out.println("server side discon " + actor));
    Thread.sleep(Integer.MAX_VALUE);
}
Also used : TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with TCPNIOPublisher

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

the class RemotingPlayground method main.

public static void main(String[] args) {
    AServ server = Actors.AsActor(AServ.class);
    TCPNIOPublisher publisher = new TCPNIOPublisher(server, 5678);
    publisher.publish(actor -> System.out.println("actor " + actor + " disconnected")).await();
    AServ client = (AServ) new TCPConnectable(AServ.class, "localhost", 5678).connect().await();
    client.pingme();
}
Also used : TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) Actor(org.nustaq.kontraktor.Actor) Actors(org.nustaq.kontraktor.Actors) TCPClientConnector(org.nustaq.kontraktor.remoting.tcp.TCPClientConnector) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)

Aggregations

TCPNIOPublisher (org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher)17 Test (org.junit.Test)8 TCPConnectable (org.nustaq.kontraktor.remoting.tcp.TCPConnectable)8 Actors (org.nustaq.kontraktor.Actors)4 Promise (org.nustaq.kontraktor.Promise)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Actor (org.nustaq.kontraktor.Actor)3 WebSocketPublisher (org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher)3 RateMeasure (org.nustaq.kontraktor.util.RateMeasure)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Ignore (org.junit.Ignore)2 IPromise (org.nustaq.kontraktor.IPromise)2 KxPublisher (org.nustaq.kontraktor.reactivestreams.KxPublisher)2 KxReactiveStreams (org.nustaq.kontraktor.reactivestreams.KxReactiveStreams)2 HttpPublisher (org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher)2 WebSocketConnectable (org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable)2 TableSpaceActor (org.nustaq.reallive.impl.tablespace.TableSpaceActor)2 JCommander (com.beust.jcommander.JCommander)1 MyEvent (examples.MyEvent)1