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