This commit is contained in:
@@ -496,7 +496,7 @@ public final class Application {
|
|||||||
pidstr = "APP_PID = " + pid + "\r\n";
|
pidstr = "APP_PID = " + pid + "\r\n";
|
||||||
} catch (Throwable t) {
|
} 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);
|
String lib = config.getValue("lib", "${APP_HOME}/libs/*").trim().replace("${APP_HOME}", homepath);
|
||||||
lib = lib.isEmpty() ? confpath : (lib + ";" + confpath);
|
lib = lib.isEmpty() ? confpath : (lib + ";" + confpath);
|
||||||
Server.loadLib(classLoader, logger, lib);
|
Server.loadLib(classLoader, logger, lib);
|
||||||
@@ -782,7 +782,13 @@ public final class Application {
|
|||||||
long s = System.currentTimeMillis();
|
long s = System.currentTimeMillis();
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuffer sb = new StringBuffer();
|
||||||
for (MessageAgent agent : this.messageAgents) {
|
for (MessageAgent agent : this.messageAgents) {
|
||||||
agent.start(sb).join();
|
Map<String, Long> 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());
|
if (sb.length() > 0) logger.info(sb.toString().trim());
|
||||||
logger.info(this.getClass().getSimpleName() + " MessageAgent init in " + (System.currentTimeMillis() - s) + " ms");
|
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();
|
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() {
|
// private void clearPersistData() {
|
||||||
// File cachedir = new File(home, "cache");
|
// File cachedir = new File(home, "cache");
|
||||||
// if (!cachedir.isDirectory()) return;
|
// if (!cachedir.isDirectory()) return;
|
||||||
|
|||||||
@@ -70,20 +70,15 @@ public abstract class MessageAgent {
|
|||||||
this.sncpRespStartms = System.currentTimeMillis() - s;
|
this.sncpRespStartms = System.currentTimeMillis() - s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> start(final StringBuffer sb) {
|
public CompletableFuture<Map<String, Long>> start() {
|
||||||
AtomicInteger maxlen = new AtomicInteger(sncpRespConsumer == null ? 0 : sncpRespConsumer.topic.length());
|
final LinkedHashMap<String, Long> map = new LinkedHashMap<>();
|
||||||
this.messageNodes.values().forEach(node -> {
|
if (this.sncpRespStartms >= 0) map.put(this.sncpRespConsumer.topic, this.sncpRespStartms);
|
||||||
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");
|
|
||||||
}
|
|
||||||
this.messageNodes.values().forEach(node -> {
|
this.messageNodes.values().forEach(node -> {
|
||||||
long s = System.currentTimeMillis();
|
long s = System.currentTimeMillis();
|
||||||
node.consumer.startup().join();
|
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<Void> stop() {
|
public CompletableFuture<Void> stop() {
|
||||||
@@ -217,15 +212,6 @@ public abstract class MessageAgent {
|
|||||||
return protocol + ".resp.node" + nodeid;
|
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 {
|
protected static class MessageNode {
|
||||||
|
|
||||||
public final NodeServer server;
|
public final NodeServer server;
|
||||||
|
|||||||
Reference in New Issue
Block a user