summaryrefslogtreecommitdiffstats
path: root/jrt_test/src/java/PollRPCServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'jrt_test/src/java/PollRPCServer.java')
-rw-r--r--jrt_test/src/java/PollRPCServer.java35
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");
+ }
+}