blob: bf47762e13923c534bc924a61f5f8306a7fd3a4a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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");
}
}
|