diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index 97fcac421..b3040c05d 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -496,7 +496,7 @@ public final class Application { pidstr = "APP_PID = " + pid + "\r\n"; } catch (Throwable t) { } - logger.log(Level.INFO, pidstr + "APP_JAVA = " + System.getProperty("java.version") + "\r\n" + RESNAME_APP_ADDR + " = " + this.localAddress.getHostAddress() + "\r\n" + RESNAME_APP_HOME + " = " + homepath + "\r\n" + RESNAME_APP_CONF + " = " + confpath); + logger.log(Level.INFO, pidstr + "APP_JAVA = " + System.getProperty("java.version") + "\r\n" + RESNAME_APP_NODEID + " = " + this.nodeid + "\r\n" + RESNAME_APP_ADDR + " = " + this.localAddress.getHostAddress() + "\r\n" + RESNAME_APP_HOME + " = " + homepath + "\r\n" + RESNAME_APP_CONF + " = " + confpath); String lib = config.getValue("lib", "${APP_HOME}/libs/*").trim().replace("${APP_HOME}", homepath); lib = lib.isEmpty() ? confpath : (lib + ";" + confpath); Server.loadLib(classLoader, logger, lib); @@ -782,7 +782,13 @@ public final class Application { long s = System.currentTimeMillis(); final StringBuffer sb = new StringBuffer(); for (MessageAgent agent : this.messageAgents) { - agent.start(sb).join(); + Map map = agent.start().join(); + AtomicInteger maxlen = new AtomicInteger(); + map.keySet().forEach(str -> { + if (str.length() > maxlen.get()) maxlen.set(str.length()); + }); + map.forEach((topic, ms) -> sb.append("MessageConsumer(topic=").append(alignString(topic, maxlen.get())).append(") init and start in ").append(ms).append(" ms\r\n") + ); } if (sb.length() > 0) logger.info(sb.toString().trim()); logger.info(this.getClass().getSimpleName() + " MessageAgent init in " + (System.currentTimeMillis() - s) + " ms"); @@ -793,6 +799,15 @@ public final class Application { if (!singletonrun) this.serversLatch.await(); } + private static String alignString(String value, int maxlen) { + StringBuilder sb = new StringBuilder(maxlen); + sb.append(value); + for (int i = 0; i < maxlen - value.length(); i++) { + sb.append(' '); + } + return sb.toString(); + } + // private void clearPersistData() { // File cachedir = new File(home, "cache"); // if (!cachedir.isDirectory()) return; diff --git a/src/org/redkale/mq/MessageAgent.java b/src/org/redkale/mq/MessageAgent.java index 6886b5eb3..6ff71b8e6 100644 --- a/src/org/redkale/mq/MessageAgent.java +++ b/src/org/redkale/mq/MessageAgent.java @@ -70,20 +70,15 @@ public abstract class MessageAgent { this.sncpRespStartms = System.currentTimeMillis() - s; } - public CompletableFuture start(final StringBuffer sb) { - AtomicInteger maxlen = new AtomicInteger(sncpRespConsumer == null ? 0 : sncpRespConsumer.topic.length()); - this.messageNodes.values().forEach(node -> { - if (node.consumer.topic.length() > maxlen.get()) maxlen.set(node.consumer.topic.length()); - }); - if (this.sncpRespStartms >= 0) { - if (sb != null) sb.append("MessageConsumer(topic=").append(fillString(this.sncpRespConsumer.topic, maxlen.get())).append(") init and start in ").append(this.sncpRespStartms).append(" ms\r\n"); - } + public CompletableFuture> start() { + final LinkedHashMap map = new LinkedHashMap<>(); + if (this.sncpRespStartms >= 0) map.put(this.sncpRespConsumer.topic, this.sncpRespStartms); this.messageNodes.values().forEach(node -> { long s = System.currentTimeMillis(); node.consumer.startup().join(); - if (sb != null) sb.append("MessageConsumer(topic=").append(fillString(node.consumer.topic, maxlen.get())).append(") init and start in ").append(System.currentTimeMillis() - s).append(" ms\r\n"); + map.put(node.consumer.topic, System.currentTimeMillis() - s); }); - return CompletableFuture.completedFuture(null); + return CompletableFuture.completedFuture(map); } public CompletableFuture stop() { @@ -217,15 +212,6 @@ public abstract class MessageAgent { return protocol + ".resp.node" + nodeid; } - protected static String fillString(String value, int maxlen) { - StringBuilder sb = new StringBuilder(maxlen); - sb.append(value); - for (int i = 0; i < maxlen - value.length(); i++) { - sb.append(' '); - } - return sb.toString(); - } - protected static class MessageNode { public final NodeServer server;