ClusterAgent
This commit is contained in:
@@ -44,6 +44,16 @@
|
|||||||
-->
|
-->
|
||||||
<transport bufferCapacity="32K" bufferPoolSize="32" threads="32" readTimeoutSeconds="6" writeTimeoutSeconds="6"/>
|
<transport bufferCapacity="32K" bufferPoolSize="32" threads="32" readTimeoutSeconds="6" writeTimeoutSeconds="6"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
第三方服务发现管理接口
|
||||||
|
name: cluster名称,不能包含特殊字符。
|
||||||
|
value: 类名,必须是org.redkale.watch.ClusterAgent的子类
|
||||||
|
protocols: 服务发现可以处理的协议, 默认值为: SNCP, 多个协议用分号;隔开
|
||||||
|
ports: 服务发现可以处理的端口, 多个端口用分号;隔开
|
||||||
|
<cluster name="cluster1" value="org.redkalex.consul.ConsulClusterAgent" protocols="SNCP;" ports="7070;7071">
|
||||||
|
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||||
|
</cluster>
|
||||||
|
-->
|
||||||
<!--
|
<!--
|
||||||
一个组包含多个node, 同一Service服务可以由多个进程提供,这些进程称为一个GROUP,且同一GROUP内的进程必须在同一机房或局域网内
|
一个组包含多个node, 同一Service服务可以由多个进程提供,这些进程称为一个GROUP,且同一GROUP内的进程必须在同一机房或局域网内
|
||||||
一个group节点对应一个 Transport 对象。
|
一个group节点对应一个 Transport 对象。
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ public final class Application {
|
|||||||
//SNCP传输端的TransportFactory, 注意: 只给SNCP使用
|
//SNCP传输端的TransportFactory, 注意: 只给SNCP使用
|
||||||
final TransportFactory sncpTransportFactory;
|
final TransportFactory sncpTransportFactory;
|
||||||
|
|
||||||
|
//第三方服务发现管理接口
|
||||||
|
final ClusterAgent[] clusterAgents;
|
||||||
|
|
||||||
//全局根ResourceFactory
|
//全局根ResourceFactory
|
||||||
final ResourceFactory resourceFactory = ResourceFactory.root();
|
final ResourceFactory resourceFactory = ResourceFactory.root();
|
||||||
|
|
||||||
@@ -264,6 +267,7 @@ public final class Application {
|
|||||||
AsynchronousChannelGroup transportGroup = null;
|
AsynchronousChannelGroup transportGroup = null;
|
||||||
final AnyValue resources = config.getAnyValue("resources");
|
final AnyValue resources = config.getAnyValue("resources");
|
||||||
TransportStrategy strategy = null;
|
TransportStrategy strategy = null;
|
||||||
|
List<ClusterAgent> clusters = new ArrayList<>();
|
||||||
int bufferCapacity = 32 * 1024;
|
int bufferCapacity = 32 * 1024;
|
||||||
int bufferPoolSize = Runtime.getRuntime().availableProcessors() * 8;
|
int bufferPoolSize = Runtime.getRuntime().availableProcessors() * 8;
|
||||||
int readTimeoutSeconds = TransportFactory.DEFAULT_READTIMEOUTSECONDS;
|
int readTimeoutSeconds = TransportFactory.DEFAULT_READTIMEOUTSECONDS;
|
||||||
@@ -307,6 +311,7 @@ public final class Application {
|
|||||||
}
|
}
|
||||||
logger.log(Level.INFO, Transport.class.getSimpleName() + " configure bufferCapacity = " + bufferCapacity / 1024 + "K; bufferPoolSize = " + bufferPoolSize + "; threads = " + threads + ";");
|
logger.log(Level.INFO, Transport.class.getSimpleName() + " configure bufferCapacity = " + bufferCapacity / 1024 + "K; bufferPoolSize = " + bufferPoolSize + "; threads = " + threads + ";");
|
||||||
}
|
}
|
||||||
|
AnyValue[] clusterConfs = resources.getAnyValues("cluster");
|
||||||
}
|
}
|
||||||
if (transportGroup == null) {
|
if (transportGroup == null) {
|
||||||
final AtomicInteger counter = new AtomicInteger();
|
final AtomicInteger counter = new AtomicInteger();
|
||||||
@@ -331,6 +336,7 @@ public final class Application {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.clusterAgents = clusters == null ? null : clusters.toArray(new ClusterAgent[clusters.size()]);
|
||||||
this.sncpTransportFactory = TransportFactory.create(transportExec, transportPool, transportGroup, (SSLContext) null, readTimeoutSeconds, writeTimeoutSeconds, strategy);
|
this.sncpTransportFactory = TransportFactory.create(transportExec, transportPool, transportGroup, (SSLContext) null, readTimeoutSeconds, writeTimeoutSeconds, strategy);
|
||||||
DefaultAnyValue tarnsportConf = DefaultAnyValue.create(TransportFactory.NAME_POOLMAXCONNS, System.getProperty("net.transport.poolmaxconns", "100"))
|
DefaultAnyValue tarnsportConf = DefaultAnyValue.create(TransportFactory.NAME_POOLMAXCONNS, System.getProperty("net.transport.poolmaxconns", "100"))
|
||||||
.addValue(TransportFactory.NAME_PINGINTERVAL, System.getProperty("net.transport.pinginterval", "30"))
|
.addValue(TransportFactory.NAME_PINGINTERVAL, System.getProperty("net.transport.pinginterval", "30"))
|
||||||
@@ -348,6 +354,10 @@ public final class Application {
|
|||||||
return sncpTransportFactory;
|
return sncpTransportFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClusterAgent[] getClusterAgents() {
|
||||||
|
return clusterAgents;
|
||||||
|
}
|
||||||
|
|
||||||
public RedkaleClassLoader getClassLoader() {
|
public RedkaleClassLoader getClassLoader() {
|
||||||
return classLoader;
|
return classLoader;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/org/redkale/watch/ClusterAgent.java
Normal file
18
src/org/redkale/watch/ClusterAgent.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.redkale.watch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方服务发现管理接口cluster
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* 详情见: https://redkale.org
|
||||||
|
*
|
||||||
|
* @author zhangjx
|
||||||
|
*/
|
||||||
|
public abstract class ClusterAgent {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user