ClusterAgent优化
This commit is contained in:
@@ -175,6 +175,7 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
protected void checkLocalHealth(final ClusterEntry entry) {
|
||||
AddressEntry newaddr = new AddressEntry();
|
||||
newaddr.addr = entry.address;
|
||||
newaddr.resname = entry.resourceName;
|
||||
newaddr.nodeid = this.nodeid;
|
||||
newaddr.time = System.currentTimeMillis();
|
||||
source.hset(entry.checkName, entry.checkid, AddressEntry.class, newaddr);
|
||||
@@ -266,6 +267,7 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
ClusterEntry clusterEntry = new ClusterEntry(ns, protocol, service);
|
||||
AddressEntry entry = new AddressEntry();
|
||||
entry.addr = clusterEntry.address;
|
||||
entry.resname = clusterEntry.resourceName;
|
||||
entry.nodeid = this.nodeid;
|
||||
entry.time = System.currentTimeMillis();
|
||||
source.hset(clusterEntry.serviceName, clusterEntry.serviceid, AddressEntry.class, entry);
|
||||
@@ -347,6 +349,8 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
|
||||
public long time;
|
||||
|
||||
public String resname;
|
||||
|
||||
public AddressEntry() {
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,9 @@ public abstract class ClusterAgent {
|
||||
//以协议+Rest资源名为主 服务类名
|
||||
public String serviceName;
|
||||
|
||||
public String serviceType;
|
||||
public String resourceType;
|
||||
|
||||
public String resourceName;
|
||||
|
||||
public String checkid;
|
||||
|
||||
@@ -403,7 +405,8 @@ public abstract class ClusterAgent {
|
||||
this.serviceName = generateServiceName(ns, protocol, service);
|
||||
this.checkid = generateCheckId(ns, protocol, service);
|
||||
this.checkName = generateCheckName(ns, protocol, service);
|
||||
this.serviceType = Sncp.getResourceType(service).getName();
|
||||
this.resourceType = Sncp.getResourceType(service).getName();
|
||||
this.resourceName = Sncp.getResourceName(service);
|
||||
this.protocol = protocol;
|
||||
InetSocketAddress addr = ns.getSocketAddress();
|
||||
String host = addr.getHostString();
|
||||
|
||||
@@ -153,20 +153,12 @@ public abstract class Sncp {
|
||||
|
||||
public static String getResourceName(Service service) {
|
||||
Resource res = service.getClass().getAnnotation(Resource.class);
|
||||
if (res != null) {
|
||||
return res.name();
|
||||
}
|
||||
javax.annotation.Resource res2 = service.getClass().getAnnotation(javax.annotation.Resource.class);
|
||||
return res2 == null ? null : res2.name();
|
||||
return res != null ? res.name() : null;
|
||||
}
|
||||
|
||||
public static Class getResourceType(Service service) {
|
||||
ResourceType type = service.getClass().getAnnotation(ResourceType.class);
|
||||
if (type != null) {
|
||||
return type.value();
|
||||
}
|
||||
org.redkale.util.ResourceType rt2 = service.getClass().getAnnotation(org.redkale.util.ResourceType.class);
|
||||
return rt2 == null ? service.getClass() : rt2.value();
|
||||
return type != null ? type.value() : service.getClass();
|
||||
}
|
||||
|
||||
public static Class getServiceType(Service service) {
|
||||
|
||||
Reference in New Issue
Block a user