|
@@ -4,6 +4,7 @@ import com.its.common.cluster.codec.ClusterMessageDecoder;
|
|
|
import com.its.common.cluster.codec.ClusterMessageEncoder;
|
|
import com.its.common.cluster.codec.ClusterMessageEncoder;
|
|
|
import com.its.common.cluster.config.AbstractClusterConfig;
|
|
import com.its.common.cluster.config.AbstractClusterConfig;
|
|
|
import com.its.common.cluster.handler.ClusterSlaveHandler;
|
|
import com.its.common.cluster.handler.ClusterSlaveHandler;
|
|
|
|
|
+import com.its.common.cluster.utils.ClusterUtils;
|
|
|
import com.its.common.cluster.vo.ClusterNode;
|
|
import com.its.common.cluster.vo.ClusterNode;
|
|
|
import io.netty.bootstrap.Bootstrap;
|
|
import io.netty.bootstrap.Bootstrap;
|
|
|
import io.netty.channel.*;
|
|
import io.netty.channel.*;
|
|
@@ -47,9 +48,8 @@ public class ClusterSlave implements Callable<Object> {
|
|
|
try {
|
|
try {
|
|
|
initializeBootstrapIfNeeded();
|
|
initializeBootstrapIfNeeded();
|
|
|
|
|
|
|
|
- if (this.clusterConfig.isLogging()) {
|
|
|
|
|
- log.info("ClusterNodeId: {}, ClusterSlave.call: Try Connect: toClusterId: {}, [{}.{}]", this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ log.info("ClusterNodeId: {}, ClusterSlave.call: Try Connect: toClusterId: {}, [{}.{}]",
|
|
|
|
|
+ this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port);
|
|
|
|
|
|
|
|
closePreviousChannel();
|
|
closePreviousChannel();
|
|
|
|
|
|
|
@@ -73,7 +73,7 @@ public class ClusterSlave implements Callable<Object> {
|
|
|
return this.channelFuture != null && this.channelFuture.isSuccess();
|
|
return this.channelFuture != null && this.channelFuture.isSuccess();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("ClusterNodeId: {}, ClusterSlave.call: Connection error toClusterId: {}, [{}.{}], Exception: {}",
|
|
log.error("ClusterNodeId: {}, ClusterSlave.call: Connection error toClusterId: {}, [{}.{}], Exception: {}",
|
|
|
- this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, e.getMessage(), e);
|
|
|
|
|
|
|
+ this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, e.getMessage());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -83,9 +83,8 @@ public class ClusterSlave implements Callable<Object> {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.clusterConfig.isLogging()) {
|
|
|
|
|
- log.info("ClusterNodeId: {}, ClusterSlave.call: Startup: toClusterId: {}, [{}.{}]", this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ log.info("ClusterNodeId: {}, ClusterSlave.call: Startup: toClusterId: {}, [{}.{}]",
|
|
|
|
|
+ this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port);
|
|
|
|
|
|
|
|
this.bootstrap = bootstrapFactory.createBootstrap();
|
|
this.bootstrap = bootstrapFactory.createBootstrap();
|
|
|
this.bootstrap.option(ChannelOption.SO_REUSEADDR, true);
|
|
this.bootstrap.option(ChannelOption.SO_REUSEADDR, true);
|
|
@@ -126,14 +125,12 @@ public class ClusterSlave implements Callable<Object> {
|
|
|
channel.attr(AbstractClusterConfig.CLUSTER_ATTRIBUTE_KEY).set(this.clusterNode);
|
|
channel.attr(AbstractClusterConfig.CLUSTER_ATTRIBUTE_KEY).set(this.clusterNode);
|
|
|
this.clusterNode.getSyncState().connect(channel);
|
|
this.clusterNode.getSyncState().connect(channel);
|
|
|
|
|
|
|
|
- if (this.clusterConfig.isLogging()) {
|
|
|
|
|
- log.info("ClusterNodeId: {}, ClusterSlave.channelOpen: toClusterId: {}, [{}.{}], Channel: {}", this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, channel);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ log.info("ClusterNodeId: {}, ClusterSlave.channelOpen: toClusterId: {}, [{}.{}], Channel: {}",
|
|
|
|
|
+ this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, ClusterUtils.getRemoteIpAddress(channel));
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- if (this.clusterConfig.isLogging()) {
|
|
|
|
|
- log.warn("ClusterNodeId: {}, ClusterSlave.channelOpen: toClusterId: {}, [{}.{}], Failed: {}", this.clusterConfig.getId(), clusterNode.getId(), clusterNode.getIp(), clusterNode.getPort(), future.cause().getMessage());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ log.warn("ClusterNodeId: {}, ClusterSlave.channelOpen: toClusterId: {}, [{}.{}], Failed: {}",
|
|
|
|
|
+ this.clusterConfig.getId(), clusterNode.getId(), clusterNode.getIp(), clusterNode.getPort(), future.cause().getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -143,9 +140,8 @@ public class ClusterSlave implements Callable<Object> {
|
|
|
protected synchronized void channelClosed(ChannelFuture future) {
|
|
protected synchronized void channelClosed(ChannelFuture future) {
|
|
|
Channel channel = future.channel();
|
|
Channel channel = future.channel();
|
|
|
|
|
|
|
|
- if (this.clusterConfig.isLogging()) {
|
|
|
|
|
- log.warn("ClusterNodeId: {}, ClusterSlave.channelClosed: toClusterId: {}, [{}.{}], Channel: {}", this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, channel);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ log.warn("ClusterNodeId: {}, ClusterSlave.channelClosed: toClusterId: {}, [{}.{}], Channel: {}",
|
|
|
|
|
+ this.clusterConfig.getId(), this.clusterNode.getId(), this.ipAddress, this.port, ClusterUtils.getRemoteIpAddress(channel));
|
|
|
|
|
|
|
|
channel.attr(AbstractClusterConfig.CLUSTER_ATTRIBUTE_KEY).set(null);
|
|
channel.attr(AbstractClusterConfig.CLUSTER_ATTRIBUTE_KEY).set(null);
|
|
|
this.clusterNode.getSyncState().disConnect();
|
|
this.clusterNode.getSyncState().disConnect();
|