if(ndx != -1) {
String portString = heartbeatServer.substring(ndx + 1);
heartbeatServer = heartbeatServer.substring(0, ndx);
port = Integer.parseInt(portString);
} else {
throw new ConfigurationException("heartbeatServer wrong format, no port");
}
long heartbeatPeriod = Config.getLongEntry(config,
COMPONENT,
HEARTBEAT_PERIOD_KEY,
DEFAULT_HEARTBEAT_PERIOD,
0,
Long.MAX_VALUE);
if(logger.isTraceEnabled()) {
StringBuilder buffer = new StringBuilder();
buffer.append("HeartbeatClient Properties : ");
buffer.append("heartbeatPeriod=").append(heartbeatPeriod).append(", ");
buffer.append("heartbeatServer=").append(heartbeatServer).append(", ");
buffer.append("port=").append(port);
logger.trace(buffer.toString());
}
try {
InetAddress address = InetAddress.getByName(heartbeatServer);
taskTimer.scheduleAtFixedRate(new HeartbeatTask(address, port),
1000,
heartbeatPeriod);
} catch(UnknownHostException e) {
throw new ConfigurationException("heartbeatServer "+
"["+heartbeatServer+"] Unknown host",
e);
}
}