Skip to content

Commit

Permalink
重构MessagingService
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed May 5, 2015
1 parent 33bbf87 commit a90a80d
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 244 deletions.
Expand Up @@ -547,7 +547,7 @@ public void removeEndpoint(InetAddress endpoint) {
unreachableEndpoints.remove(endpoint);
// do not remove endpointState until the quarantine expires
FailureDetector.instance.remove(endpoint);
MessagingService.instance().resetVersion(endpoint);
MessagingService.instance().removeVersion(endpoint);
quarantineEndpoint(endpoint);
MessagingService.instance().destroyConnectionPool(endpoint);
if (logger.isDebugEnabled())
Expand Down
Expand Up @@ -197,7 +197,7 @@ public VersionedValue releaseVersion() {
}

public VersionedValue networkVersion() {
return new VersionedValue(String.valueOf(MessagingService.current_version));
return new VersionedValue(String.valueOf(MessagingService.CURRENT_VERSION));
}

public VersionedValue internalIP(String private_ip) {
Expand Down
Expand Up @@ -50,7 +50,7 @@ private void reconnect(InetAddress publicAddress, VersionedValue localAddressVal
InetAddress localAddress = InetAddress.getByName(localAddressValue.value);

if (snitch.getDatacenter(publicAddress).equals(localDc)
&& MessagingService.instance().getVersion(publicAddress) == MessagingService.current_version
&& MessagingService.instance().getVersion(publicAddress) == MessagingService.CURRENT_VERSION
&& !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress)) {

MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress);
Expand Down
Expand Up @@ -94,7 +94,7 @@ private void close() {
private void receiveMessages() throws IOException {
// handshake (true) endpoint versions
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeInt(MessagingService.current_version);
out.writeInt(MessagingService.CURRENT_VERSION);
out.flush();
DataInputStream in = new DataInputStream(socket.getInputStream());
int maxVersion = in.readInt();
Expand All @@ -117,7 +117,7 @@ private void receiveMessages() throws IOException {
in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), 4096));
}

if (version > MessagingService.current_version) {
if (version > MessagingService.CURRENT_VERSION) {
// save the endpoint so gossip will reconnect to it
Gossiper.instance.addSavedEndpoint(from);
logger.info("Received messages from newer protocol version {}. Ignoring", version);
Expand Down

0 comments on commit a90a80d

Please sign in to comment.