Search in sources :

Example 6 with FastCast

use of org.nustaq.fastcast.api.FastCast in project fast-cast by RuedigerMoeller.

the class FCPing method initFC.

protected FastCast initFC(String nodeId, String config) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    FSTStructFactory.getInstance().registerClz(PingRequest.class);
    try {
        FastCast fc = FastCast.getFastCast();
        fc.setNodeId(nodeId);
        fc.loadConfig("./src/main/java/org/nustaq/fastcast/examples/latency/" + config);
        // fc.loadConfig("C:\\work\\GitHub\\fast-cast\\src\\test\\java\\bench\\"+config);
        return fc;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : FastCast(org.nustaq.fastcast.api.FastCast)

Example 7 with FastCast

use of org.nustaq.fastcast.api.FastCast in project fast-cast by RuedigerMoeller.

the class FCPing method runPongServer.

public void runPongServer() throws InterruptedException {
    FastCast fc = initFC("pserv", "pingponglat.kson");
    final FCPublisher echoresp = fc.onTransport(PING_BACK_ON_SAME_TOPIC ? "ping" : "pong").publish(fc.getPublisherConf("pongtopic"));
    fc.onTransport("ping").subscribe(fc.getSubscriberConf("pingtopic"), new FCSubscriber() {

        @Override
        public void messageReceived(String sender, long sequence, Bytez b, long off, int len) {
            // System.out.println("snd:"+sender);
            while (!echoresp.offer(sender, b, off, len, true)) {
                // ensure retrans processing etc.
                echoresp.flush();
            }
        }

        @Override
        public boolean dropped() {
            return true;
        }

        @Override
        public void senderTerminated(String senderNodeId) {
            System.out.println(senderNodeId + " terminated");
        }

        @Override
        public void senderBootstrapped(String receivesFrom, long seqNo) {
            System.out.println("bootstrap " + receivesFrom);
        }
    });
    while (true) {
        Thread.sleep(100000);
    }
}
Also used : FastCast(org.nustaq.fastcast.api.FastCast) FCPublisher(org.nustaq.fastcast.api.FCPublisher) Bytez(org.nustaq.offheap.bytez.Bytez) FCSubscriber(org.nustaq.fastcast.api.FCSubscriber)

Example 8 with FastCast

use of org.nustaq.fastcast.api.FastCast in project fast-cast by RuedigerMoeller.

the class Issue4 method setupFC.

public FastCast setupFC(String nodeId, String config) {
    System.setProperty("java.net.preferIPv4Stack", "true");
    try {
        // FastCast.getFastCast();
        FastCast fc = new FastCast();
        fc.setNodeId(nodeId);
        fc.loadConfig("./src/test/java/basic/" + config);
        return fc;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : FastCast(org.nustaq.fastcast.api.FastCast)

Example 9 with FastCast

use of org.nustaq.fastcast.api.FastCast in project fast-cast by RuedigerMoeller.

the class StructPublisher method configureFastCast.

public static void configureFastCast() {
    // note this configuration is far below possible limits regarding throughput and rate
    FastCast fc = FastCast.getFastCast();
    fc.addTransport(new PhysicalTransportConf("default").interfaceAdr(// define the interface
    "127.0.0.1").port(// port is more important than address as some OS only test for ports ('crosstalking')
    42043).mulitcastAdr(// ip4 multicast address
    "229.9.9.9").setDgramsize(// datagram size. Small sizes => lower latency, large sizes => better throughput [range 1200 to 64_000 bytes]
    64_000).socketReceiveBufferSize(// as large as possible .. however avoid hitting system limits in example
    4_000_000).socketSendBufferSize(2_000_000));
}
Also used : PhysicalTransportConf(org.nustaq.fastcast.config.PhysicalTransportConf) FastCast(org.nustaq.fastcast.api.FastCast)

Example 10 with FastCast

use of org.nustaq.fastcast.api.FastCast in project fast-cast by RuedigerMoeller.

the class TestEchoServer method main.

public static void main(String[] arg) throws InterruptedException {
    FastCast fc = SendReceive.initFC("echo", "sendreceive.kson");
    echoServer(fc);
}
Also used : FastCast(org.nustaq.fastcast.api.FastCast)

Aggregations

FastCast (org.nustaq.fastcast.api.FastCast)12 FCPublisher (org.nustaq.fastcast.api.FCPublisher)4 FCSubscriber (org.nustaq.fastcast.api.FCSubscriber)3 PhysicalTransportConf (org.nustaq.fastcast.config.PhysicalTransportConf)3 Bytez (org.nustaq.offheap.bytez.Bytez)3 Executor (java.util.concurrent.Executor)2 Histogram (org.HdrHistogram.Histogram)2 Sleeper (org.nustaq.fastcast.util.Sleeper)2 FSTStructAllocator (org.nustaq.offheap.structs.FSTStructAllocator)2 File (java.io.File)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ObjectPublisher (org.nustaq.fastcast.api.util.ObjectPublisher)1 RateMeasure (org.nustaq.fastcast.util.RateMeasure)1