Skip to content

Commit

Permalink
framework: Do not update mshost_peer when mgmt server is Up as it wil…
Browse files Browse the repository at this point in the history
…l be updated by status update
  • Loading branch information
weizhouapache committed Nov 12, 2024
1 parent 48e3211 commit d05c36f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -760,16 +760,7 @@ private void queueNotification(final ClusterManagerMessage msg) {
}

switch (msg.getMessageType()) {
case nodeAdded: {
final List<ManagementServerHostVO> l = msg.getNodes();
if (l != null && l.size() > 0) {
for (final ManagementServerHostVO mshost : l) {
if (mshost.getId() != _mshostId) {
_mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up);
}
}
}
}
case nodeAdded:
break;

case nodeRemoved: {
Expand Down
27 changes: 18 additions & 9 deletions server/src/main/java/com/cloud/server/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -1164,15 +1164,7 @@ public String newStatus(ClusterServicePdu pdu) {
managementServerHostStats.put(hostStatsEntry.getManagementServerHostUuid(), hostStatsEntry);

// Update peer state to Up in mshost_peer
ManagementServerHostVO mgmtServerVo = managementServerHostDao.findByMsid(managementServerNodeId);
if (mgmtServerVo != null) {
msId = mgmtServerVo.getId();
if (msId != hostStatsEntry.getManagementServerHostId()) {
managementServerHostPeerDao.updatePeerInfo(msId, hostStatsEntry.getManagementServerHostId(), hostStatsEntry.getManagementServerRunId(), ManagementServerHost.State.Up);
}
} else {
LOGGER.warn(String.format("Cannot find management server with msid [%s]. Therefore, do not update peer info.", managementServerNodeId));
}
updatePeerInfo(hostStatsEntry);
} catch (JsonParseException e) {
LOGGER.error("Exception in decoding of other MS hosts status from : " + pdu.getSourcePeer());
if (LOGGER.isDebugEnabled()) {
Expand All @@ -1182,6 +1174,23 @@ public String newStatus(ClusterServicePdu pdu) {
return null;
}

private void updatePeerInfo(ManagementServerHostStatsEntry hostStatsEntry) {
// Update msId to id of the management server if msId is same as managementServerNodeId
if (msId == managementServerNodeId) {
ManagementServerHostVO mgmtServerVo = managementServerHostDao.findByMsid(managementServerNodeId);
if (mgmtServerVo != null) {
msId = mgmtServerVo.getId();
} else {
LOGGER.warn(String.format("Cannot find management server with msid [%s]. Therefore, do not update peer info.", managementServerNodeId));
return;
}
}
// Update peer state to Up in mshost_peer
if (msId != hostStatsEntry.getManagementServerHostId()) {
managementServerHostPeerDao.updatePeerInfo(msId, hostStatsEntry.getManagementServerHostId(), hostStatsEntry.getManagementServerRunId(), ManagementServerHost.State.Up);
}
}

@Override
public void onManagementNodeJoined(List<? extends ManagementServerHost> nodeList, long selfNodeId) {
// do nothing, but wait for the status to come through
Expand Down

0 comments on commit d05c36f

Please sign in to comment.