|
55 | 55 | import org.apache.cloudstack.utils.security.KeyStoreUtils; |
56 | 56 | import org.apache.commons.collections.CollectionUtils; |
57 | 57 | import org.apache.commons.io.FileUtils; |
| 58 | +import org.apache.commons.lang.ObjectUtils; |
58 | 59 | import org.apache.commons.lang3.StringUtils; |
59 | 60 | import org.apache.logging.log4j.Logger; |
60 | 61 | import org.apache.logging.log4j.LogManager; |
@@ -182,7 +183,7 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour |
182 | 183 |
|
183 | 184 | final String value = _shell.getPersistentProperty(getResourceName(), "id"); |
184 | 185 | _id = value != null ? Long.parseLong(value) : null; |
185 | | - logger.info("id is {}", () -> (_id != null ? _id : "")); |
| 186 | + logger.info("id is {}", ObjectUtils.defaultIfNull(_id, "")); |
186 | 187 |
|
187 | 188 | final Map<String, Object> params = new HashMap<>(); |
188 | 189 |
|
@@ -211,8 +212,8 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour |
211 | 212 | new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory( |
212 | 213 | "agentRequest-Handler")); |
213 | 214 |
|
214 | | - logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", () -> (_id != null ? _id : "new"), () -> getResourceName(), |
215 | | - () -> _shell.getZone(), () -> _shell.getPod(), () -> _shell.getWorkers(), () -> host, () -> _shell.getPort()); |
| 215 | + logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", ObjectUtils.defaultIfNull(_id, "new"), getResourceName(), |
| 216 | + _shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort()); |
216 | 217 | } |
217 | 218 |
|
218 | 219 | public String getVersion() { |
@@ -312,7 +313,7 @@ public void start() { |
312 | 313 | } |
313 | 314 |
|
314 | 315 | public void stop(final String reason, final String detail) { |
315 | | - logger.info("Stopping the agent: Reason = {}", () -> reason + (detail != null ? ": Detail = " + detail : "")); |
| 316 | + logger.info("Stopping the agent: Reason = {}", reason + ObjectUtils.defaultIfNull(": Detail = " + detail, "")); |
316 | 317 | _reconnectAllowed = false; |
317 | 318 | if (_connection != null) { |
318 | 319 | final ShutdownCommand cmd = new ShutdownCommand(reason, detail); |
@@ -1034,7 +1035,7 @@ public WatchTask(final Link link, final Request request, final Agent agent) { |
1034 | 1035 |
|
1035 | 1036 | @Override |
1036 | 1037 | protected void runInContext() { |
1037 | | - logger.trace("Scheduling {}", () -> (_request instanceof Response ? "Ping" : "Watch Task")); |
| 1038 | + logger.trace("Scheduling {}", (_request instanceof Response ? "Ping" : "Watch Task")); |
1038 | 1039 | try { |
1039 | 1040 | if (_request instanceof Response) { |
1040 | 1041 | _ugentTaskPool.submit(new ServerHandler(Task.Type.OTHER, _link, _request)); |
|
0 commit comments