From 289b238fc2c2172f1886ab56d8b920ab3491f1ab Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Wed, 22 Feb 2017 19:36:21 +0100 Subject: [PATCH] Don't set local node on cluster state used for node join validation --- .../discovery/zen/MembershipAction.java | 14 ++++---------- .../elasticsearch/discovery/zen/ZenDiscovery.java | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/MembershipAction.java b/core/src/main/java/org/elasticsearch/discovery/zen/MembershipAction.java index c65542093d353..6f56a547d3fba 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/MembershipAction.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/MembershipAction.java @@ -39,7 +39,6 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; public class MembershipAction extends AbstractComponent { @@ -63,8 +62,7 @@ public interface MembershipListener { private final MembershipListener listener; - public MembershipAction(Settings settings, TransportService transportService, - Supplier localNodeSupplier, MembershipListener listener) { + public MembershipAction(Settings settings, TransportService transportService, MembershipListener listener) { super(settings); this.transportService = transportService; this.listener = listener; @@ -73,7 +71,7 @@ public MembershipAction(Settings settings, TransportService transportService, transportService.registerRequestHandler(DISCOVERY_JOIN_ACTION_NAME, JoinRequest::new, ThreadPool.Names.GENERIC, new JoinRequestRequestHandler()); transportService.registerRequestHandler(DISCOVERY_JOIN_VALIDATE_ACTION_NAME, - () -> new ValidateJoinRequest(localNodeSupplier), ThreadPool.Names.GENERIC, + () -> new ValidateJoinRequest(), ThreadPool.Names.GENERIC, new ValidateJoinRequestRequestHandler()); transportService.registerRequestHandler(DISCOVERY_LEAVE_ACTION_NAME, LeaveRequest::new, ThreadPool.Names.GENERIC, new LeaveRequestRequestHandler()); @@ -155,22 +153,18 @@ public void onFailure(Exception e) { } static class ValidateJoinRequest extends TransportRequest { - private final Supplier localNode; private ClusterState state; - ValidateJoinRequest(Supplier localNode) { - this.localNode = localNode; - } + ValidateJoinRequest() {} ValidateJoinRequest(ClusterState state) { this.state = state; - this.localNode = state.nodes()::getLocalNode; } @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - this.state = ClusterState.readFrom(in, localNode.get()); + this.state = ClusterState.readFrom(in, null); } @Override diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index 94c46ed867094..be6f52fc22c0c 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -191,7 +191,7 @@ public ZenDiscovery(Settings settings, ThreadPool threadPool, TransportService t new NewPendingClusterStateListener(), discoverySettings, clusterService.getClusterName()); - this.membership = new MembershipAction(settings, transportService, this::localNode, new MembershipListener()); + this.membership = new MembershipAction(settings, transportService, new MembershipListener()); this.joinThreadControl = new JoinThreadControl(); transportService.registerRequestHandler(