use of com.cloud.utils.Profiler in project cloudstack by apache.
the class ClusterManagerImpl method onSendingClusterPdu.
private void onSendingClusterPdu() {
while (true) {
try {
final ClusterServicePdu pdu = popOutgoingClusterPdu(1000);
if (pdu == null) {
continue;
}
ClusterService peerService = null;
for (int i = 0; i < 2; i++) {
try {
peerService = getPeerService(pdu.getDestPeer());
} catch (final RemoteException e) {
s_logger.error("Unable to get cluster service on peer : " + pdu.getDestPeer());
}
if (peerService != null) {
try {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId() + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
}
final Profiler profiler = new Profiler();
profiler.start();
final String strResult = peerService.execute(pdu);
profiler.stop();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " + profiler.getDurationInMillis() + "ms. agent: " + pdu.getAgentId() + ", pdu seq: " + pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage());
}
if ("true".equals(strResult)) {
break;
}
} catch (final RemoteException e) {
invalidatePeerService(pdu.getDestPeer());
if (s_logger.isInfoEnabled()) {
s_logger.info("Exception on remote execution, peer: " + pdu.getDestPeer() + ", iteration: " + i + ", exception message :" + e.getMessage());
}
}
}
}
} catch (final Throwable e) {
s_logger.error("Unexcpeted exception: ", e);
}
}
}
Aggregations