use of rpc.turbo.config.HostPort in project turbo-rpc by hank-whu.
the class App method kill.
/**
* 干掉有问题的连接
*
* @param connectorContext
*/
private synchronized void kill(ConnectorContext connectorContext) {
if (connectorContext == null) {
return;
}
HostPort serverAddress = connectorContext.serverAddress;
if (logger.isWarnEnabled()) {
logger.warn(group + "#" + app + " " + serverAddress + " is zombie, and will be killed!");
}
activeMap.remove(serverAddress);
zombieMap.put(serverAddress, connectorContext);
Collection<ConnectorContext> connectors = activeMap.values();
int length = methodRouterMap.size();
for (int i = 0; i < length; i++) {
MethodRouter router = methodRouterMap.get(i);
if (!connectorContext.isSupport(router.getServiceMethodName())) {
continue;
}
router.setConnectors(connectors);
}
if (logger.isWarnEnabled()) {
logger.warn(group + "#" + app + " " + serverAddress + " is zombie, and have been killed!");
}
}
use of rpc.turbo.config.HostPort in project turbo-rpc by hank-whu.
the class App method heartbeat.
private void heartbeat() {
if (isCloseing) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug(group + "#" + app + " start heartbeat");
}
//
activeMap.entrySet().stream().parallel().forEach(kv -> {
if (isCloseing) {
return;
}
HostPort serverAddress = kv.getKey();
ConnectorContext context = kv.getValue();
if (!context.heartbeat()) {
activeMap.remove(serverAddress);
zombieMap.put(serverAddress, context);
if (logger.isInfoEnabled()) {
logger.info(group + "#" + app + " " + serverAddress + " is zombie");
}
} else {
if (logger.isDebugEnabled()) {
logger.debug(group + "#" + app + " " + serverAddress + " is active");
}
}
});
}
use of rpc.turbo.config.HostPort in project turbo-rpc by hank-whu.
the class App method addConnect.
private synchronized void addConnect(ConnectorContext context) throws Exception {
if (isCloseing) {
return;
}
if (context == null) {
return;
}
HostPort serverAddress = context.serverAddress;
activeMap.put(serverAddress, context);
zombieMap.remove(serverAddress);
}
use of rpc.turbo.config.HostPort in project turbo-rpc by hank-whu.
the class NettyRpcServerHandler method channelActive.
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx);
if (logger.isInfoEnabled()) {
logger.info("channelActive: " + ctx.channel());
}
InetSocketAddress insocket = (InetSocketAddress) ctx.channel().remoteAddress();
clientAddress = new HostPort(insocket.getAddress().getHostAddress(), 0);
insocket = (InetSocketAddress) ctx.channel().localAddress();
serverAddress = new HostPort(insocket.getAddress().getHostAddress(), insocket.getPort());
}
use of rpc.turbo.config.HostPort in project turbo-rpc by hank-whu.
the class ZooKeeperDiscover method init.
@Override
public void init(List<HostPort> hostPorts) {
watchers = new ConcurrentArrayList<>();
String connectString = hostPorts.stream().map(i -> i.toString()).collect(Collectors.joining(","));
RetryPolicy retryPolicy = new ForeverRetryPolicy(1000, 60 * 1000);
client = CuratorFrameworkFactory.newClient(connectString, 1000 * 10, 1000 * 3, retryPolicy);
client.start();
}
Aggregations