Skip to content

Commit 311706e

Browse files
author
klaus.freitas.scclouds
committed
fixing mistakes
1 parent 8641c3d commit 311706e

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ public void run() {
269269

270270
public void start() {
271271
if (!_resource.start()) {
272-
logger.error("Unable to start the resource: {}", () -> _resource.getName());
273-
throw new CloudRuntimeException("Unable to start the resource: {}" + _resource.getName());
272+
logger.error("Unable to start the resource: {}", _resource.getName());
273+
throw new CloudRuntimeException("Unable to start the resource: " + _resource.getName());
274274
}
275275

276276
_keystoreSetupPath = Script.findScript("scripts/util/", KeyStoreUtils.KS_SETUP_SCRIPT);
@@ -286,7 +286,7 @@ public void start() {
286286
try {
287287
_connection.start();
288288
} catch (final NioConnectionException e) {
289-
logger.warn("NIO Connection Exception {}", () -> e);
289+
logger.warn("NIO Connection Exception {}", e);
290290
logger.info("Attempted to connect to the server, but received an unexpected exception, trying again...");
291291
}
292292
while (!_connection.isStartup()) {
@@ -322,7 +322,7 @@ public void stop(final String reason, final String detail) {
322322
_link.send(req.toBytes());
323323
}
324324
} catch (final ClosedChannelException e) {
325-
logger.warn("Unable to send: {}" + cmd.toString());
325+
logger.warn("Unable to send: {}", cmd.toString());
326326
} catch (final Exception e) {
327327
logger.warn("Unable to send: {} due to exception: {}", cmd.toString(), e);
328328
}
@@ -422,7 +422,7 @@ public void triggerUpdate() {
422422
try {
423423
_link.send(request.toBytes());
424424
} catch (final ClosedChannelException e) {
425-
logger.warn("Unable to send ping update: {}", () -> request.toString());
425+
logger.warn("Unable to send ping update: {}", request.toString());
426426
}
427427
}
428428

@@ -467,12 +467,12 @@ public void sendStartup(final Link link) {
467467
final Request request = new Request(_id != null ? _id : -1, -1, commands, false, false);
468468
request.setSequence(getNextSequence());
469469

470-
logger.debug("Sending Startup: {}", () -> request.toString());
470+
logger.debug("Sending Startup: {}", request.toString());
471471
lockStartupTask(link);
472472
try {
473473
link.send(request.toBytes());
474474
} catch (final ClosedChannelException e) {
475-
logger.warn("Unable to send request: {}", () -> request.toString());
475+
logger.warn("Unable to send request: {}", request.toString());
476476
}
477477

478478
if (_resource instanceof ResourceStatusUpdater) {
@@ -532,7 +532,7 @@ protected void reconnect(final Link link) {
532532

533533
_resource.disconnected();
534534

535-
logger.info("Lost connection to host: {}. Attempting reconnection while we still have {} commands in progress.", () -> _shell.getConnectedHost(), () -> _inProgress.get());
535+
logger.info("Lost connection to host: {}. Attempting reconnection while we still have {} commands in progress.", _shell.getConnectedHost(), _inProgress.get());
536536

537537
_connection.stop();
538538

@@ -564,7 +564,7 @@ protected void reconnect(final Link link) {
564564
_shell.getBackoffAlgorithm().waitBeforeRetry();
565565
} while (!_connection.isStartup());
566566
_shell.updateConnectedHost();
567-
logger.info("Connected to the host: " + _shell.getConnectedHost());
567+
logger.info("Connected to the host: {}", _shell.getConnectedHost());
568568
}
569569

570570
public void processStartupAnswer(final Answer answer, final Response response, final Link link) {
@@ -579,15 +579,15 @@ public void processStartupAnswer(final Answer answer, final Response response, f
579579
}
580580
final StartupAnswer startup = (StartupAnswer)answer;
581581
if (!startup.getResult()) {
582-
logger.error("Not allowed to connect to the server: {}", () -> answer.getDetails());
582+
logger.error("Not allowed to connect to the server: {}", answer.getDetails());
583583
System.exit(1);
584584
}
585585
if (cancelled) {
586586
logger.warn("Threw away a startup answer because we're reconnecting.");
587587
return;
588588
}
589589

590-
logger.info("Process agent startup answer, agent id = {}", () -> startup.getHostId());
590+
logger.info("Process agent startup answer, agent id = {}", startup.getHostId());
591591

592592
setId(startup.getHostId());
593593
_pingInterval = (long)startup.getPingInterval() * 1000; // change to ms.
@@ -597,7 +597,7 @@ public void processStartupAnswer(final Answer answer, final Response response, f
597597

598598
_ugentTaskPool.setKeepAliveTime(2 * _pingInterval, TimeUnit.MILLISECONDS);
599599

600-
logger.info("Startup Response Received: agent id = {}", () -> getId());
600+
logger.info("Startup Response Received: agent id = {}", getId());
601601
}
602602

603603
protected void processRequest(final Request request, final Link link) {
@@ -623,7 +623,7 @@ protected void processRequest(final Request request, final Link link) {
623623
}
624624
requestLogged = true;
625625
}
626-
logger.debug("Processing command: {}", () -> cmd.toString());
626+
logger.debug("Processing command: {}", cmd.toString());
627627
}
628628

629629
if (cmd instanceof CronCommand) {
@@ -632,15 +632,15 @@ protected void processRequest(final Request request, final Link link) {
632632
answer = new Answer(cmd, true, null);
633633
} else if (cmd instanceof ShutdownCommand) {
634634
final ShutdownCommand shutdown = (ShutdownCommand)cmd;
635-
logger.debug("Received shutdownCommand, due to: {}", () -> shutdown.getReason());
635+
logger.debug("Received shutdownCommand, due to: {}", shutdown.getReason());
636636
cancelTasks();
637637
if (shutdown.isRemoveHost()) {
638638
cleanupAgentZoneProperties();
639639
}
640640
_reconnectAllowed = false;
641641
answer = new Answer(cmd, true, null);
642642
} else if (cmd instanceof ReadyCommand && ((ReadyCommand)cmd).getDetails() != null) {
643-
logger.debug("Not ready to connect to mgt server: {}", () -> ((ReadyCommand)cmd).getDetails());
643+
logger.debug("Not ready to connect to mgt server: {}", ((ReadyCommand)cmd).getDetails());
644644
System.exit(1);
645645
return;
646646
} else if (cmd instanceof MaintainCommand) {
@@ -658,7 +658,7 @@ protected void processRequest(final Request request, final Link link) {
658658
}
659659

660660
if (answer == null) {
661-
logger.warn("No handler found to process cmd: {}", () -> cmd.toString());
661+
logger.warn("No handler found to process cmd: {}", cmd.toString());
662662
answer = new AgentControlAnswer(cmd);
663663
}
664664
} else if (cmd instanceof SetupKeyStoreCommand && ((SetupKeyStoreCommand) cmd).isHandleByAgent()) {
@@ -681,7 +681,7 @@ protected void processRequest(final Request request, final Link link) {
681681
_inProgress.decrementAndGet();
682682
}
683683
if (answer == null) {
684-
logger.debug("Response: unsupported command {}", () -> cmd.toString());
684+
logger.debug("Response: unsupported command {}", cmd.toString());
685685
answer = Answer.createUnsupportedCommandAnswer(cmd);
686686
}
687687
}
@@ -827,7 +827,7 @@ private Answer setupManagementServerList(final SetupMSListCommand cmd) {
827827

828828
public void processResponse(final Response response, final Link link) {
829829
final Answer answer = response.getAnswer();
830-
logger.debug("Received response: {}", () -> response.toString());
830+
logger.debug("Received response: {}", response.toString());
831831
if (answer instanceof StartupAnswer) {
832832
processStartupAnswer(answer, response, link);
833833
} else if (answer instanceof AgentControlAnswer) {
@@ -867,21 +867,21 @@ public void processOtherTask(final Task task) {
867867
final Object obj = task.get();
868868
if (obj instanceof Response) {
869869
if (System.currentTimeMillis() - _lastPingResponseTime > _pingInterval * _shell.getPingRetries()) {
870-
logger.error("Ping Interval has gone past {}. Won't reconnect to mgt server, as connection is still alive", () -> _pingInterval * _shell.getPingRetries());
870+
logger.error("Ping Interval has gone past {}. Won't reconnect to mgt server, as connection is still alive", _pingInterval * _shell.getPingRetries());
871871
return;
872872
}
873873

874874
final PingCommand ping = _resource.getCurrentStatus(getId());
875875
final Request request = new Request(_id, -1, ping, false);
876876
request.setSequence(getNextSequence());
877-
logger.debug("Sending ping: {}", () -> request.toString());
877+
logger.debug("Sending ping: {}", request.toString());
878878

879879
try {
880880
task.getLink().send(request.toBytes());
881881
//if i can send pingcommand out, means the link is ok
882882
setLastPingResponseTime();
883883
} catch (final ClosedChannelException e) {
884-
logger.warn("Unable to send request: {}", () -> request.toString());
884+
logger.warn("Unable to send request: {}", request.toString());
885885
}
886886

887887
} else if (obj instanceof Request) {
@@ -900,11 +900,11 @@ public void processOtherTask(final Task task) {
900900
if (answer != null) {
901901
final Response response = new Response(req, answer);
902902

903-
logger.debug("Watch Sent: {}", () -> response.toString());
903+
logger.debug("Watch Sent: {}", response.toString());
904904
try {
905905
task.getLink().send(response.toBytes());
906906
} catch (final ClosedChannelException e) {
907-
logger.warn("Unable to send response: {}", () -> response.toString());
907+
logger.warn("Unable to send response: {}", response.toString());
908908
}
909909
}
910910
} else {
@@ -970,7 +970,7 @@ private void postRequest(final Request request) throws AgentControlChannelExcept
970970
try {
971971
_link.send(request.toBytes());
972972
} catch (final ClosedChannelException e) {
973-
logger.warn("Unable to post agent control request: {}", () -> request.toString());
973+
logger.warn("Unable to post agent control request: {}", request.toString());
974974
throw new AgentControlChannelException("Unable to post agent control request due to " + e.getMessage());
975975
}
976976
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void loadProperties() throws ConfigurationException {
222222
throw new ConfigurationException("Unable to find agent.properties.");
223223
}
224224

225-
LOGGER.info("agent.properties found at {}", () -> file.getAbsolutePath());
225+
LOGGER.info("agent.properties found at {}", file.getAbsolutePath());
226226

227227
try {
228228
PropertiesUtil.loadFromFile(_properties, file);

0 commit comments

Comments
 (0)