This commit is contained in:
@@ -75,17 +75,17 @@ public final class Application {
|
||||
public static final String RESNAME_APP_ADDR = "APP_ADDR";
|
||||
|
||||
/**
|
||||
* 当前Service的IP地址+端口 类型: SocketAddress、InetSocketAddress、String
|
||||
* 当前Service所属的SNCP Server的地址 类型: SocketAddress、InetSocketAddress、String <br>
|
||||
*/
|
||||
public static final String RESNAME_SERVER_ADDR = "SERVER_ADDR";
|
||||
public static final String RESNAME_SNCP_ADDR = "SNCP_ADDR";
|
||||
|
||||
/**
|
||||
* 当前SNCP Server所属的组 类型: String
|
||||
* 当前Service所属的SNCP Server所属的组 类型: String<br>
|
||||
*/
|
||||
public static final String RESNAME_SERVER_GROUP = "SERVER_GROUP";
|
||||
public static final String RESNAME_SNCP_GROUP = "SNCP_GROUP";
|
||||
|
||||
/**
|
||||
* 当前Server的ROOT目录 类型:String、File、Path
|
||||
* "SERVER_ROOT" 当前Server的ROOT目录类型:String、File、Path
|
||||
*/
|
||||
public static final String RESNAME_SERVER_ROOT = Server.RESNAME_SERVER_ROOT;
|
||||
|
||||
@@ -283,7 +283,6 @@ public final class Application {
|
||||
// public WatchFactory getWatchFactory() {
|
||||
// return watchFactory;
|
||||
// }
|
||||
|
||||
public List<NodeServer> getNodeServers() {
|
||||
return new ArrayList<>(servers);
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ public abstract class NodeServer {
|
||||
//if (this.sncpGroup == null) throw new RuntimeException("Server (" + String.valueOf(config).replaceAll("\\s+", " ") + ") not found <group> info");
|
||||
}
|
||||
//单点服务不会有 sncpAddress、sncpGroup
|
||||
if (this.sncpAddress != null) this.resourceFactory.register(RESNAME_SERVER_ADDR, this.sncpAddress);
|
||||
if (this.sncpGroup != null) this.resourceFactory.register(RESNAME_SERVER_GROUP, this.sncpGroup);
|
||||
if (this.sncpAddress != null) this.resourceFactory.register(RESNAME_SNCP_ADDR, this.sncpAddress);
|
||||
if (this.sncpGroup != null) this.resourceFactory.register(RESNAME_SNCP_GROUP, this.sncpGroup);
|
||||
{
|
||||
//设置root文件夹
|
||||
String webroot = this.serverConf.getValue("root", "root");
|
||||
|
||||
@@ -30,8 +30,8 @@ public abstract class WebSocketNode {
|
||||
|
||||
protected final boolean finest = logger.isLoggable(Level.FINEST);
|
||||
|
||||
//如果不是分布式(没有SNCP) 值为null
|
||||
@Resource(name = Application.RESNAME_SERVER_ADDR)
|
||||
//"SNCP_ADDR" 如果不是分布式(没有SNCP) 值为null
|
||||
@Resource(name = Application.RESNAME_SNCP_ADDR)
|
||||
protected InetSocketAddress localSncpAddress; //为SncpServer的服务address
|
||||
|
||||
@RpcRemote
|
||||
|
||||
@@ -885,8 +885,8 @@ public abstract class Sncp {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends Service> T createSimpleLocalService(final String name, final Class<T> serviceImplClass, final InetSocketAddress clientAddress, final Transport sameGroupTransport) {
|
||||
return createLocalService(name, null, ResourceFactory.root(), serviceImplClass, clientAddress, null, new HashSet<>(), null, sameGroupTransport, null);
|
||||
public static <T extends Service> T createSimpleLocalService(final String name, final Class<T> serviceImplClass, final InetSocketAddress clientSncpAddress, final Transport sameGroupTransport) {
|
||||
return createLocalService(name, null, ResourceFactory.root(), serviceImplClass, clientSncpAddress, null, new HashSet<>(), null, sameGroupTransport, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,7 +898,7 @@ public abstract class Sncp {
|
||||
* @param executor 线程池
|
||||
* @param resourceFactory 资源容器
|
||||
* @param serviceImplClass Service类
|
||||
* @param clientAddress 本地IP地址
|
||||
* @param clientSncpAddress 本地IP地址
|
||||
* @param sncpGroup 自身的组节点名 可能为null
|
||||
* @param groups 所有的组节点,包含自身
|
||||
* @param conf 启动配置项
|
||||
@@ -913,7 +913,7 @@ public abstract class Sncp {
|
||||
final Consumer<Runnable> executor,
|
||||
final ResourceFactory resourceFactory,
|
||||
final Class<T> serviceImplClass,
|
||||
final InetSocketAddress clientAddress,
|
||||
final InetSocketAddress clientSncpAddress,
|
||||
final String sncpGroup,
|
||||
final Set<String> groups,
|
||||
final AnyValue conf,
|
||||
@@ -952,7 +952,7 @@ public abstract class Sncp {
|
||||
}
|
||||
}
|
||||
if (remoteService == null && remoteTransport != null) {
|
||||
remoteService = createRemoteService(name, executor, serviceImplClass, clientAddress, sncpGroup, groups, conf, remoteTransport);
|
||||
remoteService = createRemoteService(name, executor, serviceImplClass, clientSncpAddress, sncpGroup, groups, conf, remoteTransport);
|
||||
}
|
||||
if (remoteService != null) field.set(rs, remoteService);
|
||||
}
|
||||
@@ -963,7 +963,7 @@ public abstract class Sncp {
|
||||
try {
|
||||
Field e = newClazz.getDeclaredField(FIELDPREFIX + "_client");
|
||||
e.setAccessible(true);
|
||||
client = new SncpClient(name, serviceImplClass, rs, executor, false, newClazz, clientAddress);
|
||||
client = new SncpClient(name, serviceImplClass, rs, executor, false, newClazz, clientSncpAddress);
|
||||
e.set(rs, client);
|
||||
} catch (NoSuchFieldException ne) {
|
||||
}
|
||||
@@ -982,7 +982,7 @@ public abstract class Sncp {
|
||||
// groups.add(t.getName());
|
||||
// }
|
||||
// }
|
||||
sb.append(", address = ").append(clientAddress).append(", groups = ").append(groups);
|
||||
sb.append(", address = ").append(clientSncpAddress).append(", groups = ").append(groups);
|
||||
sb.append(", sameaddrs = ").append(sameGroupTransport == null ? null : Arrays.asList(sameGroupTransport.getRemoteAddresses()));
|
||||
|
||||
List<InetSocketAddress> addrs = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user