settings: Removed `action.get.realtime` setting

Closes #12543
This commit is contained in:
Martijn van Groningen 2016-04-19 15:06:14 +02:00
parent 4169b00441
commit ba08313417
19 changed files with 40 additions and 91 deletions

View File

@ -26,10 +26,8 @@ package org.elasticsearch.action;
public interface RealtimeRequest { public interface RealtimeRequest {
/** /**
* @param realtime Controls whether this request should be realtime by reading from the translog. If <code>null</code> * @param realtime Controls whether this request should be realtime by reading from the translog.
* is specified then whether the operation will be realtime depends on the api of the concrete request
* subclass.
*/ */
<R extends RealtimeRequest> R realtime(Boolean realtime); <R extends RealtimeRequest> R realtime(boolean realtime);
} }

View File

@ -57,7 +57,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
private boolean refresh = false; private boolean refresh = false;
Boolean realtime; boolean realtime = true;
private VersionType versionType = VersionType.INTERNAL; private VersionType versionType = VersionType.INTERNAL;
private long version = Versions.MATCH_ANY; private long version = Versions.MATCH_ANY;
@ -218,11 +218,11 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
} }
public boolean realtime() { public boolean realtime() {
return this.realtime == null ? true : this.realtime; return this.realtime;
} }
@Override @Override
public GetRequest realtime(Boolean realtime) { public GetRequest realtime(boolean realtime) {
this.realtime = realtime; this.realtime = realtime;
return this; return this;
} }
@ -277,12 +277,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
fields[i] = in.readString(); fields[i] = in.readString();
} }
} }
byte realtime = in.readByte(); realtime = in.readBoolean();
if (realtime == 0) {
this.realtime = false;
} else if (realtime == 1) {
this.realtime = true;
}
this.ignoreErrorsOnGeneratedFields = in.readBoolean(); this.ignoreErrorsOnGeneratedFields = in.readBoolean();
this.versionType = VersionType.fromValue(in.readByte()); this.versionType = VersionType.fromValue(in.readByte());
@ -308,13 +303,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
out.writeString(field); out.writeString(field);
} }
} }
if (realtime == null) { out.writeBoolean(realtime);
out.writeByte((byte) -1);
} else if (!realtime) {
out.writeByte((byte) 0);
} else {
out.writeByte((byte) 1);
}
out.writeBoolean(ignoreErrorsOnGeneratedFields); out.writeBoolean(ignoreErrorsOnGeneratedFields);
out.writeByte(versionType.getValue()); out.writeByte(versionType.getValue());
out.writeLong(version); out.writeLong(version);

View File

@ -150,7 +150,7 @@ public class GetRequestBuilder extends SingleShardOperationRequestBuilder<GetReq
return this; return this;
} }
public GetRequestBuilder setRealtime(Boolean realtime) { public GetRequestBuilder setRealtime(boolean realtime) {
request.realtime(realtime); request.realtime(realtime);
return this; return this;
} }

View File

@ -260,7 +260,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
} }
String preference; String preference;
Boolean realtime; boolean realtime = true;
boolean refresh; boolean refresh;
public boolean ignoreErrorsOnGeneratedFields = false; public boolean ignoreErrorsOnGeneratedFields = false;
@ -319,11 +319,11 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
} }
public boolean realtime() { public boolean realtime() {
return this.realtime == null ? true : this.realtime; return this.realtime;
} }
@Override @Override
public MultiGetRequest realtime(Boolean realtime) { public MultiGetRequest realtime(boolean realtime) {
this.realtime = realtime; this.realtime = realtime;
return this; return this;
} }
@ -509,12 +509,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
super.readFrom(in); super.readFrom(in);
preference = in.readOptionalString(); preference = in.readOptionalString();
refresh = in.readBoolean(); refresh = in.readBoolean();
byte realtime = in.readByte(); realtime = in.readBoolean();
if (realtime == 0) {
this.realtime = false;
} else if (realtime == 1) {
this.realtime = true;
}
ignoreErrorsOnGeneratedFields = in.readBoolean(); ignoreErrorsOnGeneratedFields = in.readBoolean();
int size = in.readVInt(); int size = in.readVInt();
@ -529,13 +524,7 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> implements I
super.writeTo(out); super.writeTo(out);
out.writeOptionalString(preference); out.writeOptionalString(preference);
out.writeBoolean(refresh); out.writeBoolean(refresh);
if (realtime == null) { out.writeBoolean(realtime);
out.writeByte((byte) -1);
} else if (realtime == false) {
out.writeByte((byte) 0);
} else {
out.writeByte((byte) 1);
}
out.writeBoolean(ignoreErrorsOnGeneratedFields); out.writeBoolean(ignoreErrorsOnGeneratedFields);
out.writeVInt(items.size()); out.writeVInt(items.size());

View File

@ -76,7 +76,7 @@ public class MultiGetRequestBuilder extends ActionRequestBuilder<MultiGetRequest
return this; return this;
} }
public MultiGetRequestBuilder setRealtime(Boolean realtime) { public MultiGetRequestBuilder setRealtime(boolean realtime) {
request.realtime(realtime); request.realtime(realtime);
return this; return this;
} }

View File

@ -33,7 +33,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
private int shardId; private int shardId;
private String preference; private String preference;
Boolean realtime; boolean realtime = true;
boolean refresh; boolean refresh;
boolean ignoreErrorsOnGeneratedFields = false; boolean ignoreErrorsOnGeneratedFields = false;
@ -79,10 +79,10 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
} }
public boolean realtime() { public boolean realtime() {
return this.realtime == null ? true : this.realtime; return this.realtime;
} }
public MultiGetShardRequest realtime(Boolean realtime) { public MultiGetShardRequest realtime(boolean realtime) {
this.realtime = realtime; this.realtime = realtime;
return this; return this;
} }
@ -129,12 +129,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
preference = in.readOptionalString(); preference = in.readOptionalString();
refresh = in.readBoolean(); refresh = in.readBoolean();
byte realtime = in.readByte(); realtime = in.readBoolean();
if (realtime == 0) {
this.realtime = false;
} else if (realtime == 1) {
this.realtime = true;
}
ignoreErrorsOnGeneratedFields = in.readBoolean(); ignoreErrorsOnGeneratedFields = in.readBoolean();
} }
@ -150,13 +145,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
out.writeOptionalString(preference); out.writeOptionalString(preference);
out.writeBoolean(refresh); out.writeBoolean(refresh);
if (realtime == null) { out.writeBoolean(realtime);
out.writeByte((byte) -1);
} else if (!realtime) {
out.writeByte((byte) 0);
} else {
out.writeByte((byte) 1);
}
out.writeBoolean(ignoreErrorsOnGeneratedFields); out.writeBoolean(ignoreErrorsOnGeneratedFields);
} }

View File

@ -44,7 +44,6 @@ import org.elasticsearch.transport.TransportService;
public class TransportGetAction extends TransportSingleShardAction<GetRequest, GetResponse> { public class TransportGetAction extends TransportSingleShardAction<GetRequest, GetResponse> {
private final IndicesService indicesService; private final IndicesService indicesService;
private final boolean realtime;
@Inject @Inject
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService, public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
@ -53,8 +52,6 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
GetRequest::new, ThreadPool.Names.GET); GetRequest::new, ThreadPool.Names.GET);
this.indicesService = indicesService; this.indicesService = indicesService;
this.realtime = settings.getAsBoolean("action.get.realtime", true);
} }
@Override @Override
@ -70,9 +67,6 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
@Override @Override
protected void resolveRequest(ClusterState state, InternalRequest request) { protected void resolveRequest(ClusterState state, InternalRequest request) {
if (request.request().realtime == null) {
request.request().realtime = this.realtime;
}
IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex()); IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex());
if (request.request().realtime && // if the realtime flag is set if (request.request().realtime && // if the realtime flag is set
request.request().preference() == null && // the preference flag is not already set request.request().preference() == null && // the preference flag is not already set

View File

@ -43,8 +43,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
private final IndicesService indicesService; private final IndicesService indicesService;
private final boolean realtime;
@Inject @Inject
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService, public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters, IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
@ -52,8 +50,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
MultiGetShardRequest::new, ThreadPool.Names.GET); MultiGetShardRequest::new, ThreadPool.Names.GET);
this.indicesService = indicesService; this.indicesService = indicesService;
this.realtime = settings.getAsBoolean("action.get.realtime", true);
} }
@Override @Override
@ -77,13 +73,6 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
.getShards(state, request.request().index(), request.request().shardId(), request.request().preference()); .getShards(state, request.request().index(), request.request().shardId(), request.request().preference());
} }
@Override
protected void resolveRequest(ClusterState state, InternalRequest request) {
if (request.request().realtime == null) {
request.request().realtime = this.realtime;
}
}
@Override @Override
protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, ShardId shardId) { protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, ShardId shardId) {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());

View File

@ -173,7 +173,7 @@ public class MultiTermVectorsRequest extends ActionRequest<MultiTermVectorsReque
} }
@Override @Override
public MultiTermVectorsRequest realtime(Boolean realtime) { public MultiTermVectorsRequest realtime(boolean realtime) {
for (TermVectorsRequest request : requests) { for (TermVectorsRequest request : requests) {
request.realtime(realtime); request.realtime(realtime);
} }

View File

@ -78,7 +78,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
// TODO: change to String[] // TODO: change to String[]
private Set<String> selectedFields; private Set<String> selectedFields;
Boolean realtime; private boolean realtime = true;
private Map<String, String> perFieldAnalyzer; private Map<String, String> perFieldAnalyzer;
@ -394,14 +394,11 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
* Return whether term vectors should be generated real-time (default to true). * Return whether term vectors should be generated real-time (default to true).
*/ */
public boolean realtime() { public boolean realtime() {
return this.realtime == null ? true : this.realtime; return this.realtime;
} }
/**
* Choose whether term vectors be generated real-time.
*/
@Override @Override
public TermVectorsRequest realtime(Boolean realtime) { public TermVectorsRequest realtime(boolean realtime) {
this.realtime = realtime; this.realtime = realtime;
return this; return this;
} }
@ -559,7 +556,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
if (filterSettings != null) { if (filterSettings != null) {
filterSettings.writeTo(out); filterSettings.writeTo(out);
} }
out.writeBoolean(realtime()); out.writeBoolean(realtime);
out.writeByte(versionType.getValue()); out.writeByte(versionType.getValue());
out.writeLong(version); out.writeLong(version);
} }

View File

@ -161,7 +161,7 @@ public class TermVectorsRequestBuilder extends ActionRequestBuilder<TermVectorsR
/** /**
* Sets whether term vectors are generated real-time. * Sets whether term vectors are generated real-time.
*/ */
public TermVectorsRequestBuilder setRealtime(Boolean realtime) { public TermVectorsRequestBuilder setRealtime(boolean realtime) {
request.realtime(realtime); request.realtime(realtime);
return this; return this;
} }

View File

@ -60,7 +60,7 @@ public class RestGetAction extends BaseRestHandler {
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
getRequest.parent(request.param("parent")); getRequest.parent(request.param("parent"));
getRequest.preference(request.param("preference")); getRequest.preference(request.param("preference"));
getRequest.realtime(request.paramAsBoolean("realtime", null)); getRequest.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
getRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false)); getRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
String sField = request.param("fields"); String sField = request.param("fields");

View File

@ -60,7 +60,7 @@ public class RestGetSourceAction extends BaseRestHandler {
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
getRequest.parent(request.param("parent")); getRequest.parent(request.param("parent"));
getRequest.preference(request.param("preference")); getRequest.preference(request.param("preference"));
getRequest.realtime(request.paramAsBoolean("realtime", null)); getRequest.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request)); getRequest.fetchSourceContext(FetchSourceContext.parseFromRestRequest(request));

View File

@ -57,7 +57,7 @@ public class RestHeadAction extends BaseRestHandler {
getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing getRequest.routing(request.param("routing")); // order is important, set it after routing, so it will set the routing
getRequest.parent(request.param("parent")); getRequest.parent(request.param("parent"));
getRequest.preference(request.param("preference")); getRequest.preference(request.param("preference"));
getRequest.realtime(request.paramAsBoolean("realtime", null)); getRequest.realtime(request.paramAsBoolean("realtime", getRequest.realtime()));
// don't get any fields back... // don't get any fields back...
getRequest.fields(Strings.EMPTY_ARRAY); getRequest.fields(Strings.EMPTY_ARRAY);
// TODO we can also just return the document size as Content-Length // TODO we can also just return the document size as Content-Length

View File

@ -58,7 +58,7 @@ public class RestMultiGetAction extends BaseRestHandler {
MultiGetRequest multiGetRequest = new MultiGetRequest(); MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh()));
multiGetRequest.preference(request.param("preference")); multiGetRequest.preference(request.param("preference"));
multiGetRequest.realtime(request.paramAsBoolean("realtime", null)); multiGetRequest.realtime(request.paramAsBoolean("realtime", multiGetRequest.realtime()));
multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false)); multiGetRequest.ignoreErrorsOnGeneratedFields(request.paramAsBoolean("ignore_errors_on_generated_fields", false));
String[] sFields = null; String[] sFields = null;

View File

@ -83,7 +83,7 @@ public class RestPercolateAction extends BaseRestHandler {
getRequest.routing(restRequest.param("routing")); getRequest.routing(restRequest.param("routing"));
getRequest.preference(restRequest.param("preference")); getRequest.preference(restRequest.param("preference"));
getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh())); getRequest.refresh(restRequest.paramAsBoolean("refresh", getRequest.refresh()));
getRequest.realtime(restRequest.paramAsBoolean("realtime", null)); getRequest.realtime(restRequest.paramAsBoolean("realtime", getRequest.realtime()));
getRequest.version(RestActions.parseVersion(restRequest)); getRequest.version(RestActions.parseVersion(restRequest));
getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType())); getRequest.versionType(VersionType.fromString(restRequest.param("version_type"), getRequest.versionType()));

View File

@ -82,7 +82,7 @@ public class RestTermVectorsAction extends BaseRestHandler {
termVectorsRequest.positions(request.paramAsBoolean("positions", termVectorsRequest.positions())); termVectorsRequest.positions(request.paramAsBoolean("positions", termVectorsRequest.positions()));
termVectorsRequest.payloads(request.paramAsBoolean("payloads", termVectorsRequest.payloads())); termVectorsRequest.payloads(request.paramAsBoolean("payloads", termVectorsRequest.payloads()));
termVectorsRequest.routing(request.param("routing")); termVectorsRequest.routing(request.param("routing"));
termVectorsRequest.realtime(request.paramAsBoolean("realtime", null)); termVectorsRequest.realtime(request.paramAsBoolean("realtime", termVectorsRequest.realtime()));
termVectorsRequest.version(RestActions.parseVersion(request, termVectorsRequest.version())); termVectorsRequest.version(RestActions.parseVersion(request, termVectorsRequest.version()));
termVectorsRequest.versionType(VersionType.fromString(request.param("version_type"), termVectorsRequest.versionType())); termVectorsRequest.versionType(VersionType.fromString(request.param("version_type"), termVectorsRequest.versionType()));
termVectorsRequest.parent(request.param("parent")); termVectorsRequest.parent(request.param("parent"));

View File

@ -46,11 +46,8 @@ curl -XHEAD -i 'http://localhost:9200/twitter/tweet/1'
=== Realtime === Realtime
By default, the get API is realtime, and is not affected by the refresh By default, the get API is realtime, and is not affected by the refresh
rate of the index (when data will become visible for search). rate of the index (when data will become visible for search). In order
to disable realtime GET, one can set `realtime` parameter to `false`.
In order to disable realtime GET, one can either set `realtime`
parameter to `false`, or globally default it to by setting the
`action.get.realtime` to `false` in the node configuration.
When getting a document, one can specify `fields` to fetch from it. They When getting a document, one can specify `fields` to fetch from it. They
will, when possible, be fetched as stored fields (fields mapped as will, when possible, be fetched as stored fields (fields mapped as

View File

@ -231,3 +231,10 @@ The `discovery.zen.minimum_master_node` must bet set for nodes that have
`transport.host`, `transport.bind_host`, or `transport.publish_host` `transport.host`, `transport.bind_host`, or `transport.publish_host`
configuration options set. We see those nodes as in "production" mode configuration options set. We see those nodes as in "production" mode
and thus require the setting. and thus require the setting.
==== Realtime get setting
The `action.get.realtime` setting has been removed. This setting was
a fallback realtime setting for the get and mget APIs when realtime
wasn't specified. Now if the parameter isn't specified we always
default to true.