You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2015/08/29 22:06:31 UTC
[34/36] git commit: updated refs/heads/master to cd7218e
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 2bc4f68..440cfc3 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -43,10 +43,6 @@ 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;
@@ -95,10 +91,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
@@ -144,7 +140,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
_sslEngines = new HashMap<String, SSLEngine>(7);
_nodeId = ManagementServerNode.getManagementServerId();
- s_logger.info("Configuring ClusterAgentManagerImpl. management server node id(msid): " + _nodeId);
+ logger.info("Configuring ClusterAgentManagerImpl. management server node id(msid): " + _nodeId);
ClusteredAgentAttache.initialize(this);
@@ -162,8 +158,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
return false;
}
_timer.schedule(new DirectAgentScanTimerTask(), STARTUP_DELAY, ScanInterval.value());
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Scheduled direct agent scan task to run at an interval of " + ScanInterval.value() + " seconds");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Scheduled direct agent scan task to run at an interval of " + ScanInterval.value() + " seconds");
}
// Schedule tasks for agent rebalancing
@@ -177,8 +173,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
public void scheduleHostScanTask() {
_timer.schedule(new DirectAgentScanTimerTask(), 0);
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Scheduled a direct agent scan task");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Scheduled a direct agent scan task");
}
}
@@ -187,8 +183,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
private void scanDirectAgentToLoad() {
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Begin scanning directly connected hosts");
+ if (logger.isTraceEnabled()) {
+ logger.trace("Begin scanning directly connected hosts");
}
// for agents that are self-managed, threshold to be considered as disconnected after pingtimeout
@@ -196,18 +192,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) {
- s_logger.debug("Found " + hosts.size() + " unmanaged direct hosts, processing connect for them...");
+ 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 (s_logger.isInfoEnabled()) {
- s_logger.info(host + " is detected down, but we have a forward attache running, disconnect this one before launching the host");
+ if (logger.isInfoEnabled()) {
+ 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 {
@@ -215,18 +211,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
}
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ")");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ")");
}
loadDirectlyConnectedHost(host, false);
} catch (Throwable e) {
- s_logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ", e);
+ logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ", e);
}
}
}
}
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("End scanning directly connected hosts");
+ if (logger.isTraceEnabled()) {
+ logger.trace("End scanning directly connected hosts");
}
}
@@ -236,7 +232,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
runDirectAgentScanTimerTask();
} catch (Throwable e) {
- s_logger.error("Unexpected exception " + e.getMessage(), e);
+ logger.error("Unexpected exception " + e.getMessage(), e);
}
}
}
@@ -247,7 +243,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
protected AgentAttache createAttache(long id) {
- s_logger.debug("create forwarding ClusteredAgentAttache for " + id);
+ logger.debug("create forwarding ClusteredAgentAttache for " + id);
HostVO host = _hostDao.findById(id);
final AgentAttache attache = new ClusteredAgentAttache(this, id, host.getName());
AgentAttache old = null;
@@ -256,8 +252,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
_agents.put(id, attache);
}
if (old != null) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Remove stale agent attache from current management server");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Remove stale agent attache from current management server");
}
removeAgent(old, Status.Removed);
}
@@ -266,7 +262,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
protected AgentAttache createAttacheForConnect(HostVO host, Link link) {
- s_logger.debug("create ClusteredAgentAttache for " + host.getId());
+ 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;
@@ -282,7 +278,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
protected AgentAttache createAttacheForDirectConnect(Host host, ServerResource resource) {
- s_logger.debug("create ClusteredDirectAgentAttache for " + host.getId());
+ 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) {
@@ -326,8 +322,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
public boolean executeUserRequest(long hostId, Event event) throws AgentUnavailableException {
if (event == Event.AgentDisconnected) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Received agent disconnect event for host " + hostId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Received agent disconnect event for host " + hostId);
}
AgentAttache attache = findAttache(hostId);
if (attache != null) {
@@ -336,7 +332,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
HostTransferMapVO transferVO = _hostTransferDao.findById(hostId);
if (transferVO != null) {
if (transferVO.getFutureOwner() == _nodeId && transferVO.getState() == HostTransferState.TransferStarted) {
- s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " +
+ logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " +
_nodeId);
return true;
}
@@ -346,7 +342,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()) {
- s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId +
+ 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;
}
@@ -369,7 +365,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
return result;
}
} catch (AgentUnavailableException e) {
- s_logger.debug("cannot propagate agent reconnect because agent is not available", e);
+ logger.debug("cannot propagate agent reconnect because agent is not available", e);
return false;
}
@@ -377,32 +373,27 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
public void notifyNodesInCluster(AgentAttache attache) {
- s_logger.debug("Notifying other nodes of to disconnect");
+ 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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Notifying other MS nodes to run host scan task");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Notifying other MS nodes to run host scan task");
}
Command[] cmds = new Command[] {new ScheduleHostScanTaskCommand()};
_clusterMgr.broadcast(0, _gson.toJson(cmds));
}
- 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) + ": " +
+ protected void logD(byte[] bytes, final String msg) {
+ logger.debug("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " +
(Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg);
}
- protected static void logI(byte[] bytes, final String msg) {
- s_logger.info("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " +
+ protected void logI(byte[] bytes, final String msg) {
+ logger.info("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " +
(Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg);
}
@@ -427,7 +418,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
return false;
}
try {
- if (s_logger.isDebugEnabled()) {
+ if (logger.isDebugEnabled()) {
logD(bytes, "Routing to peer");
}
Link.write(ch, new ByteBuffer[] {ByteBuffer.wrap(bytes)}, sslEngine);
@@ -467,7 +458,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
ch.close();
} catch (IOException e) {
- s_logger.warn("Unable to close peer socket connection to " + peerName);
+ logger.warn("Unable to close peer socket connection to " + peerName);
}
}
_peers.remove(peerName);
@@ -483,14 +474,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
prevCh.close();
} catch (Exception e) {
- s_logger.info("[ignored]"
+ 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) {
- s_logger.info("Unable to find peer: " + peerName);
+ logger.info("Unable to find peer: " + peerName);
return null;
}
String ip = ms.getServiceIP();
@@ -513,13 +504,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols()));
Link.doHandshake(ch1, sslEngine, true);
- s_logger.info("SSL: Handshake done");
+ logger.info("SSL: Handshake done");
} catch (Exception e) {
ch1.close();
throw new IOException("SSL: Fail to init SSL! " + e);
}
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Connection to peer opened: " + peerName + ", ip: " + ip);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Connection to peer opened: " + peerName + ", ip: " + ip);
}
_peers.put(peerName, ch1);
_sslEngines.put(peerName, sslEngine);
@@ -528,15 +519,15 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
ch1.close();
} catch (IOException ex) {
- s_logger.error("failed to close failed peer socket: " + ex);
+ logger.error("failed to close failed peer socket: " + ex);
}
- s_logger.warn("Unable to connect to peer management server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e);
+ logger.warn("Unable to connect to peer management server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e);
return null;
}
}
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Found open channel for peer: " + peerName);
+ if (logger.isTraceEnabled()) {
+ logger.trace("Found open channel for peer: " + peerName);
}
return ch;
}
@@ -562,8 +553,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
AgentAttache agent = findAttache(hostId);
if (agent == null || !agent.forForward()) {
if (isHostOwnerSwitched(host)) {
- 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");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Host " + hostId + " has switched to another management server, need to update agent map with a forwarding agent attache");
}
agent = createAttache(hostId);
}
@@ -582,10 +573,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
if (_peers != null) {
for (SocketChannel ch : _peers.values()) {
try {
- s_logger.info("Closing: " + ch.toString());
+ logger.info("Closing: " + ch.toString());
ch.close();
} catch (IOException e) {
- s_logger.info("[ignored] error on closing channel: " +ch.toString(), e);
+ logger.info("[ignored] error on closing channel: " +ch.toString(), e);
}
}
}
@@ -622,7 +613,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()) {
- s_logger.warn("Wrong version for clustered agent request");
+ logger.warn("Wrong version for clustered agent request");
super.doTask(task);
return;
}
@@ -642,7 +633,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
Request req = Request.parse(data);
Command[] cmds = req.getCommands();
CancelCommand cancel = (CancelCommand)cmds[0];
- if (s_logger.isDebugEnabled()) {
+ if (logger.isDebugEnabled()) {
logD(data, "Cancel request received");
}
agent.cancel(cancel.getSequence());
@@ -690,7 +681,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
AgentAttache attache = (AgentAttache)link.attachment();
if (attache != null) {
attache.sendNext(Request.getSequence(data));
- } else if (s_logger.isDebugEnabled()) {
+ } else if (logger.isDebugEnabled()) {
logD(data, "No attache to process " + Request.parse(data).toString());
}
}
@@ -703,11 +694,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
final Response response = Response.parse(data);
AgentAttache attache = findAttache(response.getAgentId());
if (attache == null) {
- s_logger.info("SeqA " + response.getAgentId() + "-" + response.getSequence() + "Unable to find attache to forward " + response.toString());
+ logger.info("SeqA " + response.getAgentId() + "-" + response.getSequence() + "Unable to find attache to forward " + response.toString());
return;
}
if (!attache.processAnswers(response.getSequence(), response)) {
- s_logger.info("SeqA " + attache.getId() + "-" + response.getSequence() + ": Response is not processed: " + response.toString());
+ logger.info("SeqA " + attache.getId() + "-" + response.getSequence() + ": Response is not processed: " + response.toString());
}
}
return;
@@ -726,10 +717,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
public void onManagementNodeLeft(List<? extends ManagementServerHost> nodeList, long selfNodeId) {
for (ManagementServerHost vo : nodeList) {
- s_logger.info("Marking hosts as disconnected on Management server" + vo.getMsid());
+ logger.info("Marking hosts as disconnected on Management server" + vo.getMsid());
long lastPing = (System.currentTimeMillis() >> 10) - getTimeout();
_hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing);
- s_logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid());
+ logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid());
cleanupTransferMap(vo.getMsid());
}
}
@@ -757,7 +748,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
result = rebalanceHost(agentId, currentOwnerId, futureOwnerId);
} catch (Exception e) {
- s_logger.warn("Unable to rebalance host id=" + agentId, e);
+ logger.warn("Unable to rebalance host id=" + agentId, e);
}
}
return result;
@@ -772,14 +763,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
protected volatile boolean cancelled = false;
public AgentLoadBalancerTask() {
- s_logger.debug("Agent load balancer task created");
+ logger.debug("Agent load balancer task created");
}
@Override
public synchronized boolean cancel() {
if (!cancelled) {
cancelled = true;
- s_logger.debug("Agent load balancer task cancelled");
+ logger.debug("Agent load balancer task cancelled");
return super.cancel();
}
return true;
@@ -790,19 +781,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
if (!cancelled) {
startRebalanceAgents();
- if (s_logger.isInfoEnabled()) {
- s_logger.info("The agent load balancer task is now being cancelled");
+ if (logger.isInfoEnabled()) {
+ logger.info("The agent load balancer task is now being cancelled");
}
cancelled = true;
}
} catch (Throwable e) {
- s_logger.error("Unexpected exception " + e.toString(), e);
+ logger.error("Unexpected exception " + e.toString(), e);
}
}
}
public void startRebalanceAgents() {
- s_logger.debug("Management server " + _nodeId + " is asking other peers to rebalance their agents");
+ 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);
@@ -814,16 +805,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
if (!allManagedAgents.isEmpty() && !allMS.isEmpty()) {
avLoad = allManagedAgents.size() / allMS.size();
} else {
- 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() +
+ 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() +
"; number of managed agents is " + allManagedAgents.size());
}
return;
}
if (avLoad == 0L) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("As calculated average load is less than 1, rounding it to 1");
+ if (logger.isDebugEnabled()) {
+ logger.debug("As calculated average load is less than 1, rounding it to 1");
}
avLoad = 1;
}
@@ -837,19 +828,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
break;
} else {
- s_logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + node.getMsid());
+ logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + node.getMsid());
}
}
if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
- s_logger.debug("Found " + hostsToRebalance.size() + " hosts to rebalance from management server " + node.getMsid());
+ logger.debug("Found " + hostsToRebalance.size() + " hosts to rebalance from management server " + node.getMsid());
for (HostVO host : hostsToRebalance) {
long hostId = host.getId();
- s_logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId);
+ logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId);
boolean result = true;
if (_hostTransferDao.findById(hostId) != null) {
- s_logger.warn("Somebody else is already rebalancing host id: " + hostId);
+ logger.warn("Somebody else is already rebalancing host id: " + hostId);
continue;
}
@@ -858,18 +849,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) {
- s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid());
+ logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid());
result = false;
}
} catch (Exception ex) {
- s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid(), ex);
+ 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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Removing mapping from op_host_transfer as it failed to be set to transfer mode");
+ if (logger.isDebugEnabled()) {
+ 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
@@ -879,7 +870,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
}
} else {
- s_logger.debug("Found no hosts to rebalance from the management server " + node.getMsid());
+ logger.debug("Found no hosts to rebalance from the management server " + node.getMsid());
}
}
}
@@ -893,8 +884,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
Command[] cmds = commands.toCommands();
try {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Forwarding " + cmds[0].toString() + " to " + peer);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Forwarding " + cmds[0].toString() + " to " + peer);
}
String peerName = Long.toString(peer);
String cmdStr = _gson.toJson(cmds);
@@ -902,7 +893,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
return answers;
} catch (Exception e) {
- s_logger.warn("Caught exception while talking to " + currentOwnerId, e);
+ logger.warn("Caught exception while talking to " + currentOwnerId, e);
return null;
}
}
@@ -926,8 +917,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
return null;
}
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
}
Command[] cmds = new Command[1];
cmds[0] = new ChangeAgentCommand(agentId, event);
@@ -939,8 +930,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Result for agent change is " + answers[0].getResult());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Result for agent change is " + answers[0].getResult());
}
return answers[0].getResult();
@@ -951,12 +942,12 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
protected void runInContext() {
try {
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Clustered agent transfer scan check, management server id:" + _nodeId);
+ if (logger.isTraceEnabled()) {
+ logger.trace("Clustered agent transfer scan check, management server id:" + _nodeId);
}
synchronized (_agentToTransferIds) {
if (_agentToTransferIds.size() > 0) {
- s_logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer");
+ logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer");
// for (Long hostId : _agentToTransferIds) {
for (Iterator<Long> iterator = _agentToTransferIds.iterator(); iterator.hasNext();) {
Long hostId = iterator.next();
@@ -973,14 +964,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
_hostTransferDao.findActiveHostTransferMapByHostId(hostId, new Date(cutTime.getTime() - rebalanceTimeOut));
if (transferMap == null) {
- s_logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, skipping rebalance for the host");
+ 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()) {
- s_logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host");
+ logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host");
iterator.remove();
_hostTransferDao.completeAgentTransfer(hostId);
continue;
@@ -988,7 +979,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
ManagementServerHostVO ms = _mshostDao.findByMsid(transferMap.getFutureOwner());
if (ms != null && ms.getState() != ManagementServerHost.State.Up) {
- s_logger.debug("Can't transfer host " + hostId + " as it's future owner is not in UP state: " + ms +
+ 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);
@@ -1000,31 +991,31 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
_executor.execute(new RebalanceTask(hostId, transferMap.getInitialOwner(), transferMap.getFutureOwner()));
} catch (RejectedExecutionException ex) {
- s_logger.warn("Failed to submit rebalance task for host id=" + hostId + "; postponing the execution");
+ logger.warn("Failed to submit rebalance task for host id=" + hostId + "; postponing the execution");
continue;
}
} else {
- s_logger.debug("Agent " + hostId + " can't be transfered yet as its request queue size is " + attache.getQueueSize() +
+ 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 (s_logger.isTraceEnabled()) {
- s_logger.trace("Found no agents to be transfered by the management server " + _nodeId);
+ if (logger.isTraceEnabled()) {
+ logger.trace("Found no agents to be transfered by the management server " + _nodeId);
}
}
}
} catch (Throwable e) {
- s_logger.error("Problem with the clustered agent transfer scan check!", e);
+ logger.error("Problem with the clustered agent transfer scan check!", e);
}
}
};
}
private boolean setToWaitForRebalance(final long hostId, long currentOwnerId, long futureOwnerId) {
- s_logger.debug("Adding agent " + hostId + " to the list of agents to transfer");
+ logger.debug("Adding agent " + hostId + " to the list of agents to transfer");
synchronized (_agentToTransferIds) {
return _agentToTransferIds.add(hostId);
}
@@ -1035,7 +1026,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
boolean result = true;
if (currentOwnerId == _nodeId) {
if (!startRebalance(hostId)) {
- s_logger.debug("Failed to start agent rebalancing");
+ logger.debug("Failed to start agent rebalancing");
finishRebalance(hostId, futureOwnerId, Event.RebalanceFailed);
return false;
}
@@ -1046,23 +1037,23 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
} catch (Exception ex) {
- s_logger.warn("Host " + hostId + " failed to connect to the management server " + futureOwnerId + " as a part of rebalance process", ex);
+ logger.warn("Host " + hostId + " failed to connect to the management server " + futureOwnerId + " as a part of rebalance process", ex);
result = false;
}
if (result) {
- s_logger.debug("Successfully transfered host id=" + hostId + " to management server " + futureOwnerId);
+ logger.debug("Successfully transfered host id=" + hostId + " to management server " + futureOwnerId);
finishRebalance(hostId, futureOwnerId, Event.RebalanceCompleted);
} else {
- s_logger.warn("Failed to transfer host id=" + hostId + " to management server " + futureOwnerId);
+ 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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification");
}
AgentAttache attache = findAttache(hostId);
@@ -1071,26 +1062,26 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
}
if (result) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+ if (logger.isDebugEnabled()) {
+ 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 {
- s_logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification");
+ logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification");
}
} catch (Exception ex) {
- s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+ 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) {
- s_logger.debug("Successfully loaded directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+ logger.debug("Successfully loaded directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
" as a part of rebalance process");
} else {
- s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
+ logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId +
" as a part of rebalance process");
}
}
@@ -1101,13 +1092,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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Finishing rebalancing for the agent " + hostId + " with event " + event);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Finishing rebalancing for the agent " + hostId + " with event " + event);
}
AgentAttache attache = findAttache(hostId);
if (attache == null || !(attache instanceof ClusteredAgentAttache)) {
- s_logger.debug("Unable to find forward attache for the host id=" + hostId + ", assuming that the agent disconnected already");
+ logger.debug("Unable to find forward attache for the host id=" + hostId + ", assuming that the agent disconnected already");
_hostTransferDao.completeAgentTransfer(hostId);
return;
}
@@ -1122,7 +1113,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) {
- s_logger.debug("Forwarding request " + requestToTransfer.getSequence() + " held in transfer attache " + hostId + " from the management server " +
+ 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) {
@@ -1132,23 +1123,23 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
requestToTransfer = forwardAttache.getRequestToTransfer();
}
- s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId);
+ logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId);
} else {
failRebalance(hostId);
}
- s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance");
+ logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance");
_hostTransferDao.completeAgentTransfer(hostId);
}
protected void failRebalance(final long hostId) {
try {
- s_logger.debug("Management server " + _nodeId + " failed to rebalance agent " + hostId);
+ logger.debug("Management server " + _nodeId + " failed to rebalance agent " + hostId);
_hostTransferDao.completeAgentTransfer(hostId);
handleDisconnectWithoutInvestigation(findAttache(hostId), Event.RebalanceFailed, true, true);
} catch (Exception ex) {
- s_logger.warn("Failed to reconnect host id=" + hostId + " as a part of failed rebalance task cleanup");
+ logger.warn("Failed to reconnect host id=" + hostId + " as a part of failed rebalance task cleanup");
}
}
@@ -1156,7 +1147,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
HostVO host = _hostDao.findById(hostId);
if (host == null || host.getRemoved() != null) {
- s_logger.warn("Unable to find host record, fail start rebalancing process");
+ logger.warn("Unable to find host record, fail start rebalancing process");
return false;
}
@@ -1166,17 +1157,17 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
handleDisconnectWithoutInvestigation(attache, Event.StartAgentRebalance, true, true);
ClusteredAgentAttache forwardAttache = (ClusteredAgentAttache)createAttache(hostId);
if (forwardAttache == null) {
- s_logger.warn("Unable to create a forward attache for the host " + hostId + " as a part of rebalance process");
+ logger.warn("Unable to create a forward attache for the host " + hostId + " as a part of rebalance process");
return false;
}
- s_logger.debug("Putting agent id=" + hostId + " to transfer mode");
+ logger.debug("Putting agent id=" + hostId + " to transfer mode");
forwardAttache.setTransferMode(true);
_agents.put(hostId, forwardAttache);
} else {
if (attache == null) {
- s_logger.warn("Attache for the agent " + hostId + " no longer exists on management server " + _nodeId + ", can't start host rebalancing");
+ logger.warn("Attache for the agent " + hostId + " no longer exists on management server " + _nodeId + ", can't start host rebalancing");
} else {
- s_logger.warn("Attache for the agent " + hostId + " has request queue size= " + attache.getQueueSize() + " and listener queue size " +
+ 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;
@@ -1213,19 +1204,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
protected void runInContext() {
try {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Rebalancing host id=" + hostId);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Rebalancing host id=" + hostId);
}
rebalanceHost(hostId, currentOwnerId, futureOwnerId);
} catch (Exception e) {
- s_logger.warn("Unable to rebalance host id=" + hostId, e);
+ logger.warn("Unable to rebalance host id=" + hostId, e);
}
}
}
private String handleScheduleHostScanTaskCommand(ScheduleHostScanTaskCommand cmd) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Intercepting resource manager command: " + _gson.toJson(cmd));
+ if (logger.isDebugEnabled()) {
+ logger.debug("Intercepting resource manager command: " + _gson.toJson(cmd));
}
try {
@@ -1233,7 +1224,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
- s_logger.warn("Exception happened while trying to schedule host scan task on mgmt server " + _clusterMgr.getSelfPeerName() +
+ 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;
}
@@ -1260,8 +1251,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
public String dispatch(ClusterServicePdu pdu) {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + pdu.getJsonPackage());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + pdu.getJsonPackage());
}
Command[] cmds = null;
@@ -1269,24 +1260,24 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
cmds = _gson.fromJson(pdu.getJsonPackage(), Command[].class);
} catch (Throwable e) {
assert (false);
- s_logger.error("Excection in gson decoding : ", e);
+ logger.error("Excection in gson decoding : ", e);
}
if (cmds.length == 1 && cmds[0] instanceof ChangeAgentCommand) { // intercepted
ChangeAgentCommand cmd = (ChangeAgentCommand)cmds[0];
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Intercepting command for agent change: agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Intercepting command for agent change: agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
}
boolean result = false;
try {
result = executeAgentUserRequest(cmd.getAgentId(), cmd.getEvent());
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Result is " + result);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Result is " + result);
}
} catch (AgentUnavailableException e) {
- s_logger.warn("Agent is unavailable", e);
+ logger.warn("Agent is unavailable", e);
return null;
}
@@ -1296,21 +1287,21 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
} else if (cmds.length == 1 && cmds[0] instanceof TransferAgentCommand) {
TransferAgentCommand cmd = (TransferAgentCommand)cmds[0];
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Intercepting command for agent rebalancing: agent " + cmd.getAgentId() + " event: " + cmd.getEvent());
+ if (logger.isDebugEnabled()) {
+ 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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Result is " + result);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Result is " + result);
}
} catch (AgentUnavailableException e) {
- s_logger.warn("Agent is unavailable", e);
+ logger.warn("Agent is unavailable", e);
return null;
} catch (OperationTimedoutException e) {
- s_logger.warn("Operation timed out", e);
+ logger.warn("Operation timed out", e);
return null;
}
Answer[] answers = new Answer[1];
@@ -1319,14 +1310,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
} else if (cmds.length == 1 && cmds[0] instanceof PropagateResourceEventCommand) {
PropagateResourceEventCommand cmd = (PropagateResourceEventCommand)cmds[0];
- s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId());
+ 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());
- s_logger.debug("Result is " + result);
+ logger.debug("Result is " + result);
} catch (AgentUnavailableException ex) {
- s_logger.warn("Agent is unavailable", ex);
+ logger.warn("Agent is unavailable", ex);
return null;
}
@@ -1341,30 +1332,30 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
try {
long startTick = System.currentTimeMillis();
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Dispatch -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage());
+ if (logger.isDebugEnabled()) {
+ 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 (s_logger.isDebugEnabled()) {
- s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
+ if (logger.isDebugEnabled()) {
+ logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
(System.currentTimeMillis() - startTick) + " ms, return result: " + jsonReturn);
}
return jsonReturn;
} else {
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
+ if (logger.isDebugEnabled()) {
+ logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " +
(System.currentTimeMillis() - startTick) + " ms, return null result");
}
}
} catch (AgentUnavailableException e) {
- s_logger.warn("Agent is unavailable", e);
+ logger.warn("Agent is unavailable", e);
} catch (OperationTimedoutException e) {
- s_logger.warn("Timed Out", e);
+ logger.warn("Timed Out", e);
}
return null;
@@ -1389,8 +1380,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
protected void runInContext() {
try {
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Agent rebalance task check, management server id:" + _nodeId);
+ if (logger.isTraceEnabled()) {
+ 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
@@ -1408,18 +1399,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
if (allHostsCount > 0.0) {
double load = managedHostsCount / allHostsCount;
if (load >= ConnectedAgentThreshold.value()) {
- s_logger.debug("Scheduling agent rebalancing task as the average agent load " + load + " is more than the threshold " +
+ logger.debug("Scheduling agent rebalancing task as the average agent load " + load + " is more than the threshold " +
ConnectedAgentThreshold.value());
scheduleRebalanceAgents();
_agentLbHappened = true;
} else {
- s_logger.debug("Not scheduling agent rebalancing task as the averages load " + load + " is less than the threshold " +
+ logger.debug("Not scheduling agent rebalancing task as the averages load " + load + " is less than the threshold " +
ConnectedAgentThreshold.value());
}
}
}
} catch (Throwable e) {
- s_logger.error("Problem with the clustered agent transfer scan check!", e);
+ logger.error("Problem with the clustered agent transfer scan check!", e);
}
}
};
@@ -1428,13 +1419,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
@Override
public void rescan() {
// schedule a scan task immediately
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Scheduling a host scan task");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Scheduling a host scan task");
}
// schedule host scan task on current MS
scheduleHostScanTask();
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Notifying all peer MS to schedule host scan task");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Notifying all peer MS to schedule host scan task");
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 254f1bf..f5c699b 100644
--- a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
+++ b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
@@ -27,7 +27,6 @@ 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;
@@ -41,7 +40,6 @@ 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;
@@ -54,7 +52,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
List<HostVO> allHosts = sc.list();
if (allHosts.size() <= avLoad) {
- s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad +
+ 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;
}
@@ -66,7 +64,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
List<HostVO> directHosts = sc.list();
if (directHosts.isEmpty()) {
- s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId +
+ 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;
}
@@ -92,23 +90,23 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
int hostsLeft = directHosts.size();
List<HostVO> hostsToReturn = new ArrayList<HostVO>();
- s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() +
+ 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) {
- s_logger.debug("Trying cluster id=" + cluster);
+ logger.debug("Trying cluster id=" + cluster);
if (hostsInCluster.size() > hostsLeftToGive) {
- s_logger.debug("Skipping cluster id=" + cluster + " as it has more hosts than we need: " + hostsInCluster.size() + " vs " + hostsLeftToGive);
+ 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 {
- s_logger.debug("Taking all " + hostsInCluster.size() + " hosts: " + hostsInCluster + " from cluster id=" + cluster);
+ logger.debug("Taking all " + hostsInCluster.size() + " hosts: " + hostsInCluster + " from cluster id=" + cluster);
hostsToReturn.addAll(hostsInCluster);
hostsLeftToGive = hostsLeftToGive - hostsInCluster.size();
}
@@ -117,7 +115,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
}
}
- s_logger.debug("Management server " + msId + " is ready to give away " + hostsToReturn.size() + " hosts");
+ logger.debug("Management server " + msId + " is ready to give away " + hostsToReturn.size() + " hosts");
return hostsToReturn;
}