Application.nodeid改为string类型
This commit is contained in:
@@ -54,7 +54,7 @@ class AppConfig {
|
||||
boolean configFromCache;
|
||||
|
||||
//本进程节点ID
|
||||
int nodeid;
|
||||
String nodeid;
|
||||
|
||||
//本进程节点ID
|
||||
String name;
|
||||
@@ -97,7 +97,7 @@ class AppConfig {
|
||||
private void init(AnyValue conf) {
|
||||
this.config = conf;
|
||||
this.name = checkName(config.getValue("name", ""));
|
||||
this.nodeid = config.getIntValue("nodeid", 0);
|
||||
this.nodeid = config.getValue("nodeid", String.valueOf(Math.abs(System.nanoTime())));
|
||||
this.configFromCache = "true".equals(config.getValue("[config-from-cache]"));
|
||||
//初始化classLoader、serverClassLoader
|
||||
this.initClassLoader();
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class Application {
|
||||
public static final String RESNAME_APP_CONF_DIR = "APP_CONF_DIR";
|
||||
|
||||
/**
|
||||
* 当前进程节点的nodeid, 类型:int
|
||||
* 当前进程节点的nodeid, 类型:String
|
||||
*/
|
||||
public static final String RESNAME_APP_NODEID = "APP_NODEID";
|
||||
|
||||
@@ -156,7 +156,7 @@ public final class Application {
|
||||
private final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
||||
|
||||
//本进程节点ID
|
||||
final int nodeid;
|
||||
final String nodeid;
|
||||
|
||||
//本进程节点ID
|
||||
final String name;
|
||||
@@ -271,8 +271,10 @@ public final class Application {
|
||||
//设置基础信息资源
|
||||
this.resourceFactory.register(RESNAME_APP_NAME, String.class, this.name);
|
||||
|
||||
this.resourceFactory.register(RESNAME_APP_NODEID, int.class, this.nodeid);
|
||||
this.resourceFactory.register(RESNAME_APP_NODEID, Integer.class, this.nodeid);
|
||||
this.resourceFactory.register(RESNAME_APP_NODEID, String.class, this.nodeid);
|
||||
if (Utility.isNumeric(this.nodeid)) {
|
||||
this.resourceFactory.register(RESNAME_APP_NODEID, int.class, Integer.parseInt(this.nodeid));
|
||||
}
|
||||
|
||||
this.resourceFactory.register(RESNAME_APP_TIME, long.class, this.startTime);
|
||||
this.resourceFactory.register(RESNAME_APP_TIME, Long.class, this.startTime);
|
||||
@@ -1437,7 +1439,7 @@ public final class Application {
|
||||
return sncpRpcGroups;
|
||||
}
|
||||
|
||||
public int getNodeid() {
|
||||
public String getNodeid() {
|
||||
return nodeid;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,6 @@ public abstract class HttpRpcClient implements ClusterRpcClient<HttpSimpleReques
|
||||
|
||||
public abstract CompletableFuture<Void> produceMessage(String topic, Serializable userid, String groupid, HttpSimpleRequest request);
|
||||
|
||||
protected abstract int getNodeid();
|
||||
protected abstract String getNodeid();
|
||||
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
|
||||
public InetSocketAddress addr;
|
||||
|
||||
public int nodeid;
|
||||
public String nodeid;
|
||||
|
||||
public long time;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class ClusterAgent {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
|
||||
|
||||
@Resource(name = RESNAME_APP_NODEID)
|
||||
protected int nodeid;
|
||||
protected String nodeid;
|
||||
|
||||
@Resource(name = RESNAME_APP_NAME)
|
||||
protected String appName = "";
|
||||
|
||||
@@ -54,7 +54,7 @@ public class HttpClusterRpcClient extends HttpRpcClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNodeid() {
|
||||
protected String getNodeid() {
|
||||
return localClient.getNodeid();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HttpLocalRpcClient extends HttpRpcClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNodeid() {
|
||||
protected String getNodeid() {
|
||||
return application.getNodeid();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ final class HttpRpcMessageClient extends HttpRpcClient {
|
||||
|
||||
private final MessageCoder<HttpSimpleRequest> requestCoder = HttpSimpleRequestCoder.getInstance();
|
||||
|
||||
private final int nodeid;
|
||||
private final String nodeid;
|
||||
|
||||
private final MessageClient messageClient;
|
||||
|
||||
public HttpRpcMessageClient(MessageClient messageClient, final int nodeid) {
|
||||
public HttpRpcMessageClient(MessageClient messageClient, final String nodeid) {
|
||||
this.messageClient = messageClient;
|
||||
this.nodeid = nodeid;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ final class HttpRpcMessageClient extends HttpRpcClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNodeid() {
|
||||
protected String getNodeid() {
|
||||
return nodeid;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class MessageAgent implements MessageManager {
|
||||
protected Environment environment;
|
||||
|
||||
@Resource(name = RESNAME_APP_NODEID)
|
||||
protected int nodeid;
|
||||
protected String nodeid;
|
||||
|
||||
@Resource(name = RESNAME_APP_NAME)
|
||||
protected String nodeName;
|
||||
@@ -432,7 +432,7 @@ public abstract class MessageAgent implements MessageManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (WebSocketNode.class.isAssignableFrom(Sncp.getResourceType(service)) && nodeid == 0) {
|
||||
if (WebSocketNode.class.isAssignableFrom(Sncp.getResourceType(service)) && Utility.isEmpty(nodeid)) {
|
||||
throw new RedkaleException("Application.node not config in WebSocket Cluster");
|
||||
}
|
||||
String topic = Rest.generateHttpReqTopic(service, this.nodeid);
|
||||
@@ -449,7 +449,7 @@ public abstract class MessageAgent implements MessageManager {
|
||||
if (al2 != null && !al2.value() && service.getClass().getAnnotation(Local.class) != null) {
|
||||
return;
|
||||
}
|
||||
if (WebSocketNode.class.isAssignableFrom(Sncp.getResourceType(service)) && nodeid == 0) {
|
||||
if (WebSocketNode.class.isAssignableFrom(Sncp.getResourceType(service)) && Utility.isEmpty(nodeid)) {
|
||||
throw new RedkaleException("Application.node not config in WebSocket Cluster");
|
||||
}
|
||||
String topic = Sncp.generateSncpReqTopic(service, this.nodeid);
|
||||
@@ -486,7 +486,7 @@ public abstract class MessageAgent implements MessageManager {
|
||||
return this.sncpAppRespTopic;
|
||||
}
|
||||
|
||||
public final int getNodeid() {
|
||||
public final String getNodeid() {
|
||||
return this.nodeid;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Context {
|
||||
protected final long serverStartTime;
|
||||
|
||||
//Application节点id
|
||||
protected final int nodeid;
|
||||
protected final String nodeid;
|
||||
|
||||
//Server的线程池
|
||||
protected final ExecutorService workExecutor;
|
||||
@@ -85,7 +85,7 @@ public class Context {
|
||||
config.dispatcher, config.aliveTimeoutSeconds, config.readTimeoutSeconds, config.writeTimeoutSeconds);
|
||||
}
|
||||
|
||||
public Context(long serverStartTime, int nodeid, Logger logger, ExecutorService workExecutor, SSLBuilder sslBuilder, SSLContext sslContext,
|
||||
public Context(long serverStartTime, String nodeid, Logger logger, ExecutorService workExecutor, SSLBuilder sslBuilder, SSLContext sslContext,
|
||||
int bufferCapacity, final int maxConns, final int maxBody, Charset charset, InetSocketAddress address,
|
||||
ResourceFactory resourceFactory, DispatcherServlet dispatcher, int aliveTimeoutSeconds, int readTimeoutSeconds, int writeTimeoutSeconds) {
|
||||
this.serverStartTime = serverStartTime;
|
||||
@@ -178,7 +178,7 @@ public class Context {
|
||||
return serverStartTime;
|
||||
}
|
||||
|
||||
public int getNodeid() {
|
||||
public String getNodeid() {
|
||||
return nodeid;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class Context {
|
||||
public long serverStartTime;
|
||||
|
||||
//Application节点id
|
||||
public int nodeid;
|
||||
public String nodeid;
|
||||
|
||||
//Server的线程池
|
||||
public ExecutorService workExecutor;
|
||||
|
||||
@@ -269,16 +269,16 @@ public final class Rest {
|
||||
}
|
||||
|
||||
//格式: http.req.module.user
|
||||
public static String generateHttpReqTopic(String module, int nodeid) {
|
||||
public static String generateHttpReqTopic(String module, String nodeid) {
|
||||
return getHttpReqTopicPrefix() + "module." + module.toLowerCase();
|
||||
}
|
||||
|
||||
//格式: http.req.module.user
|
||||
public static String generateHttpReqTopic(String module, String resname, int nodeid) {
|
||||
public static String generateHttpReqTopic(String module, String resname, String nodeid) {
|
||||
return getHttpReqTopicPrefix() + "module." + module.toLowerCase() + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
||||
}
|
||||
|
||||
public static String generateHttpReqTopic(Service service, int nodeid) {
|
||||
public static String generateHttpReqTopic(Service service, String nodeid) {
|
||||
String resname = Sncp.getResourceName(service);
|
||||
String module = getRestModule(service).toLowerCase();
|
||||
return getHttpReqTopicPrefix() + "module." + module + (resname.isEmpty() ? "" : ("-" + resname));
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class WebSocketNode implements Service {
|
||||
protected final Logger logger = Logger.getLogger(WebSocketNode.class.getSimpleName());
|
||||
|
||||
@Resource(name = RESNAME_APP_NODEID)
|
||||
protected int nodeid;
|
||||
protected String nodeid;
|
||||
|
||||
//"SNCP_ADDR" 如果不是分布式(没有SNCP) 值为null
|
||||
@Resource(name = Application.RESNAME_SNCP_ADDRESS, required = false)
|
||||
|
||||
@@ -261,12 +261,12 @@ public abstract class Sncp {
|
||||
}
|
||||
|
||||
//格式: sncp.req.module.user
|
||||
public static String generateSncpReqTopic(Service service, int nodeid) {
|
||||
public static String generateSncpReqTopic(Service service, String nodeid) {
|
||||
return generateSncpReqTopic(getResourceName(service), getResourceType(service), nodeid);
|
||||
}
|
||||
|
||||
//格式: sncp.req.module.user
|
||||
public static String generateSncpReqTopic(String resourceName, Class resourceType, int nodeid) {
|
||||
public static String generateSncpReqTopic(String resourceName, Class resourceType, String nodeid) {
|
||||
if (WebSocketNode.class.isAssignableFrom(resourceType)) {
|
||||
return getSncpReqTopicPrefix() + "module.wsnode" + nodeid + (isEmpty(resourceName) ? "" : ("-" + resourceName));
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ public class SncpClient extends Client<SncpClientConnection, SncpClientRequest,
|
||||
|
||||
private final AtomicLong seqno = new AtomicLong();
|
||||
|
||||
final int nodeid;
|
||||
final String nodeid;
|
||||
|
||||
final InetSocketAddress clientSncpAddress;
|
||||
|
||||
public SncpClient(String name, AsyncGroup group, int nodeid,
|
||||
public SncpClient(String name, AsyncGroup group, String nodeid,
|
||||
InetSocketAddress clientSncpAddress, ClientAddress address, String netprotocol, int maxConns, int maxPipelines) {
|
||||
super(name, group, "TCP".equalsIgnoreCase(netprotocol), address, maxConns, maxPipelines, null, null, null); //maxConns
|
||||
this.clientSncpAddress = clientSncpAddress;
|
||||
@@ -46,7 +46,7 @@ public class SncpClient extends Client<SncpClientConnection, SncpClientRequest,
|
||||
return clientSncpAddress;
|
||||
}
|
||||
|
||||
public int getNodeid() {
|
||||
public String getNodeid() {
|
||||
return nodeid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user