@@ -68,6 +68,7 @@ private static void checkAllHosts(final CheckCompleteHandler completeHandler) {
6868 final CheckStatus checkStatus = new CheckStatus ();
6969 checkStatus .totalCount = allHosts .length ;
7070 checkStatus .completeCount = 0 ;
71+ checkStatus .isCompleted = false ;
7172 for (String host : allHosts ) {
7273 checkHost (host , new CheckCompleteHandler () {
7374 @ Override
@@ -79,8 +80,16 @@ public void complete(boolean isHostConnected) {
7980 if (isHostConnected ) {
8081 checkStatus .isConnected = true ;
8182 }
82- if (checkStatus .completeCount == checkStatus .totalCount ) {
83- LogUtil .i ("== check all hosts has completed totalCount:" + checkStatus .totalCount + " completeCount:" + checkStatus .completeCount );
83+ if (isHostConnected || checkStatus .completeCount == checkStatus .totalCount ) {
84+ synchronized (checkStatus ) {
85+ if (checkStatus .isCompleted ) {
86+ LogUtil .i ("== check all hosts has completed totalCount:" + checkStatus .totalCount + " completeCount:" + checkStatus .completeCount );
87+ return ;
88+ } else {
89+ LogUtil .i ("== check all hosts completed totalCount:" + checkStatus .totalCount + " completeCount:" + checkStatus .completeCount );
90+ checkStatus .isCompleted = true ;
91+ }
92+ }
8493 completeHandler .complete (checkStatus .isConnected );
8594 } else {
8695 LogUtil .i ("== check all hosts not completed totalCount:" + checkStatus .totalCount + " completeCount:" + checkStatus .completeCount );
@@ -119,6 +128,7 @@ private interface CheckCompleteHandler {
119128 private static class CheckStatus {
120129 private int totalCount = 0 ;
121130 private int completeCount = 0 ;
131+ private boolean isCompleted = false ;
122132 private boolean isConnected = false ;
123133 }
124134
0 commit comments