Skip to content

Commit c88c5b5

Browse files
reconnect lock fix
1 parent a2dc66c commit c88c5b5

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public int value() {
176176
long pingInterval = 0;
177177
AtomicInteger commandsInProgress = new AtomicInteger(0);
178178

179-
private static final AtomicBoolean RECONNECT_LOCK = new AtomicBoolean(false);
179+
private final AtomicBoolean reconnectLock = new AtomicBoolean(false);
180180
boolean reconnectAllowed = true;
181181

182182
//For time sensitive task, e.g. PingTask
@@ -626,7 +626,7 @@ protected String selectReconnectionHost(String preferredHost, Link link) {
626626
* this is only "switch Management Server", it does not perform full Host Connect process.
627627
*/
628628
protected void reconnect(Link link, String preferredHost, boolean forceReconnect) {
629-
if (!RECONNECT_LOCK.compareAndSet(false, true)) {
629+
if (!reconnectLock.compareAndSet(false, true)) {
630630
logger.warn("Reconnect is already running, exiting");
631631
return;
632632
}
@@ -691,7 +691,7 @@ protected void reconnect(Link link, String preferredHost, boolean forceReconnect
691691
skipTimeoutRef.set(true);
692692
}
693693
}
694-
if(!skipTimeoutRef.get()) {
694+
if (!skipTimeoutRef.get()) {
695695
shell.getBackoffAlgorithm().waitBeforeRetry();
696696
}
697697
host = shell.getNextHost();
@@ -703,7 +703,7 @@ protected void reconnect(Link link, String preferredHost, boolean forceReconnect
703703
String msg = String.format("Connected to the host: %s (%s)", shell.getConnectedHost(), this.link);
704704
logger.info(msg);
705705
} finally {
706-
RECONNECT_LOCK.set(false);
706+
reconnectLock.set(false);
707707
logger.debug("Removed reconnect lock");
708708
}
709709
}
@@ -763,7 +763,7 @@ private void logReconnectionFailure(Exception e, String hostLog) {
763763
.map(IOException::getMessage)
764764
.filter(BROKEN_PIPE_MSG::equalsIgnoreCase)
765765
.isPresent();
766-
if(rejectedByMs) {
766+
if (rejectedByMs) {
767767
logger.warn("Attempted to re-connect to {}, but rejected" +
768768
" due to 'agent.max.concurrent.new.connections' reached limit," +
769769
" will try again", hostLog, e);

0 commit comments

Comments
 (0)