优化cluster
This commit is contained in:
@@ -2599,15 +2599,6 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
logger.info("MessageAgent(names=" + JsonConvert.root().convertTo(names) + ") stop in " + (System.currentTimeMillis() - s) + " ms");
|
logger.info("MessageAgent(names=" + JsonConvert.root().convertTo(names) + ") stop in " + (System.currentTimeMillis() - s) + " ms");
|
||||||
}
|
}
|
||||||
if (!isCompileMode() && clusterAgent != null) {
|
|
||||||
if (logger.isLoggable(Level.FINER)) {
|
|
||||||
logger.log(Level.FINER, "ClusterAgent destroying");
|
|
||||||
}
|
|
||||||
long s = System.currentTimeMillis();
|
|
||||||
clusterAgent.deregister(this);
|
|
||||||
clusterAgent.destroy(clusterAgent.getConfig());
|
|
||||||
logger.info("ClusterAgent destroy in " + (System.currentTimeMillis() - s) + " ms");
|
|
||||||
}
|
|
||||||
localServers.stream().forEach((server) -> {
|
localServers.stream().forEach((server) -> {
|
||||||
try {
|
try {
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
@@ -2629,6 +2620,15 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
logger.info("MessageAgent(names=" + JsonConvert.root().convertTo(names) + ") destroy in " + (System.currentTimeMillis() - s) + " ms");
|
logger.info("MessageAgent(names=" + JsonConvert.root().convertTo(names) + ") destroy in " + (System.currentTimeMillis() - s) + " ms");
|
||||||
}
|
}
|
||||||
|
if (!isCompileMode() && clusterAgent != null) {
|
||||||
|
if (logger.isLoggable(Level.FINER)) {
|
||||||
|
logger.log(Level.FINER, "ClusterAgent destroying");
|
||||||
|
}
|
||||||
|
long s = System.currentTimeMillis();
|
||||||
|
clusterAgent.deregister(this);
|
||||||
|
clusterAgent.destroy(clusterAgent.getConfig());
|
||||||
|
logger.info("ClusterAgent destroy in " + (System.currentTimeMillis() - s) + " ms");
|
||||||
|
}
|
||||||
for (DataSource source : dataSources) {
|
for (DataSource source : dataSources) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -309,22 +309,22 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String generateApplicationServiceName() {
|
protected String generateApplicationServiceName() {
|
||||||
return "cluster.application." + super.generateApplicationServiceName();
|
return "cluster:app:" + super.generateApplicationServiceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String generateServiceName(NodeServer ns, String protocol, Service service) {
|
protected String generateServiceName(NodeServer ns, String protocol, Service service) {
|
||||||
return "cluster.service." + super.generateServiceName(ns, protocol, service);
|
return "cluster:service:" + super.generateServiceName(ns, protocol, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateHttpServiceName(String protocol, String module, String resname) {
|
public String generateHttpServiceName(String protocol, String module, String resname) {
|
||||||
return "cluster.service." + super.generateHttpServiceName(protocol, module, resname);
|
return "cluster:service:" + super.generateHttpServiceName(protocol, module, resname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
||||||
return "cluster.service." + super.generateSncpServiceName(protocol, restype, resname);
|
return "cluster:service:" + super.generateSncpServiceName(protocol, restype, resname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ public abstract class ClusterAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String generateApplicationServiceName() {
|
protected String generateApplicationServiceName() {
|
||||||
return "node" + (appName == null || appName.isEmpty() ? "" : ("." + appName));
|
return Utility.isEmpty(appName) ? "node" : appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateApplicationServiceType() {
|
protected String generateApplicationServiceType() {
|
||||||
@@ -264,7 +264,7 @@ public abstract class ClusterAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String generateApplicationServiceId() {
|
protected String generateApplicationServiceId() {
|
||||||
return generateApplicationServiceName() + "." + this.nodeid;
|
return generateApplicationServiceName() + "@" + this.nodeid;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateApplicationCheckName() {
|
protected String generateApplicationCheckName() {
|
||||||
@@ -284,12 +284,12 @@ public abstract class ClusterAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
||||||
return protocol.toLowerCase() + "." + restype + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + restype + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
|
|
||||||
//也会提供给HttpMessageClusterAgent适用
|
//也会提供给HttpMessageClusterAgent适用
|
||||||
public String generateHttpServiceName(String protocol, String module, String resname) {
|
public String generateHttpServiceName(String protocol, String module, String resname) {
|
||||||
return protocol.toLowerCase() + "." + module + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + module + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式: protocol:classtype-resourcename
|
//格式: protocol:classtype-resourcename
|
||||||
@@ -297,18 +297,18 @@ public abstract class ClusterAgent {
|
|||||||
if (protocol.toLowerCase().startsWith("http")) { //HTTP使用RestService.name方式是为了与MessageClient中的module保持一致, 因为HTTP依靠的url中的module,无法知道Service类名
|
if (protocol.toLowerCase().startsWith("http")) { //HTTP使用RestService.name方式是为了与MessageClient中的module保持一致, 因为HTTP依靠的url中的module,无法知道Service类名
|
||||||
String resname = Sncp.getResourceName(service);
|
String resname = Sncp.getResourceName(service);
|
||||||
String module = Rest.getRestModule(service).toLowerCase();
|
String module = Rest.getRestModule(service).toLowerCase();
|
||||||
return protocol.toLowerCase() + "." + module + (resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + module + (resname.isEmpty() ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
if (!Sncp.isSncpDyn(service)) {
|
if (!Sncp.isSncpDyn(service)) {
|
||||||
return protocol.toLowerCase() + "." + service.getClass().getName();
|
return protocol.toLowerCase() + ":" + service.getClass().getName();
|
||||||
}
|
}
|
||||||
String resname = Sncp.getResourceName(service);
|
String resname = Sncp.getResourceName(service);
|
||||||
return protocol.toLowerCase() + "." + Sncp.getResourceType(service).getName() + (resname.isEmpty() ? "" : ("-" + resname));
|
return protocol.toLowerCase() + ":" + Sncp.getResourceType(service).getName() + (resname.isEmpty() ? "" : ("-" + resname));
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式: protocol:classtype-resourcename:nodeid
|
//格式: protocol:classtype-resourcename:nodeid
|
||||||
protected String generateServiceId(NodeServer ns, String protocol, Service service) {
|
protected String generateServiceId(NodeServer ns, String protocol, Service service) {
|
||||||
return generateServiceName(ns, protocol, service) + "." + this.nodeid;
|
return generateServiceName(ns, protocol, service) + "@" + this.nodeid;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateCheckName(NodeServer ns, String protocol, Service service) {
|
protected String generateCheckName(NodeServer ns, String protocol, Service service) {
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public class HttpClusterRpcClient extends HttpRpcClient {
|
|||||||
}
|
}
|
||||||
return clusterAgent.queryHttpAddress("http", module, resname).thenCompose(addrs -> {
|
return clusterAgent.queryHttpAddress("http", module, resname).thenCompose(addrs -> {
|
||||||
if (addrs == null || addrs.isEmpty()) {
|
if (addrs == null || addrs.isEmpty()) {
|
||||||
if (logger.isLoggable(Level.FINE)) {
|
if (logger.isLoggable(Level.WARNING)) {
|
||||||
logger.log(Level.FINE, "httpAsync." + (produce ? "produceMessage" : "sendMessage") + ": module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
logger.log(Level.WARNING, "httpAsync." + (produce ? "produceMessage" : "sendMessage") + ": module=" + localModule + ", resname=" + resname + ", addrmap is empty");
|
||||||
}
|
}
|
||||||
return new HttpResult<byte[]>().status(404).toFuture();
|
return new HttpResult<byte[]>().status(404).toFuture();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user