@@ -125,30 +125,30 @@ public void updateHostStatusCheckDelay(int newDelaySec) {
125125 }
126126
127127 /**
128- * Task wait for the Host to be available to connect to submit {@link StartupCommand}.
128+ * Task waits for the Host to be available to connect to submit {@link StartupCommand}.
129129 * Checks Host status on Management Server cluster and submit {@link StartupCommand} only if there is no lock and
130130 * Host is not {@link Status#Connecting}.
131131 */
132132 public static class HostStatusTask implements Runnable , AsyncSend {
133133 private final Set <Status > operationalStatuses = Set .of (Status .Connecting , Status .Up , Status .Rebalancing );
134134
135- private final Link _link ;
136- private final boolean _forceConnect ;
137- private final Agent _agent ;
138- private final AtomicReference <? extends ScheduledFuture <?>> _futureRef ;
135+ private final Link link ;
136+ private final boolean forceConnect ;
137+ private final Agent agent ;
138+ private final AtomicReference <? extends ScheduledFuture <?>> futureRef ;
139139
140140 public HostStatusTask (Link link , boolean forceConnect , Agent agent ,
141141 AtomicReference <? extends ScheduledFuture <?>> futureRef ) {
142142 logger .debug ("{} created" , this .getClass ().getSimpleName ());
143- _link = link ;
144- _forceConnect = forceConnect ;
145- _agent = agent ;
146- _futureRef = futureRef ;
143+ this . link = link ;
144+ this . forceConnect = forceConnect ;
145+ this . agent = agent ;
146+ this . futureRef = futureRef ;
147147 }
148148
149149 private void cancel () {
150150 logger .debug ("Cancelling future" );
151- Optional .ofNullable (_futureRef .get ())
151+ Optional .ofNullable (futureRef .get ())
152152 .filter (Predicate .not (ScheduledFuture ::isCancelled ))
153153 .ifPresent (future -> future .cancel (true ));
154154 logger .debug ("Cancelled future" );
@@ -165,7 +165,7 @@ public void run() {
165165 }
166166
167167 private void runInternal () {
168- ServerAttache attache = (ServerAttache ) _link .attachment ();
168+ ServerAttache attache = (ServerAttache ) link .attachment ();
169169 if (attache == null || attache .getLink () == null ) {
170170 cancel ();
171171 return ;
@@ -176,8 +176,8 @@ private void runInternal() {
176176 answer = getAgentConnectStatusAnswer (attache );
177177 } catch (IOException e ) {
178178 cancel ();
179- logger .error ("The connection to {} interrupted, restarting the whole process" , _link , e );
180- _agent .getRequestHandler ().submit (() -> _agent .reconnect (_link , null , _forceConnect ));
179+ logger .error ("The connection to {} interrupted, restarting the whole process" , link , e );
180+ agent .getRequestHandler ().submit (() -> agent .reconnect (link , null , forceConnect ));
181181 return ;
182182 }
183183 if (answer == null ) {
@@ -190,24 +190,24 @@ private void runInternal() {
190190 // send startup command here
191191 logger .info ("There is no lock and Host status is {}" , status );
192192 try {
193- sendStartupCommand (_link , _forceConnect );
194- logger .debug ("Sending startup command to {} finished" , _link );
193+ sendStartupCommand ();
194+ logger .debug ("Sending startup command to {} finished" , link );
195195 cancel ();
196196 logger .debug ("Unscheduled {}" , getClass ().getSimpleName ());
197197 } catch (RuntimeException e ) {
198- logger .error ("Failed to send startup command to {}" , _link , e );
198+ logger .error ("Failed to send startup command to {}" , link , e );
199199 } catch (IOException e ) {
200200 cancel ();
201- logger .error ("The connection to {} interrupted, restarting the whole process" , _link , e );
202- _agent .getRequestHandler ().submit (() -> _agent .reconnect (_link , null , _forceConnect ));
201+ logger .error ("The connection to {} interrupted, restarting the whole process" , link , e );
202+ agent .getRequestHandler ().submit (() -> agent .reconnect (link , null , forceConnect ));
203203 }
204204 } else {
205205 logger .info ("There is lock and Host status is {}, will retry later" , status );
206206 }
207207 }
208208
209209 private AgentConnectStatusAnswer getAgentConnectStatusAnswer (ServerAttache attache ) throws IOException {
210- AgentConnectStatusCommand command = _agent .setupAgentConnectStatusCommand (new AgentConnectStatusCommand ());
210+ AgentConnectStatusCommand command = agent .setupAgentConnectStatusCommand (new AgentConnectStatusCommand ());
211211 var commands = new Command []{command };
212212 try {
213213 return send (attache , commands , AgentConnectStatusAnswer .class , DEFAULT_ASYNC_COMMAND_TIMEOUT_SEC );
@@ -218,26 +218,26 @@ private AgentConnectStatusAnswer getAgentConnectStatusAnswer(ServerAttache attac
218218 }
219219 }
220220
221- public void sendStartupCommand (Link link , boolean connectionTransfer ) throws IOException {
221+ public void sendStartupCommand () throws IOException {
222222 ServerAttache attache = (ServerAttache ) link .attachment ();
223223 if (attache == null || attache .getLink () == null ) {
224224 return ;
225225 }
226- ServerResource serverResource = _agent .getResource ();
226+ ServerResource serverResource = agent .getResource ();
227227 StartupCommand [] startup = serverResource .initialize ();
228228 if (ArrayUtils .isEmpty (startup )) {
229229 logger .warn ("No startup commands returned from {}, Startup command sending skipped" , serverResource .getName ());
230230 return ;
231231 }
232- String msHostList = _agent .getPersistentProperty ("host" );
232+ String msHostList = agent .getPersistentProperty ("host" );
233233 // need to downcast StartupCommand[] to Command[], otherwise logger will fail to decode JSON on MS side
234234 Command [] commands = new Command [startup .length ];
235235 for (int i = 0 ; i < startup .length ; i ++) {
236236 StartupCommand command = startup [i ];
237237 commands [i ] = command ;
238- _agent .setupStartupCommand (command );
238+ agent .setupStartupCommand (command );
239239 command .setMSHostList (msHostList );
240- command .setConnectionTransferred (connectionTransfer );
240+ command .setConnectionTransferred (forceConnect );
241241 ThreadContextCommandUtil .setContextInCommand (command );
242242 }
243243 String commandName = commands [0 ].getClass ().getSimpleName ();
@@ -263,29 +263,29 @@ public void sendStartupCommand(Link link, boolean connectionTransfer) throws IOE
263263 AgentConnectStatusAnswer answer = getAgentConnectStatusAnswer (attache );
264264 if (answer == null ) {
265265 logger .warn ("Received empty agent connect status answer, reconnecting" );
266- _agent .getRequestHandler ().submit (() -> _agent .reconnect (link , null , connectionTransfer ));
266+ agent .getRequestHandler ().submit (() -> agent .reconnect (link , null , forceConnect ));
267267 return ;
268268 }
269269 Boolean lockAvailable = answer .isLockAvailable ();
270270 Status status = answer .getHostStatus ();
271271 if (Boolean .TRUE .equals (lockAvailable ) && status != null && operationalStatuses .contains (status )) {
272- logger .info ("Host is in operational state {} on {}" , status , _link );
272+ logger .info ("Host is in operational state {} on {}" , status , link );
273273 } else if (Boolean .FALSE .equals (lockAvailable )) {
274- logger .info ("Host is locked and has state {} on {}" , status , _link );
274+ logger .info ("Host is locked and has state {} on {}" , status , link );
275275 } else {
276- logger .info ("Host is locked and has state {} on {}, reconnecting" , status , _link );
277- _agent .getRequestHandler ().submit (() -> _agent .reconnect (link , null , connectionTransfer ));
276+ logger .info ("Host is locked and has state {} on {}, reconnecting" , status , link );
277+ agent .getRequestHandler ().submit (() -> agent .reconnect (link , null , forceConnect ));
278278 return ;
279279 }
280280 }
281281 if (serverResource instanceof ResourceStatusUpdater ) {
282- ((ResourceStatusUpdater ) serverResource ).registerStatusUpdater (_agent );
282+ ((ResourceStatusUpdater ) serverResource ).registerStatusUpdater (agent );
283283 }
284284
285285 }
286286
287287 public Agent getAgent () {
288- return _agent ;
288+ return agent ;
289289 }
290290 }
291291
0 commit comments