Skip to content

Commit

Permalink
Fix #183 by using node name as the cassandra broadcast address
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Royer committed Apr 18, 2018
1 parent 293c836 commit 15f8c58
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.elassandra.discovery;

import com.google.common.collect.Maps;
import com.google.common.net.InetAddresses;

import org.apache.cassandra.concurrent.Stage;
import org.apache.cassandra.concurrent.StageManager;
Expand Down Expand Up @@ -476,7 +477,7 @@ public MetaDataVersionAckListener(long version, Discovery.AckListener ackListene
clusterState.nodes().forEach((n) -> {
if (!localNode.getId().equals(n.getId()) &&
n.status() == DiscoveryNodeStatus.ALIVE &&
isNormal(Gossiper.instance.getEndpointStateForEndpoint(n.getInetAddress())))
isNormal(n))
attendees.put(n.getId(), n);
});
logger.debug("new MetaDataVersionAckListener version={} attendees={}", expectedVersion, this.attendees.keySet());
Expand Down Expand Up @@ -515,6 +516,19 @@ private boolean isMember(InetAddress endpoint) {
return !this.localAddress.equals(endpoint) && DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint).equals(localDc);
}

/**
* #183 lookup EndpointState with the node name = cassandra broadcast address.
* ES RPC adress can be different from the cassandra broadcast address.
*/
private boolean isNormal(DiscoveryNode node) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(InetAddresses.forString(node.getName()));
if (state == null) {
logger.warn("Node name=[{}] address=[{}] state not found", node.getName(), node.getInetAddress());
return false;
}
return state.isAlive() && state.getStatus().equals(VersionedValue.STATUS_NORMAL);
}

private boolean isNormal(EndpointState state) {
return state.isAlive() && state.getStatus().equals(VersionedValue.STATUS_NORMAL);
}
Expand Down

0 comments on commit 15f8c58

Please sign in to comment.