Skip to content

Commit d4c9ea9

Browse files
committed
Fixup
1 parent 6baebc9 commit d4c9ea9

File tree

14 files changed

+148
-115
lines changed

14 files changed

+148
-115
lines changed

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 53 additions & 41 deletions
Large diffs are not rendered by default.

engine/orchestration/src/main/java/com/cloud/agent/manager/ClusteredAgentManagerImpl.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ public boolean executeUserRequest(final long hostId, final Event event) throws A
341341
// don't process disconnect if the disconnect came for the host via delayed cluster notification,
342342
// but the host has already reconnected to the current management server
343343
if (!attache.forForward()) {
344-
logger.debug("Not processing {} event for the host id={} as the host is directly connected to the current management server {}", Event.AgentDisconnected, hostId, _nodeId);
344+
logger.debug(
345+
"Not processing {} event for the host [id: {}, name: {}] as the host is directly connected to the current management server {}",
346+
Event.AgentDisconnected, hostId, attache.getName(), _nodeId);
345347
return true;
346348
}
347349

@@ -715,12 +717,12 @@ public void onManagementNodeJoined(final List<? extends ManagementServerHost> no
715717
@Override
716718
public void onManagementNodeLeft(final List<? extends ManagementServerHost> nodeList, final long selfNodeId) {
717719
for (final ManagementServerHost vo : nodeList) {
718-
logger.info("Marking hosts as disconnected on Management server {}", vo.getMsid());
720+
logger.info("Marking hosts as disconnected on Management server {}", vo);
719721
final long lastPing = (System.currentTimeMillis() >> 10) - mgmtServiceConf.getTimeout();
720722
_hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing);
721723
outOfBandManagementDao.expireServerOwnership(vo.getMsid());
722724
haConfigDao.expireServerOwnership(vo.getMsid());
723-
logger.info("Deleting entries from op_host_transfer table for Management server {}", vo.getMsid());
725+
logger.info("Deleting entries from op_host_transfer table for Management server {}", vo);
724726
cleanupTransferMap(vo.getMsid());
725727
}
726728
}
@@ -827,7 +829,7 @@ public void startRebalanceAgents() {
827829
}
828830

829831
if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) {
830-
logger.debug("Found {} hosts to rebalance from management server {}", hostsToRebalance.size(), node.getMsid());
832+
logger.debug("Found {} hosts to rebalance from management server {}", hostsToRebalance.size(), node);
831833
for (final HostVO host : hostsToRebalance) {
832834
final long hostId = host.getId();
833835
logger.debug("Asking management server {} to give away host id={}", node, host);
@@ -1032,29 +1034,29 @@ protected boolean rebalanceHost(final long hostId, final long currentOwnerId, fi
10321034
} else if (futureOwnerId == _nodeId) {
10331035
final HostVO host = _hostDao.findById(hostId);
10341036
try {
1035-
logger.debug("Disconnecting host {}({}) as a part of rebalance process without notification", host.getId(), host.getName());
1037+
logger.debug("Disconnecting host {} as a part of rebalance process without notification", host);
10361038

10371039
final AgentAttache attache = findAttache(hostId);
10381040
if (attache != null) {
10391041
result = handleDisconnect(attache, Event.AgentDisconnected, false, false, true);
10401042
}
10411043

10421044
if (result) {
1043-
logger.debug("Loading directly connected host {}({}) to the management server {} as a part of rebalance process", host.getId(), host.getName(), _nodeId);
1045+
logger.debug("Loading directly connected host {} to the management server {} as a part of rebalance process", host, _nodeId);
10441046
result = loadDirectlyConnectedHost(host, true);
10451047
} else {
1046-
logger.warn("Failed to disconnect {}({}) as a part of rebalance process without notification" + host.getId(), host.getName());
1048+
logger.warn("Failed to disconnect {} as a part of rebalance process without notification", host);
10471049
}
10481050

10491051
} catch (final Exception ex) {
1050-
logger.warn("Failed to load directly connected host {}({}) to the management server {} a part of rebalance process without notification", host.getId(), host.getName(), _nodeId, ex);
1052+
logger.warn("Failed to load directly connected host {} to the management server {} a part of rebalance process without notification", host, _nodeId, ex);
10511053
result = false;
10521054
}
10531055

10541056
if (result) {
1055-
logger.debug("Successfully loaded directly connected host {}({}) to the management server {} a part of rebalance process without notification", host.getId(), host.getName(), _nodeId);
1057+
logger.debug("Successfully loaded directly connected host {} to the management server {} a part of rebalance process without notification", host, _nodeId);
10561058
} else {
1057-
logger.warn("Failed to load directly connected host {}({}) to the management server {} a part of rebalance process without notification", host.getId(), host.getName(), _nodeId);
1059+
logger.warn("Failed to load directly connected host {} to the management server {} a part of rebalance process without notification", host, _nodeId);
10581060
}
10591061
}
10601062

@@ -1126,18 +1128,18 @@ protected boolean startRebalance(final long hostId) {
11261128
handleDisconnectWithoutInvestigation(attache, Event.StartAgentRebalance, true, true);
11271129
final ClusteredAgentAttache forwardAttache = (ClusteredAgentAttache)createAttache(host);
11281130
if (forwardAttache == null) {
1129-
logger.warn("Unable to create a forward attache for the host {} as a part of rebalance process", hostId);
1131+
logger.warn("Unable to create a forward attache for the host {} as a part of rebalance process", host);
11301132
return false;
11311133
}
1132-
logger.debug("Putting agent id={} to transfer mode", hostId);
1134+
logger.debug("Putting agent {} to transfer mode", host);
11331135
forwardAttache.setTransferMode(true);
11341136
_agents.put(hostId, forwardAttache);
11351137
} else {
11361138
if (attache == null) {
1137-
logger.warn("Attache for the agent {} no longer exists on management server, can't start host rebalancing", hostId, _nodeId);
1139+
logger.warn("Attache for the agent {} no longer exists on management server, can't start host rebalancing", host, _nodeId);
11381140
} else {
11391141
logger.warn("Attache for the agent {} has request queue size= {} and listener queue size {}, can't start host rebalancing",
1140-
hostId, attache.getQueueSize(), attache.getNonRecurringListenersSize());
1142+
host, attache.getQueueSize(), attache.getNonRecurringListenersSize());
11411143
}
11421144
return false;
11431145
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineHostPodVO.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.cloud.utils.NumbersUtil;
3939
import com.cloud.utils.db.GenericDao;
4040
import com.cloud.utils.db.StateMachine;
41+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
4142

4243
@Entity
4344
@Table(name = "host_pod_ref")
@@ -246,4 +247,11 @@ public Date getLastUpdated() {
246247
public State getState() {
247248
return state;
248249
}
250+
251+
@Override
252+
public String toString() {
253+
return String.format("EngineHostPod %s",
254+
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
255+
this, "id", "name", "uuid"));
256+
}
249257
}

engine/schema/src/main/java/com/cloud/dc/HostPodVO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.cloud.org.Grouping;
3232
import com.cloud.utils.NumbersUtil;
3333
import com.cloud.utils.db.GenericDao;
34+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
3435

3536
@Entity
3637
@Table(name = "host_pod_ref")
@@ -197,4 +198,10 @@ public String getUuid() {
197198
public void setUuid(String uuid) {
198199
this.uuid = uuid;
199200
}
201+
202+
@Override
203+
public String toString() {
204+
return String.format("HostPod %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
205+
this, "id", "name", "uuid"));
206+
}
200207
}

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/store/TemplateObject.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,4 +596,12 @@ public Date getUpdated() {
596596
public boolean isFollowRedirects() {
597597
return followRedirects;
598598
}
599+
600+
@Override
601+
public String toString() {
602+
return "VolumeObject{" +
603+
"templateVO=" + getImage() +
604+
", dataStore=" + getDataStore() +
605+
'}';
606+
}
599607
}

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ public boolean isFollowRedirects() {
948948
@Override
949949
public String toString() {
950950
return "VolumeObject{" +
951-
"volumeVO=" + volumeVO +
952-
", dataStore=" + dataStore +
951+
"volumeVO=" + getVolume() +
952+
", dataStore=" + getDataStore() +
953953
'}';
954954
}
955955
}

framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,11 @@ public void broadcast(final long agentId, final String cmds) {
381381
}
382382
try {
383383
if (logger.isDebugEnabled()) {
384-
logger.debug("Forwarding " + cmds + " to " + peer.getMsid());
384+
logger.debug("Forwarding {} to {}", cmds, peer);
385385
}
386386
executeAsync(peerName, agentId, cmds, true);
387387
} catch (final Exception e) {
388-
logger.warn("Caught exception while talking to " + peer.getMsid());
388+
logger.warn("Caught exception while talking to {}", peer);
389389
}
390390
}
391391
}
@@ -409,11 +409,11 @@ public void publishStatus(final String status) {
409409
final String peerName = Long.toString(peer.getMsid());
410410
try {
411411
if (logger.isDebugEnabled()) {
412-
logger.debug("Forwarding " + status + " to " + peer.getMsid());
412+
logger.debug("Forwarding {} to {}", status, peer);
413413
}
414414
sendStatus(peerName, status);
415415
} catch (final Exception e) {
416-
String msg = String.format("Caught exception while talking to %d", peer.getMsid());
416+
String msg = String.format("Caught exception while talking to %s", peer);
417417
logger.warn(msg);
418418
logger.debug(msg, e);
419419
}
@@ -504,7 +504,7 @@ public void notifyNodeJoined(final List<ManagementServerHostVO> nodeList) {
504504
logger.debug("Notify management server node join to listeners.");
505505

506506
for (final ManagementServerHostVO mshost : nodeList) {
507-
logger.debug("Joining node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid());
507+
logger.debug("Joining node, IP: {}, ms: {}", mshost.getServiceIP(), mshost);
508508
}
509509
}
510510

@@ -524,7 +524,7 @@ public void notifyNodeLeft(final List<ManagementServerHostVO> nodeList) {
524524

525525
for (final ManagementServerHostVO mshost : nodeList) {
526526
if (logger.isDebugEnabled()) {
527-
logger.debug("Leaving node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid());
527+
logger.debug("Leaving node, IP: {}, ms: {}", mshost.getServiceIP(), mshost);
528528
}
529529
cancelClusterRequestToPeer(String.valueOf(mshost.getMsid()));
530530
}
@@ -817,15 +817,14 @@ private void initPeerScan() {
817817
if (logger.isInfoEnabled()) {
818818
logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp");
819819
for (final ManagementServerHostVO host : inactiveList) {
820-
logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() +
821-
", version: " + host.getVersion());
820+
logger.info("management server node ms: {}, service ip: {}, version: {}", host, host.getServiceIP(), host.getVersion());
822821
}
823822
}
824823

825824
final List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>();
826825
for (final ManagementServerHostVO host : inactiveList) {
827826
if (!pingManagementNode(host)) {
828-
logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable");
827+
logger.warn("Management node {} is detected inactive by timestamp and also not pingable", host);
829828
downHostList.add(host);
830829
}
831830
}
@@ -870,23 +869,25 @@ private void peerScan() throws ActiveFencingException {
870869
if (current == null) {
871870
if (entry.getKey().longValue() != _mshostId.longValue()) {
872871
if (logger.isDebugEnabled()) {
873-
logger.debug("Detected management node left, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP());
872+
logger.debug("Detected management node left {}, nodeIP:{}",
873+
entry.getValue(), entry.getValue().getServiceIP());
874874
}
875875
removedNodeList.add(entry.getValue());
876876
}
877877
} else {
878878
if (current.getRunid() == 0) {
879879
if (entry.getKey().longValue() != _mshostId.longValue()) {
880880
if (logger.isDebugEnabled()) {
881-
logger.debug("Detected management node left because of invalidated session, id:" + entry.getKey() + ", nodeIP:" +
882-
entry.getValue().getServiceIP());
881+
logger.debug("Detected management node left because of invalidated session {}, nodeIP:{}",
882+
entry.getValue(), entry.getValue().getServiceIP());
883883
}
884884
invalidatedNodeList.add(entry.getValue());
885885
}
886886
} else {
887887
if (entry.getValue().getRunid() != current.getRunid()) {
888888
if (logger.isDebugEnabled()) {
889-
logger.debug("Detected management node left and rejoined quickly, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP());
889+
logger.debug("Detected management node left and rejoined quickly {}, nodeIP:{}",
890+
entry.getValue(), entry.getValue().getServiceIP());
890891
}
891892

892893
entry.getValue().setRunid(current.getRunid());
@@ -921,15 +922,15 @@ private void peerScan() throws ActiveFencingException {
921922
while (it.hasNext()) {
922923
final ManagementServerHostVO mshost = it.next();
923924
if (!pingManagementNode(mshost)) {
924-
logger.warn("Management node " + mshost.getId() + " is detected inactive by timestamp and also not pingable");
925+
logger.warn("Management node {} is detected inactive by timestamp and also not pingable", mshost);
925926
_activePeers.remove(mshost.getId());
926927
try {
927928
JmxUtil.unregisterMBean("ClusterManager", "Node " + mshost.getId());
928929
} catch (final Exception e) {
929930
logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString());
930931
}
931932
} else {
932-
logger.info("Management node " + mshost.getId() + " is detected inactive by timestamp but is pingable");
933+
logger.info("Management node {} is detected inactive by timestamp but is pingable", mshost);
933934
it.remove();
934935
}
935936
}
@@ -945,7 +946,7 @@ private void peerScan() throws ActiveFencingException {
945946
_activePeers.put(mshost.getId(), mshost);
946947

947948
if (logger.isDebugEnabled()) {
948-
logger.debug("Detected management node joined, id:" + mshost.getId() + ", nodeIP:" + mshost.getServiceIP());
949+
logger.debug("Detected management node joined, {}, nodeIP:{}", mshost, mshost.getServiceIP());
949950
}
950951
newNodeList.add(mshost);
951952

@@ -1011,13 +1012,13 @@ public ManagementServerHostVO doInTransaction(final TransactionStatus status) {
10111012
mshost.setUuid(UUID.randomUUID().toString());
10121013
_mshostDao.persist(mshost);
10131014
if (logger.isInfoEnabled()) {
1014-
logger.info("New instance of management server msid " + _msId + ", runId " + _runId + " is being started");
1015+
logger.info("New instance of management server {}, runId {} is being started", mshost, _runId);
10151016
}
10161017
} else {
10171018
_mshostDao.update(mshost.getId(), _runId, NetUtils.getCanonicalHostName(), version, _clusterNodeIP, _currentServiceAdapter.getServicePort(),
10181019
DateUtil.currentGMTTime());
10191020
if (logger.isInfoEnabled()) {
1020-
logger.info("Management server " + _msId + ", runId " + _runId + " is being started");
1021+
logger.info("Management server {}, runId {} is being started", mshost, _runId);
10211022
}
10221023
}
10231024

@@ -1028,7 +1029,7 @@ public ManagementServerHostVO doInTransaction(final TransactionStatus status) {
10281029
_mshost = mshost;
10291030
_mshostId = mshost.getId();
10301031
if (logger.isInfoEnabled()) {
1031-
logger.info("Management server (host id : {}) is being started at {}:{}", _mshost, _clusterNodeIP, _currentServiceAdapter.getServicePort());
1032+
logger.info("Management server (host : {}) is being started at {}:{}", _mshost, _clusterNodeIP, _currentServiceAdapter.getServicePort());
10321033
}
10331034

10341035
_mshostPeerDao.clearPeerInfo(_mshostId);
@@ -1048,7 +1049,7 @@ public ManagementServerHostVO doInTransaction(final TransactionStatus status) {
10481049
@DB
10491050
public boolean stop() {
10501051
if (logger.isInfoEnabled()) {
1051-
logger.info("Stopping Cluster manager, msid : {}, runId : {}, host : {}",_msId, _runId, _mshost);
1052+
logger.info("Stopping Cluster manager, msid : {}, runId : {}, host : {}", _msId, _runId, _mshost);
10521053
}
10531054

10541055
if (_mshostId != null) {

plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public boolean recover(Host r) throws HARecoveryException {
7878
}
7979
} catch (Exception e){
8080
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
81-
throw new HARecoveryException(" OOBM service is not configured or enabled for this host " + r, e);
81+
throw new HARecoveryException(String.format(" OOBM service is not configured or enabled for this host %s", r), e);
8282
}
8383
}
8484

@@ -95,7 +95,7 @@ public boolean fence(Host r) throws HAFenceException {
9595
}
9696
} catch (Exception e){
9797
logger.warn("OOBM service is not configured or enabled for this host {} error is {}", r, e.getMessage());
98-
throw new HAFenceException("OBM service is not configured or enabled for this host " + r.getName() , e);
98+
throw new HAFenceException(String.format("OBM service is not configured or enabled for this host %s", r.getName()), e);
9999
}
100100
}
101101

0 commit comments

Comments
 (0)