http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
 
b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 440cfc3..2bc4f68 100644
--- 
a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ 
b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -43,6 +43,10 @@ import javax.naming.ConfigurationException;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -91,10 +95,10 @@ import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.nio.Link;
 import com.cloud.utils.nio.Task;
-import com.google.gson.Gson;
 
 @Local(value = {AgentManager.class, ClusteredAgentRebalanceService.class})
 public class ClusteredAgentManagerImpl extends AgentManagerImpl implements 
ClusterManagerListener, ClusteredAgentRebalanceService {
+    final static Logger s_logger = 
Logger.getLogger(ClusteredAgentManagerImpl.class);
     private static final ScheduledExecutorService s_transferExecutor = 
Executors.newScheduledThreadPool(2, new 
NamedThreadFactory("Cluster-AgentRebalancingExecutor"));
     private final long rebalanceTimeOut = 300000; // 5 mins - after this time 
remove the agent from the transfer list
 
@@ -140,7 +144,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         _sslEngines = new HashMap<String, SSLEngine>(7);
         _nodeId = ManagementServerNode.getManagementServerId();
 
-        logger.info("Configuring ClusterAgentManagerImpl. management server 
node id(msid): " + _nodeId);
+        s_logger.info("Configuring ClusterAgentManagerImpl. management server 
node id(msid): " + _nodeId);
 
         ClusteredAgentAttache.initialize(this);
 
@@ -158,8 +162,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             return false;
         }
         _timer.schedule(new DirectAgentScanTimerTask(), STARTUP_DELAY, 
ScanInterval.value());
-        if (logger.isDebugEnabled()) {
-            logger.debug("Scheduled direct agent scan task to run at an 
interval of " + ScanInterval.value() + " seconds");
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Scheduled direct agent scan task to run at an 
interval of " + ScanInterval.value() + " seconds");
         }
 
         // Schedule tasks for agent rebalancing
@@ -173,8 +177,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
     public void scheduleHostScanTask() {
         _timer.schedule(new DirectAgentScanTimerTask(), 0);
-        if (logger.isDebugEnabled()) {
-            logger.debug("Scheduled a direct agent scan task");
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Scheduled a direct agent scan task");
         }
     }
 
@@ -183,8 +187,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     }
 
     private void scanDirectAgentToLoad() {
-        if (logger.isTraceEnabled()) {
-            logger.trace("Begin scanning directly connected hosts");
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("Begin scanning directly connected hosts");
         }
 
         // for agents that are self-managed, threshold to be considered as 
disconnected after pingtimeout
@@ -192,18 +196,18 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         List<HostVO> hosts = 
_hostDao.findAndUpdateDirectAgentToLoad(cutSeconds, 
LoadSize.value().longValue(), _nodeId);
         List<HostVO> appliances = 
_hostDao.findAndUpdateApplianceToLoad(cutSeconds, _nodeId);
 
-        if (hosts != null) {
+       if (hosts != null) {
             hosts.addAll(appliances);
             if (hosts.size() > 0) {
-                logger.debug("Found " + hosts.size() + " unmanaged direct 
hosts, processing connect for them...");
+                s_logger.debug("Found " + hosts.size() + " unmanaged direct 
hosts, processing connect for them...");
                 for (HostVO host : hosts) {
                     try {
                         AgentAttache agentattache = findAttache(host.getId());
                         if (agentattache != null) {
                             // already loaded, skip
                             if (agentattache.forForward()) {
-                                if (logger.isInfoEnabled()) {
-                                    logger.info(host + " is detected down, but 
we have a forward attache running, disconnect this one before launching the 
host");
+                                if (s_logger.isInfoEnabled()) {
+                                    s_logger.info(host + " is detected down, 
but we have a forward attache running, disconnect this one before launching the 
host");
                                 }
                                 removeAgent(agentattache, Status.Disconnected);
                             } else {
@@ -211,18 +215,18 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                             }
                         }
 
-                        if (logger.isDebugEnabled()) {
-                            logger.debug("Loading directly connected host " + 
host.getId() + "(" + host.getName() + ")");
+                        if (s_logger.isDebugEnabled()) {
+                            s_logger.debug("Loading directly connected host " 
+ host.getId() + "(" + host.getName() + ")");
                         }
                         loadDirectlyConnectedHost(host, false);
                     } catch (Throwable e) {
-                        logger.warn(" can not load directly connected host " + 
host.getId() + "(" + host.getName() + ") due to ", e);
+                        s_logger.warn(" can not load directly connected host " 
+ host.getId() + "(" + host.getName() + ") due to ", e);
                     }
                 }
             }
         }
-        if (logger.isTraceEnabled()) {
-            logger.trace("End scanning directly connected hosts");
+        if (s_logger.isTraceEnabled()) {
+            s_logger.trace("End scanning directly connected hosts");
         }
     }
 
@@ -232,7 +236,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             try {
                 runDirectAgentScanTimerTask();
             } catch (Throwable e) {
-                logger.error("Unexpected exception " + e.getMessage(), e);
+                s_logger.error("Unexpected exception " + e.getMessage(), e);
             }
         }
     }
@@ -243,7 +247,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     }
 
     protected AgentAttache createAttache(long id) {
-        logger.debug("create forwarding ClusteredAgentAttache for " + id);
+        s_logger.debug("create forwarding ClusteredAgentAttache for " + id);
         HostVO host = _hostDao.findById(id);
         final AgentAttache attache = new ClusteredAgentAttache(this, id, 
host.getName());
         AgentAttache old = null;
@@ -252,8 +256,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             _agents.put(id, attache);
         }
         if (old != null) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Remove stale agent attache from current 
management server");
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Remove stale agent attache from current 
management server");
             }
             removeAgent(old, Status.Removed);
         }
@@ -262,7 +266,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
     @Override
     protected AgentAttache createAttacheForConnect(HostVO host, Link link) {
-        logger.debug("create ClusteredAgentAttache for " + host.getId());
+        s_logger.debug("create ClusteredAgentAttache for " + host.getId());
         final AgentAttache attache = new ClusteredAgentAttache(this, 
host.getId(), host.getName(), link, host.isInMaintenanceStates());
         link.attach(attache);
         AgentAttache old = null;
@@ -278,7 +282,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
     @Override
     protected AgentAttache createAttacheForDirectConnect(Host host, 
ServerResource resource) {
-        logger.debug("create ClusteredDirectAgentAttache for " + host.getId());
+        s_logger.debug("create ClusteredDirectAgentAttache for " + 
host.getId());
         final DirectAgentAttache attache = new 
ClusteredDirectAgentAttache(this, host.getId(), host.getName(), _nodeId, 
resource, host.isInMaintenanceStates());
         AgentAttache old = null;
         synchronized (_agents) {
@@ -322,8 +326,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     @Override
     public boolean executeUserRequest(long hostId, Event event) throws 
AgentUnavailableException {
         if (event == Event.AgentDisconnected) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Received agent disconnect event for host " + 
hostId);
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Received agent disconnect event for host " + 
hostId);
             }
             AgentAttache attache = findAttache(hostId);
             if (attache != null) {
@@ -332,7 +336,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                     HostTransferMapVO transferVO = 
_hostTransferDao.findById(hostId);
                     if (transferVO != null) {
                         if (transferVO.getFutureOwner() == _nodeId && 
transferVO.getState() == HostTransferState.TransferStarted) {
-                            logger.debug("Not processing " + 
Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is 
being connected to " +
+                            s_logger.debug("Not processing " + 
Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is 
being connected to " +
                                     _nodeId);
                             return true;
                         }
@@ -342,7 +346,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 // don't process disconnect if the disconnect came for the 
host via delayed cluster notification,
                 // but the host has already reconnected to the current 
management server
                 if (!attache.forForward()) {
-                    logger.debug("Not processing " + Event.AgentDisconnected + 
" event for the host id=" + hostId +
+                    s_logger.debug("Not processing " + Event.AgentDisconnected 
+ " event for the host id=" + hostId +
                             " as the host is directly connected to the current 
management server " + _nodeId);
                     return true;
                 }
@@ -365,7 +369,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 return result;
             }
         } catch (AgentUnavailableException e) {
-            logger.debug("cannot propagate agent reconnect because agent is 
not available", e);
+            s_logger.debug("cannot propagate agent reconnect because agent is 
not available", e);
             return false;
         }
 
@@ -373,27 +377,32 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     }
 
     public void notifyNodesInCluster(AgentAttache attache) {
-        logger.debug("Notifying other nodes of to disconnect");
+        s_logger.debug("Notifying other nodes of to disconnect");
         Command[] cmds = new Command[] {new 
ChangeAgentCommand(attache.getId(), Event.AgentDisconnected)};
         _clusterMgr.broadcast(attache.getId(), _gson.toJson(cmds));
     }
 
     // notifies MS peers to schedule a host scan task immediately, triggered 
during addHost operation
     public void notifyNodesInClusterToScheduleHostScanTask() {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Notifying other MS nodes to run host scan task");
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Notifying other MS nodes to run host scan task");
         }
         Command[] cmds = new Command[] {new ScheduleHostScanTaskCommand()};
         _clusterMgr.broadcast(0, _gson.toJson(cmds));
     }
 
-    protected void logD(byte[] bytes, final String msg) {
-        logger.debug("Seq " + Request.getAgentId(bytes) + "-" + 
Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) 
+ ": " +
+    protected static void logT(byte[] bytes, final String msg) {
+        s_logger.trace("Seq " + Request.getAgentId(bytes) + "-" + 
Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) 
+ ": " +
+                (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg);
+    }
+
+    protected static void logD(byte[] bytes, final String msg) {
+        s_logger.debug("Seq " + Request.getAgentId(bytes) + "-" + 
Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) 
+ ": " +
                 (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg);
     }
 
-    protected void logI(byte[] bytes, final String msg) {
-        logger.info("Seq " + Request.getAgentId(bytes) + "-" + 
Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) 
+ ": " +
+    protected static void logI(byte[] bytes, final String msg) {
+        s_logger.info("Seq " + Request.getAgentId(bytes) + "-" + 
Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) 
+ ": " +
                 (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg);
     }
 
@@ -418,7 +427,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 return false;
             }
             try {
-                if (logger.isDebugEnabled()) {
+                if (s_logger.isDebugEnabled()) {
                     logD(bytes, "Routing to peer");
                 }
                 Link.write(ch, new ByteBuffer[] {ByteBuffer.wrap(bytes)}, 
sslEngine);
@@ -458,7 +467,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 try {
                     ch.close();
                 } catch (IOException e) {
-                    logger.warn("Unable to close peer socket connection to " + 
peerName);
+                    s_logger.warn("Unable to close peer socket connection to " 
+ peerName);
                 }
             }
             _peers.remove(peerName);
@@ -474,14 +483,14 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 try {
                     prevCh.close();
                 } catch (Exception e) {
-                    logger.info("[ignored]"
+                    s_logger.info("[ignored]"
                             + "failed to get close resource for previous 
channel Socket: " + e.getLocalizedMessage());
                 }
             }
             if (ch == null || ch == prevCh) {
                 ManagementServerHost ms = _clusterMgr.getPeer(peerName);
                 if (ms == null) {
-                    logger.info("Unable to find peer: " + peerName);
+                    s_logger.info("Unable to find peer: " + peerName);
                     return null;
                 }
                 String ip = ms.getServiceIP();
@@ -504,13 +513,13 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                         
sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols()));
 
                         Link.doHandshake(ch1, sslEngine, true);
-                        logger.info("SSL: Handshake done");
+                        s_logger.info("SSL: Handshake done");
                     } catch (Exception e) {
                         ch1.close();
                         throw new IOException("SSL: Fail to init SSL! " + e);
                     }
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Connection to peer opened: " + peerName 
+ ", ip: " + ip);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Connection to peer opened: " + 
peerName + ", ip: " + ip);
                     }
                     _peers.put(peerName, ch1);
                     _sslEngines.put(peerName, sslEngine);
@@ -519,15 +528,15 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                     try {
                         ch1.close();
                     } catch (IOException ex) {
-                        logger.error("failed to close failed peer socket: " + 
ex);
+                        s_logger.error("failed to close failed peer socket: " 
+ ex);
                     }
-                    logger.warn("Unable to connect to peer management server: 
" + peerName + ", ip: " + ip + " due to " + e.getMessage(), e);
+                    s_logger.warn("Unable to connect to peer management 
server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e);
                     return null;
                 }
             }
 
-            if (logger.isTraceEnabled()) {
-                logger.trace("Found open channel for peer: " + peerName);
+            if (s_logger.isTraceEnabled()) {
+                s_logger.trace("Found open channel for peer: " + peerName);
             }
             return ch;
         }
@@ -553,8 +562,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         AgentAttache agent = findAttache(hostId);
         if (agent == null || !agent.forForward()) {
             if (isHostOwnerSwitched(host)) {
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Host " + hostId + " has switched to another 
management server, need to update agent map with a forwarding agent attache");
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Host " + hostId + " has switched to 
another management server, need to update agent map with a forwarding agent 
attache");
                 }
                 agent = createAttache(hostId);
             }
@@ -573,10 +582,10 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         if (_peers != null) {
             for (SocketChannel ch : _peers.values()) {
                 try {
-                    logger.info("Closing: " + ch.toString());
+                    s_logger.info("Closing: " + ch.toString());
                     ch.close();
                 } catch (IOException e) {
-                    logger.info("[ignored] error on closing channel: " 
+ch.toString(), e);
+                    s_logger.info("[ignored] error on closing channel: " 
+ch.toString(), e);
                 }
             }
         }
@@ -613,7 +622,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 final byte[] data = task.getData();
                 Version ver = Request.getVersion(data);
                 if (ver.ordinal() != Version.v1.ordinal() && ver.ordinal() != 
Version.v3.ordinal()) {
-                    logger.warn("Wrong version for clustered agent request");
+                    s_logger.warn("Wrong version for clustered agent request");
                     super.doTask(task);
                     return;
                 }
@@ -633,7 +642,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                         Request req = Request.parse(data);
                         Command[] cmds = req.getCommands();
                         CancelCommand cancel = (CancelCommand)cmds[0];
-                        if (logger.isDebugEnabled()) {
+                        if (s_logger.isDebugEnabled()) {
                             logD(data, "Cancel request received");
                         }
                         agent.cancel(cancel.getSequence());
@@ -681,7 +690,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                             AgentAttache attache = 
(AgentAttache)link.attachment();
                             if (attache != null) {
                                 attache.sendNext(Request.getSequence(data));
-                            } else if (logger.isDebugEnabled()) {
+                            } else if (s_logger.isDebugEnabled()) {
                                 logD(data, "No attache to process " + 
Request.parse(data).toString());
                             }
                         }
@@ -694,11 +703,11 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                             final Response response = Response.parse(data);
                             AgentAttache attache = 
findAttache(response.getAgentId());
                             if (attache == null) {
-                                logger.info("SeqA " + response.getAgentId() + 
"-" + response.getSequence() + "Unable to find attache to forward " + 
response.toString());
+                                s_logger.info("SeqA " + response.getAgentId() 
+ "-" + response.getSequence() + "Unable to find attache to forward " + 
response.toString());
                                 return;
                             }
                             if 
(!attache.processAnswers(response.getSequence(), response)) {
-                                logger.info("SeqA " + attache.getId() + "-" + 
response.getSequence() + ": Response is not processed: " + response.toString());
+                                s_logger.info("SeqA " + attache.getId() + "-" 
+ response.getSequence() + ": Response is not processed: " + 
response.toString());
                             }
                         }
                         return;
@@ -717,10 +726,10 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     @Override
     public void onManagementNodeLeft(List<? extends ManagementServerHost> 
nodeList, long selfNodeId) {
         for (ManagementServerHost vo : nodeList) {
-            logger.info("Marking hosts as disconnected on Management server" + 
vo.getMsid());
+            s_logger.info("Marking hosts as disconnected on Management server" 
+ vo.getMsid());
             long lastPing = (System.currentTimeMillis() >> 10) - getTimeout();
             _hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing);
-            logger.info("Deleting entries from op_host_transfer table for 
Management server " + vo.getMsid());
+            s_logger.info("Deleting entries from op_host_transfer table for 
Management server " + vo.getMsid());
             cleanupTransferMap(vo.getMsid());
         }
     }
@@ -748,7 +757,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             try {
                 result = rebalanceHost(agentId, currentOwnerId, futureOwnerId);
             } catch (Exception e) {
-                logger.warn("Unable to rebalance host id=" + agentId, e);
+                s_logger.warn("Unable to rebalance host id=" + agentId, e);
             }
         }
         return result;
@@ -763,14 +772,14 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         protected volatile boolean cancelled = false;
 
         public AgentLoadBalancerTask() {
-            logger.debug("Agent load balancer task created");
+            s_logger.debug("Agent load balancer task created");
         }
 
         @Override
         public synchronized boolean cancel() {
             if (!cancelled) {
                 cancelled = true;
-                logger.debug("Agent load balancer task cancelled");
+                s_logger.debug("Agent load balancer task cancelled");
                 return super.cancel();
             }
             return true;
@@ -781,19 +790,19 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             try {
                 if (!cancelled) {
                     startRebalanceAgents();
-                    if (logger.isInfoEnabled()) {
-                        logger.info("The agent load balancer task is now being 
cancelled");
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("The agent load balancer task is now 
being cancelled");
                     }
                     cancelled = true;
                 }
             } catch (Throwable e) {
-                logger.error("Unexpected exception " + e.toString(), e);
+                s_logger.error("Unexpected exception " + e.toString(), e);
             }
         }
     }
 
     public void startRebalanceAgents() {
-        logger.debug("Management server " + _nodeId + " is asking other peers 
to rebalance their agents");
+        s_logger.debug("Management server " + _nodeId + " is asking other 
peers to rebalance their agents");
         List<ManagementServerHostVO> allMS = 
_mshostDao.listBy(ManagementServerHost.State.Up);
         QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
         sc.and(sc.entity().getManagementServerId(), Op.NNULL);
@@ -805,16 +814,16 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         if (!allManagedAgents.isEmpty() && !allMS.isEmpty()) {
             avLoad = allManagedAgents.size() / allMS.size();
         } else {
-            if (logger.isDebugEnabled()) {
-                logger.debug("There are no hosts to rebalance in the system. 
Current number of active management server nodes in the system is " + 
allMS.size() +
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("There are no hosts to rebalance in the system. 
Current number of active management server nodes in the system is " + 
allMS.size() +
                         "; number of managed agents is " + 
allManagedAgents.size());
             }
             return;
         }
 
         if (avLoad == 0L) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("As calculated average load is less than 1, 
rounding it to 1");
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("As calculated average load is less than 1, 
rounding it to 1");
             }
             avLoad = 1;
         }
@@ -828,19 +837,19 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                     if (hostsToRebalance != null && 
!hostsToRebalance.isEmpty()) {
                         break;
                     } else {
-                        logger.debug("Agent load balancer planner " + 
lbPlanner.getName() + " found no hosts to be rebalanced from management server 
" + node.getMsid());
+                        s_logger.debug("Agent load balancer planner " + 
lbPlanner.getName() + " found no hosts to be rebalanced from management server 
" + node.getMsid());
                     }
                 }
 
                 if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
-                    logger.debug("Found " + hostsToRebalance.size() + " hosts 
to rebalance from management server " + node.getMsid());
+                    s_logger.debug("Found " + hostsToRebalance.size() + " 
hosts to rebalance from management server " + node.getMsid());
                     for (HostVO host : hostsToRebalance) {
                         long hostId = host.getId();
-                        logger.debug("Asking management server " + 
node.getMsid() + " to give away host id=" + hostId);
+                        s_logger.debug("Asking management server " + 
node.getMsid() + " to give away host id=" + hostId);
                         boolean result = true;
 
                         if (_hostTransferDao.findById(hostId) != null) {
-                            logger.warn("Somebody else is already rebalancing 
host id: " + hostId);
+                            s_logger.warn("Somebody else is already 
rebalancing host id: " + hostId);
                             continue;
                         }
 
@@ -849,18 +858,18 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                             transfer = 
_hostTransferDao.startAgentTransfering(hostId, node.getMsid(), _nodeId);
                             Answer[] answer = 
sendRebalanceCommand(node.getMsid(), hostId, node.getMsid(), _nodeId, 
Event.RequestAgentRebalance);
                             if (answer == null) {
-                                logger.warn("Failed to get host id=" + hostId 
+ " from management server " + node.getMsid());
+                                s_logger.warn("Failed to get host id=" + 
hostId + " from management server " + node.getMsid());
                                 result = false;
                             }
                         } catch (Exception ex) {
-                            logger.warn("Failed to get host id=" + hostId + " 
from management server " + node.getMsid(), ex);
+                            s_logger.warn("Failed to get host id=" + hostId + 
" from management server " + node.getMsid(), ex);
                             result = false;
                         } finally {
                             if (transfer != null) {
                                 HostTransferMapVO transferState = 
_hostTransferDao.findByIdAndFutureOwnerId(transfer.getId(), _nodeId);
                                 if (!result && transferState != null && 
transferState.getState() == HostTransferState.TransferRequested) {
-                                    if (logger.isDebugEnabled()) {
-                                        logger.debug("Removing mapping from 
op_host_transfer as it failed to be set to transfer mode");
+                                    if (s_logger.isDebugEnabled()) {
+                                        s_logger.debug("Removing mapping from 
op_host_transfer as it failed to be set to transfer mode");
                                     }
                                     // just remove the mapping (if exists) as 
nothing was done on the peer management
 // server yet
@@ -870,7 +879,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                         }
                     }
                 } else {
-                    logger.debug("Found no hosts to rebalance from the 
management server " + node.getMsid());
+                    s_logger.debug("Found no hosts to rebalance from the 
management server " + node.getMsid());
                 }
             }
         }
@@ -884,8 +893,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         Command[] cmds = commands.toCommands();
 
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Forwarding " + cmds[0].toString() + " to " + 
peer);
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Forwarding " + cmds[0].toString() + " to " + 
peer);
             }
             String peerName = Long.toString(peer);
             String cmdStr = _gson.toJson(cmds);
@@ -893,7 +902,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
             return answers;
         } catch (Exception e) {
-            logger.warn("Caught exception while talking to " + currentOwnerId, 
e);
+            s_logger.warn("Caught exception while talking to " + 
currentOwnerId, e);
             return null;
         }
     }
@@ -917,8 +926,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             return null;
         }
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("Propagating agent change request event:" + 
event.toString() + " to agent:" + agentId);
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Propagating agent change request event:" + 
event.toString() + " to agent:" + agentId);
         }
         Command[] cmds = new Command[1];
         cmds[0] = new ChangeAgentCommand(agentId, event);
@@ -930,8 +939,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
         Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("Result for agent change is " + 
answers[0].getResult());
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Result for agent change is " + 
answers[0].getResult());
         }
 
         return answers[0].getResult();
@@ -942,12 +951,12 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             @Override
             protected void runInContext() {
                 try {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Clustered agent transfer scan check, 
management server id:" + _nodeId);
+                    if (s_logger.isTraceEnabled()) {
+                        s_logger.trace("Clustered agent transfer scan check, 
management server id:" + _nodeId);
                     }
                     synchronized (_agentToTransferIds) {
                         if (_agentToTransferIds.size() > 0) {
-                            logger.debug("Found " + _agentToTransferIds.size() 
+ " agents to transfer");
+                            s_logger.debug("Found " + 
_agentToTransferIds.size() + " agents to transfer");
                             // for (Long hostId : _agentToTransferIds) {
                             for (Iterator<Long> iterator = 
_agentToTransferIds.iterator(); iterator.hasNext();) {
                                 Long hostId = iterator.next();
@@ -964,14 +973,14 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                                         
_hostTransferDao.findActiveHostTransferMapByHostId(hostId, new 
Date(cutTime.getTime() - rebalanceTimeOut));
 
                                 if (transferMap == null) {
-                                    logger.debug("Timed out waiting for the 
host id=" + hostId + " to be ready to transfer, skipping rebalance for the 
host");
+                                    s_logger.debug("Timed out waiting for the 
host id=" + hostId + " to be ready to transfer, skipping rebalance for the 
host");
                                     iterator.remove();
                                     
_hostTransferDao.completeAgentTransfer(hostId);
                                     continue;
                                 }
 
                                 if (transferMap.getInitialOwner() != _nodeId 
|| attache == null || attache.forForward()) {
-                                    logger.debug("Management server " + 
_nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for 
the host");
+                                    s_logger.debug("Management server " + 
_nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for 
the host");
                                     iterator.remove();
                                     
_hostTransferDao.completeAgentTransfer(hostId);
                                     continue;
@@ -979,7 +988,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
                                 ManagementServerHostVO ms = 
_mshostDao.findByMsid(transferMap.getFutureOwner());
                                 if (ms != null && ms.getState() != 
ManagementServerHost.State.Up) {
-                                    logger.debug("Can't transfer host " + 
hostId + " as it's future owner is not in UP state: " + ms +
+                                    s_logger.debug("Can't transfer host " + 
hostId + " as it's future owner is not in UP state: " + ms +
                                             ", skipping rebalance for the 
host");
                                     iterator.remove();
                                     
_hostTransferDao.completeAgentTransfer(hostId);
@@ -991,31 +1000,31 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                                     try {
                                         _executor.execute(new 
RebalanceTask(hostId, transferMap.getInitialOwner(), 
transferMap.getFutureOwner()));
                                     } catch (RejectedExecutionException ex) {
-                                        logger.warn("Failed to submit 
rebalance task for host id=" + hostId + "; postponing the execution");
+                                        s_logger.warn("Failed to submit 
rebalance task for host id=" + hostId + "; postponing the execution");
                                         continue;
                                     }
 
                                 } else {
-                                    logger.debug("Agent " + hostId + " can't 
be transfered yet as its request queue size is " + attache.getQueueSize() +
+                                    s_logger.debug("Agent " + hostId + " can't 
be transfered yet as its request queue size is " + attache.getQueueSize() +
                                             " and listener queue size is " + 
attache.getNonRecurringListenersSize());
                                 }
                             }
                         } else {
-                            if (logger.isTraceEnabled()) {
-                                logger.trace("Found no agents to be transfered 
by the management server " + _nodeId);
+                            if (s_logger.isTraceEnabled()) {
+                                s_logger.trace("Found no agents to be 
transfered by the management server " + _nodeId);
                             }
                         }
                     }
 
                 } catch (Throwable e) {
-                    logger.error("Problem with the clustered agent transfer 
scan check!", e);
+                    s_logger.error("Problem with the clustered agent transfer 
scan check!", e);
                 }
             }
         };
     }
 
     private boolean setToWaitForRebalance(final long hostId, long 
currentOwnerId, long futureOwnerId) {
-        logger.debug("Adding agent " + hostId + " to the list of agents to 
transfer");
+        s_logger.debug("Adding agent " + hostId + " to the list of agents to 
transfer");
         synchronized (_agentToTransferIds) {
             return _agentToTransferIds.add(hostId);
         }
@@ -1026,7 +1035,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         boolean result = true;
         if (currentOwnerId == _nodeId) {
             if (!startRebalance(hostId)) {
-                logger.debug("Failed to start agent rebalancing");
+                s_logger.debug("Failed to start agent rebalancing");
                 finishRebalance(hostId, futureOwnerId, Event.RebalanceFailed);
                 return false;
             }
@@ -1037,23 +1046,23 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 }
 
             } catch (Exception ex) {
-                logger.warn("Host " + hostId + " failed to connect to the 
management server " + futureOwnerId + " as a part of rebalance process", ex);
+                s_logger.warn("Host " + hostId + " failed to connect to the 
management server " + futureOwnerId + " as a part of rebalance process", ex);
                 result = false;
             }
 
             if (result) {
-                logger.debug("Successfully transfered host id=" + hostId + " 
to management server " + futureOwnerId);
+                s_logger.debug("Successfully transfered host id=" + hostId + " 
to management server " + futureOwnerId);
                 finishRebalance(hostId, futureOwnerId, 
Event.RebalanceCompleted);
             } else {
-                logger.warn("Failed to transfer host id=" + hostId + " to 
management server " + futureOwnerId);
+                s_logger.warn("Failed to transfer host id=" + hostId + " to 
management server " + futureOwnerId);
                 finishRebalance(hostId, futureOwnerId, Event.RebalanceFailed);
             }
 
         } else if (futureOwnerId == _nodeId) {
             HostVO host = _hostDao.findById(hostId);
             try {
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Disconnecting host " + host.getId() + "(" + 
host.getName() + " as a part of rebalance process without notification");
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Disconnecting host " + host.getId() + "(" 
+ host.getName() + " as a part of rebalance process without notification");
                 }
 
                 AgentAttache attache = findAttache(hostId);
@@ -1062,26 +1071,26 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 }
 
                 if (result) {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Loading directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Loading directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
                                 " as a part of rebalance process");
                     }
                     result = loadDirectlyConnectedHost(host, true);
                 } else {
-                    logger.warn("Failed to disconnect " + host.getId() + "(" + 
host.getName() + " as a part of rebalance process without notification");
+                    s_logger.warn("Failed to disconnect " + host.getId() + "(" 
+ host.getName() + " as a part of rebalance process without notification");
                 }
 
             } catch (Exception ex) {
-                logger.warn("Failed to load directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+                s_logger.warn("Failed to load directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
                         " as a part of rebalance process due to:", ex);
                 result = false;
             }
 
             if (result) {
-                logger.debug("Successfully loaded directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+                s_logger.debug("Successfully loaded directly connected host " 
+ host.getId() + "(" + host.getName() + ") to the management server " + _nodeId 
+
                         " as a part of rebalance process");
             } else {
-                logger.warn("Failed to load directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+                s_logger.warn("Failed to load directly connected host " + 
host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
                         " as a part of rebalance process");
             }
         }
@@ -1092,13 +1101,13 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     protected void finishRebalance(final long hostId, long futureOwnerId, 
Event event) {
 
         boolean success = (event == Event.RebalanceCompleted) ? true : false;
-        if (logger.isDebugEnabled()) {
-            logger.debug("Finishing rebalancing for the agent " + hostId + " 
with event " + event);
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Finishing rebalancing for the agent " + hostId + " 
with event " + event);
         }
 
         AgentAttache attache = findAttache(hostId);
         if (attache == null || !(attache instanceof ClusteredAgentAttache)) {
-            logger.debug("Unable to find forward attache for the host id=" + 
hostId + ", assuming that the agent disconnected already");
+            s_logger.debug("Unable to find forward attache for the host id=" + 
hostId + ", assuming that the agent disconnected already");
             _hostTransferDao.completeAgentTransfer(hostId);
             return;
         }
@@ -1113,7 +1122,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             // 2) Get all transfer requests and route them to peer
             Request requestToTransfer = forwardAttache.getRequestToTransfer();
             while (requestToTransfer != null) {
-                logger.debug("Forwarding request " + 
requestToTransfer.getSequence() + " held in transfer attache " + hostId + " 
from the management server " +
+                s_logger.debug("Forwarding request " + 
requestToTransfer.getSequence() + " held in transfer attache " + hostId + " 
from the management server " +
                         _nodeId + " to " + futureOwnerId);
                 boolean routeResult = 
routeToPeer(Long.toString(futureOwnerId), requestToTransfer.getBytes());
                 if (!routeResult) {
@@ -1123,23 +1132,23 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 requestToTransfer = forwardAttache.getRequestToTransfer();
             }
 
-            logger.debug("Management server " + _nodeId + " completed agent " 
+ hostId + " rebalance to " + futureOwnerId);
+            s_logger.debug("Management server " + _nodeId + " completed agent 
" + hostId + " rebalance to " + futureOwnerId);
 
         } else {
             failRebalance(hostId);
         }
 
-        logger.debug("Management server " + _nodeId + " completed agent " + 
hostId + " rebalance");
+        s_logger.debug("Management server " + _nodeId + " completed agent " + 
hostId + " rebalance");
         _hostTransferDao.completeAgentTransfer(hostId);
     }
 
     protected void failRebalance(final long hostId) {
         try {
-            logger.debug("Management server " + _nodeId + " failed to 
rebalance agent " + hostId);
+            s_logger.debug("Management server " + _nodeId + " failed to 
rebalance agent " + hostId);
             _hostTransferDao.completeAgentTransfer(hostId);
             handleDisconnectWithoutInvestigation(findAttache(hostId), 
Event.RebalanceFailed, true, true);
         } catch (Exception ex) {
-            logger.warn("Failed to reconnect host id=" + hostId + " as a part 
of failed rebalance task cleanup");
+            s_logger.warn("Failed to reconnect host id=" + hostId + " as a 
part of failed rebalance task cleanup");
         }
     }
 
@@ -1147,7 +1156,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         HostVO host = _hostDao.findById(hostId);
 
         if (host == null || host.getRemoved() != null) {
-            logger.warn("Unable to find host record, fail start rebalancing 
process");
+            s_logger.warn("Unable to find host record, fail start rebalancing 
process");
             return false;
         }
 
@@ -1157,17 +1166,17 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 handleDisconnectWithoutInvestigation(attache, 
Event.StartAgentRebalance, true, true);
                 ClusteredAgentAttache forwardAttache = 
(ClusteredAgentAttache)createAttache(hostId);
                 if (forwardAttache == null) {
-                    logger.warn("Unable to create a forward attache for the 
host " + hostId + " as a part of rebalance process");
+                    s_logger.warn("Unable to create a forward attache for the 
host " + hostId + " as a part of rebalance process");
                     return false;
                 }
-                logger.debug("Putting agent id=" + hostId + " to transfer 
mode");
+                s_logger.debug("Putting agent id=" + hostId + " to transfer 
mode");
                 forwardAttache.setTransferMode(true);
                 _agents.put(hostId, forwardAttache);
             } else {
                 if (attache == null) {
-                    logger.warn("Attache for the agent " + hostId + " no 
longer exists on management server " + _nodeId + ", can't start host 
rebalancing");
+                    s_logger.warn("Attache for the agent " + hostId + " no 
longer exists on management server " + _nodeId + ", can't start host 
rebalancing");
                 } else {
-                    logger.warn("Attache for the agent " + hostId + " has 
request queue size= " + attache.getQueueSize() + " and listener queue size " +
+                    s_logger.warn("Attache for the agent " + hostId + " has 
request queue size= " + attache.getQueueSize() + " and listener queue size " +
                             attache.getNonRecurringListenersSize() + ", can't 
start host rebalancing");
                 }
                 return false;
@@ -1204,19 +1213,19 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         @Override
         protected void runInContext() {
             try {
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Rebalancing host id=" + hostId);
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Rebalancing host id=" + hostId);
                 }
                 rebalanceHost(hostId, currentOwnerId, futureOwnerId);
             } catch (Exception e) {
-                logger.warn("Unable to rebalance host id=" + hostId, e);
+                s_logger.warn("Unable to rebalance host id=" + hostId, e);
             }
         }
     }
 
     private String 
handleScheduleHostScanTaskCommand(ScheduleHostScanTaskCommand cmd) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Intercepting resource manager command: " + 
_gson.toJson(cmd));
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Intercepting resource manager command: " + 
_gson.toJson(cmd));
         }
 
         try {
@@ -1224,7 +1233,7 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         } catch (Exception e) {
             // Scheduling host scan task in peer MS is a best effort operation 
during host add, regular host scan
             // happens at fixed intervals anyways. So handling any exceptions 
that may be thrown
-            logger.warn("Exception happened while trying to schedule host scan 
task on mgmt server " + _clusterMgr.getSelfPeerName() +
+            s_logger.warn("Exception happened while trying to schedule host 
scan task on mgmt server " + _clusterMgr.getSelfPeerName() +
                     ", ignoring as regular host scan happens at fixed interval 
anyways", e);
             return null;
         }
@@ -1251,8 +1260,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
         @Override
         public String dispatch(ClusterServicePdu pdu) {
 
-            if (logger.isDebugEnabled()) {
-                logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + 
pdu.getJsonPackage());
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + 
pdu.getJsonPackage());
             }
 
             Command[] cmds = null;
@@ -1260,24 +1269,24 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                 cmds = _gson.fromJson(pdu.getJsonPackage(), Command[].class);
             } catch (Throwable e) {
                 assert (false);
-                logger.error("Excection in gson decoding : ", e);
+                s_logger.error("Excection in gson decoding : ", e);
             }
 
             if (cmds.length == 1 && cmds[0] instanceof ChangeAgentCommand) { 
// intercepted
                 ChangeAgentCommand cmd = (ChangeAgentCommand)cmds[0];
 
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Intercepting command for agent change: agent 
" + cmd.getAgentId() + " event: " + cmd.getEvent());
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Intercepting command for agent change: 
agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
                 }
                 boolean result = false;
                 try {
                     result = executeAgentUserRequest(cmd.getAgentId(), 
cmd.getEvent());
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Result is " + result);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Result is " + result);
                     }
 
                 } catch (AgentUnavailableException e) {
-                    logger.warn("Agent is unavailable", e);
+                    s_logger.warn("Agent is unavailable", e);
                     return null;
                 }
 
@@ -1287,21 +1296,21 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             } else if (cmds.length == 1 && cmds[0] instanceof 
TransferAgentCommand) {
                 TransferAgentCommand cmd = (TransferAgentCommand)cmds[0];
 
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Intercepting command for agent rebalancing: 
agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Intercepting command for agent 
rebalancing: agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
                 }
                 boolean result = false;
                 try {
                     result = rebalanceAgent(cmd.getAgentId(), cmd.getEvent(), 
cmd.getCurrentOwner(), cmd.getFutureOwner());
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Result is " + result);
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Result is " + result);
                     }
 
                 } catch (AgentUnavailableException e) {
-                    logger.warn("Agent is unavailable", e);
+                    s_logger.warn("Agent is unavailable", e);
                     return null;
                 } catch (OperationTimedoutException e) {
-                    logger.warn("Operation timed out", e);
+                    s_logger.warn("Operation timed out", e);
                     return null;
                 }
                 Answer[] answers = new Answer[1];
@@ -1310,14 +1319,14 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             } else if (cmds.length == 1 && cmds[0] instanceof 
PropagateResourceEventCommand) {
                 PropagateResourceEventCommand cmd = 
(PropagateResourceEventCommand)cmds[0];
 
-                logger.debug("Intercepting command to propagate event " + 
cmd.getEvent().name() + " for host " + cmd.getHostId());
+                s_logger.debug("Intercepting command to propagate event " + 
cmd.getEvent().name() + " for host " + cmd.getHostId());
 
                 boolean result = false;
                 try {
                     result = _resourceMgr.executeUserRequest(cmd.getHostId(), 
cmd.getEvent());
-                    logger.debug("Result is " + result);
+                    s_logger.debug("Result is " + result);
                 } catch (AgentUnavailableException ex) {
-                    logger.warn("Agent is unavailable", ex);
+                    s_logger.warn("Agent is unavailable", ex);
                     return null;
                 }
 
@@ -1332,30 +1341,30 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
 
             try {
                 long startTick = System.currentTimeMillis();
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Dispatch -> " + pdu.getAgentId() + ", json: 
" + pdu.getJsonPackage());
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Dispatch -> " + pdu.getAgentId() + ", 
json: " + pdu.getJsonPackage());
                 }
 
                 Answer[] answers = sendToAgent(pdu.getAgentId(), cmds, 
pdu.isStopOnError());
                 if (answers != null) {
                     String jsonReturn = _gson.toJson(answers);
 
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Completed dispatching -> " + 
pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Completed dispatching -> " + 
pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
                                 (System.currentTimeMillis() - startTick) + " 
ms, return result: " + jsonReturn);
                     }
 
                     return jsonReturn;
                 } else {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Completed dispatching -> " + 
pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Completed dispatching -> " + 
pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
                                 (System.currentTimeMillis() - startTick) + " 
ms, return null result");
                     }
                 }
             } catch (AgentUnavailableException e) {
-                logger.warn("Agent is unavailable", e);
+                s_logger.warn("Agent is unavailable", e);
             } catch (OperationTimedoutException e) {
-                logger.warn("Timed Out", e);
+                s_logger.warn("Timed Out", e);
             }
 
             return null;
@@ -1380,8 +1389,8 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
             @Override
             protected void runInContext() {
                 try {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Agent rebalance task check, management 
server id:" + _nodeId);
+                    if (s_logger.isTraceEnabled()) {
+                        s_logger.trace("Agent rebalance task check, management 
server id:" + _nodeId);
                     }
                     // initiate agent lb task will be scheduled and executed 
only once, and only when number of agents
 // loaded exceeds _connectedAgentsThreshold
@@ -1399,18 +1408,18 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
                         if (allHostsCount > 0.0) {
                             double load = managedHostsCount / allHostsCount;
                             if (load >= ConnectedAgentThreshold.value()) {
-                                logger.debug("Scheduling agent rebalancing 
task as the average agent load " + load + " is more than the threshold " +
+                                s_logger.debug("Scheduling agent rebalancing 
task as the average agent load " + load + " is more than the threshold " +
                                         ConnectedAgentThreshold.value());
                                 scheduleRebalanceAgents();
                                 _agentLbHappened = true;
                             } else {
-                                logger.debug("Not scheduling agent rebalancing 
task as the averages load " + load + " is less than the threshold " +
+                                s_logger.debug("Not scheduling agent 
rebalancing task as the averages load " + load + " is less than the threshold " 
+
                                         ConnectedAgentThreshold.value());
                             }
                         }
                     }
                 } catch (Throwable e) {
-                    logger.error("Problem with the clustered agent transfer 
scan check!", e);
+                    s_logger.error("Problem with the clustered agent transfer 
scan check!", e);
                 }
             }
         };
@@ -1419,13 +1428,13 @@ public class ClusteredAgentManagerImpl extends 
AgentManagerImpl implements Clust
     @Override
     public void rescan() {
         // schedule a scan task immediately
-        if (logger.isDebugEnabled()) {
-            logger.debug("Scheduling a host scan task");
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Scheduling a host scan task");
         }
         // schedule host scan task on current MS
         scheduleHostScanTask();
-        if (logger.isDebugEnabled()) {
-            logger.debug("Notifying all peer MS to schedule host scan task");
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Notifying all peer MS to schedule host scan task");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
----------------------------------------------------------------------
diff --git 
a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
 
b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
index f5c699b..254f1bf 100644
--- 
a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
+++ 
b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.host.Host;
@@ -40,6 +41,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Component
 @Local(value = AgentLoadBalancerPlanner.class)
 public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase 
implements AgentLoadBalancerPlanner {
+    private static final Logger s_logger = 
Logger.getLogger(AgentLoadBalancerPlanner.class);
 
     @Inject
     HostDao _hostDao = null;
@@ -52,7 +54,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends 
AdapterBase implements
         List<HostVO> allHosts = sc.list();
 
         if (allHosts.size() <= avLoad) {
-            logger.debug("Agent load = " + allHosts.size() + " for management 
server " + msId + " doesn't exceed average system agent load = " + avLoad +
+            s_logger.debug("Agent load = " + allHosts.size() + " for 
management server " + msId + " doesn't exceed average system agent load = " + 
avLoad +
                 "; so it doesn't participate in agent rebalancing process");
             return null;
         }
@@ -64,7 +66,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends 
AdapterBase implements
         List<HostVO> directHosts = sc.list();
 
         if (directHosts.isEmpty()) {
-            logger.debug("No direct agents in status " + Status.Up + " exist 
for the management server " + msId +
+            s_logger.debug("No direct agents in status " + Status.Up + " exist 
for the management server " + msId +
                 "; so it doesn't participate in agent rebalancing process");
             return null;
         }
@@ -90,23 +92,23 @@ public class ClusterBasedAgentLoadBalancerPlanner extends 
AdapterBase implements
         int hostsLeft = directHosts.size();
         List<HostVO> hostsToReturn = new ArrayList<HostVO>();
 
-        logger.debug("Management server " + msId + " can give away " + 
hostsToGive + " as it currently owns " + allHosts.size() +
+        s_logger.debug("Management server " + msId + " can give away " + 
hostsToGive + " as it currently owns " + allHosts.size() +
             " and the average agent load in the system is " + avLoad + "; 
finalyzing list of hosts to give away...");
         for (Long cluster : hostToClusterMap.keySet()) {
             List<HostVO> hostsInCluster = hostToClusterMap.get(cluster);
             hostsLeft = hostsLeft - hostsInCluster.size();
             if (hostsToReturn.size() < hostsToGive) {
-                logger.debug("Trying cluster id=" + cluster);
+                s_logger.debug("Trying cluster id=" + cluster);
 
                 if (hostsInCluster.size() > hostsLeftToGive) {
-                    logger.debug("Skipping cluster id=" + cluster + " as it 
has more hosts than we need: " + hostsInCluster.size() + " vs " + 
hostsLeftToGive);
+                    s_logger.debug("Skipping cluster id=" + cluster + " as it 
has more hosts than we need: " + hostsInCluster.size() + " vs " + 
hostsLeftToGive);
                     if (hostsLeft >= hostsLeftToGive) {
                         continue;
                     } else {
                         break;
                     }
                 } else {
-                    logger.debug("Taking all " + hostsInCluster.size() + " 
hosts: " + hostsInCluster + " from cluster id=" + cluster);
+                    s_logger.debug("Taking all " + hostsInCluster.size() + " 
hosts: " + hostsInCluster + " from cluster id=" + cluster);
                     hostsToReturn.addAll(hostsInCluster);
                     hostsLeftToGive = hostsLeftToGive - hostsInCluster.size();
                 }
@@ -115,7 +117,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends 
AdapterBase implements
             }
         }
 
-        logger.debug("Management server " + msId + " is ready to give away " + 
hostsToReturn.size() + " hosts");
+        s_logger.debug("Management server " + msId + " is ready to give away " 
+ hostsToReturn.size() + " hosts");
         return hostsToReturn;
     }
 

Reply via email to