Skip to content

Commit c7f61ba

Browse files
Fix cutoff time in agent connections monitor thread
1 parent 1e5fe02 commit c7f61ba

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,25 +1947,19 @@ protected void runInContext() {
19471947
logger.trace("Agent New Connections Monitor is started.");
19481948
final int cleanupTime = Wait.value();
19491949
Set<Map.Entry<String, Long>> entrySet = newAgentConnections.entrySet();
1950-
long cutOff = System.currentTimeMillis() - (cleanupTime * 60 * 1000L);
1951-
if (logger.isDebugEnabled()) {
1952-
List<String> expiredConnections = newAgentConnections.entrySet()
1953-
.stream()
1954-
.filter(e -> e.getValue() <= cutOff)
1955-
.map(Map.Entry::getKey)
1956-
.collect(Collectors.toList());
1957-
logger.debug("Currently {} active new connections, of which {} have expired - {}",
1958-
entrySet.size(),
1959-
expiredConnections.size(),
1960-
StringUtils.join(expiredConnections));
1961-
}
1962-
for (Map.Entry<String, Long> entry : entrySet) {
1963-
if (entry.getValue() <= cutOff) {
1964-
if (logger.isTraceEnabled()) {
1965-
logger.trace("Cleaning up new agent connection for {}", entry.getKey());
1966-
}
1967-
newAgentConnections.remove(entry.getKey());
1968-
}
1950+
long cutOff = System.currentTimeMillis() - (cleanupTime * 1000L);
1951+
List<String> expiredConnections = newAgentConnections.entrySet()
1952+
.stream()
1953+
.filter(e -> e.getValue() <= cutOff)
1954+
.map(Map.Entry::getKey)
1955+
.collect(Collectors.toList());
1956+
logger.debug("Currently {} active new connections, of which {} have expired - {}",
1957+
entrySet.size(),
1958+
expiredConnections.size(),
1959+
StringUtils.join(expiredConnections));
1960+
for (String connection : expiredConnections) {
1961+
logger.trace("Cleaning up new agent connection for {}", connection);
1962+
newAgentConnections.remove(connection);
19691963
}
19701964
}
19711965
}

0 commit comments

Comments
 (0)