diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jrt_test/src/java/PollRPCServer.java |
Publish
Diffstat (limited to 'jrt_test/src/java/PollRPCServer.java')
-rw-r--r-- | jrt_test/src/java/PollRPCServer.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jrt_test/src/java/PollRPCServer.java b/jrt_test/src/java/PollRPCServer.java new file mode 100644 index 00000000000..bf47762e139 --- /dev/null +++ b/jrt_test/src/java/PollRPCServer.java @@ -0,0 +1,35 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +import com.yahoo.jrt.*; + +public class PollRPCServer { + + public static void main(String[] args) { + if (args.length != 1) { + System.err.println("usage: PollRPCServer <spec>"); + System.exit(1); + } + Transport transport = new Transport(); + Supervisor orb = new Supervisor(transport); + Target target = orb.connect(new Spec(args[0])); + Request req = new Request("frt.rpc.ping"); + int retry = 0; + System.out.print("polling '" + args[0] + "' "); + while (true) { + target.invokeSync(req, 60.0); + System.out.print("."); + if (req.errorCode() != ErrorCode.CONNECTION + || ++retry == 500) { + break; + } + try { Thread.sleep(250); } catch (Exception e) {} + target = orb.connect(new Spec(args[0])); + req = new Request("frt.rpc.ping"); + } + if (req.isError()) { + System.out.println(" fail"); + System.exit(1); + } + System.out.println(" ok"); + } +} |