Search in sources :

Example 21 with Profiler

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);
        }
    }
}
Also used : Profiler(com.cloud.utils.Profiler) RemoteException(java.rmi.RemoteException)

Aggregations

Profiler (com.cloud.utils.Profiler)21 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 IOException (java.io.IOException)4 RemoteException (java.rmi.RemoteException)4 ArrayList (java.util.ArrayList)4 ManagedContextRunnable (com.cloud.managed.context.ManagedContextRunnable)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 ConnectException (java.net.ConnectException)2 SQLException (java.sql.SQLException)2 SQLNonTransientException (java.sql.SQLNonTransientException)2 SQLRecoverableException (java.sql.SQLRecoverableException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConfigurationException (javax.naming.ConfigurationException)2 ManagedContextRunnable (org.apache.cloudstack.managed.context.ManagedContextRunnable)2 HttpException (org.apache.commons.httpclient.HttpException)2 TreeSet (java.util.TreeSet)1