+ private void memberReachable(ClusterEvent.ReachableMember message) {
+ String memberName = message.member().roles().head();
+ LOG.debug("Received ReachableMember: memberName {}, address: {}", memberName, message.member().address());
+
+ markMemberAvailable(memberName);
+ }
+
+ private void memberUnreachable(ClusterEvent.UnreachableMember message) {
+ String memberName = message.member().roles().head();
+ LOG.debug("Received UnreachableMember: memberName {}, address: {}", memberName, message.member().address());
+
+ markMemberUnavailable(memberName);
+ }
+
+ private void markMemberUnavailable(final String memberName) {
+ for(ShardInformation info : localShards.values()){
+ String leaderId = info.getLeaderId();
+ if(leaderId != null && leaderId.contains(memberName)) {
+ LOG.debug("Marking Leader {} as unavailable.", leaderId);
+ info.setLeaderAvailable(false);
+
+ primaryShardInfoCache.remove(info.getShardName());
+ }
+ }
+ }
+
+ private void markMemberAvailable(final String memberName) {
+ for(ShardInformation info : localShards.values()){
+ String leaderId = info.getLeaderId();
+ if(leaderId != null && leaderId.contains(memberName)) {
+ LOG.debug("Marking Leader {} as available.", leaderId);
+ info.setLeaderAvailable(true);
+ }
+ }
+ }
+