Skip to content

Commit 1fe37de

Browse files
during ms heartbeat, update state to up only when it's down
1 parent 9bb038a commit 1fe37de

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,17 @@ public void update(long id, long runid, Date lastUpdate) {
132132
try {
133133
txn.start();
134134

135-
pstmt = txn.prepareAutoCloseStatement("update mshost set last_update=?, removed=null, alert_count=0, state='Up' where id=? and runid=?");
135+
boolean updateStatetoUp = false;
136+
ManagementServerHostVO msHost = findById(id);
137+
if (msHost != null && State.Down.equals(msHost.getState())) {
138+
updateStatetoUp = true;
139+
}
140+
141+
if (updateStatetoUp) {
142+
pstmt = txn.prepareAutoCloseStatement("update mshost set last_update=?, removed=null, alert_count=0, state='Up' where id=? and runid=?");
143+
} else {
144+
pstmt = txn.prepareAutoCloseStatement("update mshost set last_update=?, removed=null, alert_count=0 where id=? and runid=?");
145+
}
136146
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), lastUpdate));
137147
pstmt.setLong(2, id);
138148
pstmt.setLong(3, runid);

0 commit comments

Comments
 (0)