This commit is contained in:
Redkale
2020-05-17 22:11:34 +08:00
parent 38307405ed
commit 4a60ecb3ff
2 changed files with 5 additions and 2 deletions

View File

@@ -105,7 +105,7 @@ public abstract class ClusterAgent {
} }
//获取远程服务的可用ip列表 //获取远程服务的可用ip列表
protected abstract List<InetSocketAddress> queryAddress(NodeServer ns, String protocol, Service service); protected abstract Collection<InetSocketAddress> queryAddress(NodeServer ns, String protocol, Service service);
//注册服务 //注册服务
protected abstract void register(NodeServer ns, String protocol, Service service); protected abstract void register(NodeServer ns, String protocol, Service service);
@@ -118,7 +118,7 @@ public abstract class ClusterAgent {
Server server = ns.getServer(); Server server = ns.getServer();
String netprotocol = server instanceof SncpServer ? ((SncpServer) server).getNetprotocol() : Transport.DEFAULT_PROTOCOL; String netprotocol = server instanceof SncpServer ? ((SncpServer) server).getNetprotocol() : Transport.DEFAULT_PROTOCOL;
if (!Sncp.isSncpDyn(service)) return; if (!Sncp.isSncpDyn(service)) return;
List<InetSocketAddress> addrs = queryAddress(ns, protocol, service); Collection<InetSocketAddress> addrs = queryAddress(ns, protocol, service);
if (addrs != null && !addrs.isEmpty()) { if (addrs != null && !addrs.isEmpty()) {
Sncp.updateTransport(service, transportFactory, Sncp.getResourceType(service).getName() + "-" + Sncp.getResourceName(service), netprotocol, ns.getSncpAddress(), null, addrs); Sncp.updateTransport(service, transportFactory, Sncp.getResourceType(service).getName() + "-" + Sncp.getResourceName(service), netprotocol, ns.getSncpAddress(), null, addrs);
} }

View File

@@ -489,7 +489,9 @@ public abstract class NodeServer {
localServices.clear(); localServices.clear();
localServices.addAll(swlist); localServices.addAll(swlist);
//this.loadPersistData(); //this.loadPersistData();
long preinits = System.currentTimeMillis();
preInitServices(localServices, remoteServices); preInitServices(localServices, remoteServices);
long preinite = System.currentTimeMillis() - preinits;
final List<String> slist = sb == null ? null : new CopyOnWriteArrayList<>(); final List<String> slist = sb == null ? null : new CopyOnWriteArrayList<>();
localServices.stream().forEach(y -> { localServices.stream().forEach(y -> {
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
@@ -505,6 +507,7 @@ public abstract class NodeServer {
} }
sb.append(threadName).append("All Services load cost ").append(System.currentTimeMillis() - starts).append(" ms" + LINE_SEPARATOR); sb.append(threadName).append("All Services load cost ").append(System.currentTimeMillis() - starts).append(" ms" + LINE_SEPARATOR);
} }
if (sb != null && preinite > 10) sb.append(threadName).append("ALL cluster agents load ").append(preinite).append(" ms" + LINE_SEPARATOR);
if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString()); if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString());
} }