summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java')
-rw-r--r--core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java b/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java
index 681b9f0a64..ed08e5bdba 100644
--- a/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java
+++ b/core/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeReadAction.java
@@ -23,6 +23,7 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
@@ -36,22 +37,19 @@ import java.util.function.Supplier;
public abstract class TransportMasterNodeReadAction<Request extends MasterNodeReadRequest<Request>, Response extends ActionResponse>
extends TransportMasterNodeAction<Request, Response> {
- public static final String FORCE_LOCAL_SETTING = "action.master.force_local";
+ public static final Setting<Boolean> FORCE_LOCAL_SETTING = Setting.boolSetting("action.master.force_local", false, false, Setting.Scope.CLUSTER);
- private Boolean forceLocal;
+ private final boolean forceLocal;
protected TransportMasterNodeReadAction(Settings settings, String actionName, TransportService transportService,
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request) {
super(settings, actionName, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,request);
- this.forceLocal = settings.getAsBoolean(FORCE_LOCAL_SETTING, null);
+ this.forceLocal = FORCE_LOCAL_SETTING.get(settings);
}
@Override
protected final boolean localExecute(Request request) {
- if (forceLocal != null) {
- return forceLocal;
- }
- return request.local();
+ return forceLocal || request.local();
}
}