} catch (IOException e1) {
e1.printStackTrace();
return;
}
AServicePing custom = resolve(pingClass, arguments, endpoint);
if ( custom == null ) {
print("bad_pinger:", pingClass, endpoint);
return;
}
while ( true ) {
if ( debug ) print("ServicePingMeta starts ping.");
byte[] cmd = new byte[1];
cmd[0] = 0;
int eof = 0;
try {
eof = sock_in.read(cmd);
} catch (IOException e) {
handleError(e);
}
if ( debug ) print("Read cmd", new String(cmd), "eof", eof);
if ( eof == -1 ) {
print("EOF on input pipe. Exiting");
custom.stop();
return;
}
try {
if ( cmd[0] == 'P' ) {
IServiceStatistics ss = custom.getStatistics();
if ( ss == null ) {
ss = default_statistics;
}
// print("Is alive: " + ss.isAlive());
oos.writeObject(ss);
oos.flush();
// The ObjectOutputStream will cache instances and if all you do is change a
// field or two in the object, it won't be detected and the stale object will be
// sent. So you have to reset() the stream, (or use a new object, or use
// clone() here also if you want, but this is simplest and safest since we have
// no control over what the external pinger gives us.
oos.reset();
} else if ( cmd[0] == 'Q' ) {
custom.stop();
return;
} else {
System.err.println("Invalid command recieved: " + Byte.toString(cmd[0]));
}
} catch (Throwable e) {