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