Remove unsafe options

For quite some time now, our networking layer makes sure to create safe messages as in not using the shared buffers. This is great, and we should remove the old support for "unsafe" notion in our codebase.
closes #10360
This commit is contained in:
Shay Banon 2015-04-01 03:38:38 +03:00
parent 285941f0d3
commit c8f996320c
67 changed files with 138 additions and 561 deletions

View File

@ -47,7 +47,6 @@ import java.util.Map;
public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQueryRequest> {
private BytesReference source;
private boolean sourceUnsafe;
private boolean explain;
@ -74,14 +73,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
return validationException;
}
@Override
protected void beforeStart() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
}
/**
* The source to execute.
*/
@ -91,7 +82,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
public ValidateQueryRequest source(QuerySourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
@ -110,7 +100,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
public ValidateQueryRequest source(XContentBuilder builder) {
this.source = builder.bytes();
this.sourceUnsafe = false;
return this;
}
@ -120,7 +109,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
*/
public ValidateQueryRequest source(String source) {
this.source = new BytesArray(source);
this.sourceUnsafe = false;
return this;
}
@ -128,22 +116,21 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
* The source to validate.
*/
public ValidateQueryRequest source(byte[] source) {
return source(source, 0, source.length, false);
return source(source, 0, source.length);
}
/**
* The source to validate.
*/
public ValidateQueryRequest source(byte[] source, int offset, int length, boolean unsafe) {
return source(new BytesArray(source, offset, length), unsafe);
public ValidateQueryRequest source(byte[] source, int offset, int length) {
return source(new BytesArray(source, offset, length));
}
/**
* The source to validate.
*/
public ValidateQueryRequest source(BytesReference source, boolean unsafe) {
public ValidateQueryRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -180,7 +167,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQuer
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
sourceUnsafe = false;
source = in.readBytesReference();
int typesSize = in.readVInt();

View File

@ -61,17 +61,7 @@ public class ValidateQueryRequestBuilder extends BroadcastOperationRequestBuilde
* @see org.elasticsearch.index.query.QueryBuilders
*/
public ValidateQueryRequestBuilder setSource(BytesReference source) {
request().source(source, false);
return this;
}
/**
* The source to validate.
*
* @see org.elasticsearch.index.query.QueryBuilders
*/
public ValidateQueryRequestBuilder setSource(BytesReference source, boolean unsafe) {
request().source(source, unsafe);
request().source(source);
return this;
}

View File

@ -281,12 +281,12 @@ public class BulkProcessor implements Closeable {
executeIfNeeded();
}
public BulkProcessor add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(data, contentUnsafe, defaultIndex, defaultType, null);
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(data, defaultIndex, defaultType, null);
}
public synchronized BulkProcessor add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable Object payload) throws Exception {
bulkRequest.add(data, contentUnsafe, defaultIndex, defaultType, null, payload, true);
public synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable Object payload) throws Exception {
bulkRequest.add(data, defaultIndex, defaultType, null, payload, true);
executeIfNeeded();
return this;
}

View File

@ -104,12 +104,10 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
* (for example, if no id is provided, one will be generated, or usage of the create flag).
*/
public BulkRequest add(IndexRequest request) {
request.beforeLocalFork();
return internalAdd(request, null);
}
public BulkRequest add(IndexRequest request, @Nullable Object payload) {
request.beforeLocalFork();
return internalAdd(request, payload);
}
@ -222,32 +220,32 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
/**
* Adds a framed data in binary format
*/
public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe) throws Exception {
return add(data, from, length, contentUnsafe, null, null);
public BulkRequest add(byte[] data, int from, int length) throws Exception {
return add(data, from, length, null, null);
}
/**
* Adds a framed data in binary format
*/
public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(new BytesArray(data, from, length), contentUnsafe, defaultIndex, defaultType);
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(new BytesArray(data, from, length), defaultIndex, defaultType);
}
/**
* Adds a framed data in binary format
*/
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(data, contentUnsafe, defaultIndex, defaultType, null, null, true);
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
return add(data, defaultIndex, defaultType, null, null, true);
}
/**
* Adds a framed data in binary format
*/
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception {
return add(data, contentUnsafe, defaultIndex, defaultType, null, null, allowExplicitIndex);
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws Exception {
return add(data, defaultIndex, defaultType, null, null, allowExplicitIndex);
}
public BulkRequest add(BytesReference data, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable Object payload, boolean allowExplicitIndex) throws Exception {
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable Object payload, boolean allowExplicitIndex) throws Exception {
XContent xContent = XContentFactory.xContent(data);
int from = 0;
int length = data.length();
@ -336,20 +334,20 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
}
// order is important, we set parent after routing, so routing will be set to parent if not set explicitly
// we use internalAdd so we don't fork here, this allows us not to copy over the big byte array to small chunks
// of index request. All index requests are still unsafe if applicable.
// of index request.
if ("index".equals(action)) {
if (opType == null) {
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType)
.source(data.slice(from, nextMarker - from), contentUnsafe), payload);
.source(data.slice(from, nextMarker - from)), payload);
} else {
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType)
.create("create".equals(opType))
.source(data.slice(from, nextMarker - from), contentUnsafe), payload);
.source(data.slice(from, nextMarker - from)), payload);
}
} else if ("create".equals(action)) {
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).timestamp(timestamp).ttl(ttl).version(version).versionType(versionType)
.create(true)
.source(data.slice(from, nextMarker - from), contentUnsafe), payload);
.source(data.slice(from, nextMarker - from)), payload);
} else if ("update".equals(action)) {
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent).retryOnConflict(retryOnConflict)
.version(version).versionType(versionType)

View File

@ -96,16 +96,16 @@ public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkRe
/**
* Adds a framed data in binary format
*/
public BulkRequestBuilder add(byte[] data, int from, int length, boolean contentUnsafe) throws Exception {
request.add(data, from, length, contentUnsafe, null, null);
public BulkRequestBuilder add(byte[] data, int from, int length) throws Exception {
request.add(data, from, length, null, null);
return this;
}
/**
* Adds a framed data in binary format
*/
public BulkRequestBuilder add(byte[] data, int from, int length, boolean contentUnsafe, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
request.add(data, from, length, contentUnsafe, defaultIndex, defaultType);
public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
request.add(data, from, length, defaultIndex, defaultType);
return this;
}

View File

@ -74,20 +74,6 @@ public class BulkShardRequest extends ShardReplicationOperationRequest<BulkShard
return indices.toArray(new String[indices.size()]);
}
/**
* Before we fork on a local thread, make sure we copy over the bytes if they are unsafe
*/
@Override
public void beforeLocalFork() {
for (BulkItemRequest item : items) {
if (item.request() instanceof InstanceShardOperationRequest) {
((InstanceShardOperationRequest) item.request()).beforeLocalFork();
} else {
((ShardReplicationOperationRequest) item.request()).beforeLocalFork();
}
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -65,7 +65,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
private String preference;
private BytesReference source;
private boolean sourceUnsafe;
private String[] types = Strings.EMPTY_ARRAY;
@ -89,14 +88,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
return validationException;
}
@Override
protected void beforeStart() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
}
/**
* The minimum score of the documents to include in the count.
*/
@ -125,7 +116,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
*/
public CountRequest source(QuerySourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
@ -144,7 +134,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
public CountRequest source(XContentBuilder builder) {
this.source = builder.bytes();
this.sourceUnsafe = false;
return this;
}
@ -154,7 +143,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
*/
public CountRequest source(String querySource) {
this.source = new BytesArray(querySource);
this.sourceUnsafe = false;
return this;
}
@ -162,19 +150,18 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
* The source to execute.
*/
public CountRequest source(byte[] querySource) {
return source(querySource, 0, querySource.length, false);
return source(querySource, 0, querySource.length);
}
/**
* The source to execute.
*/
public CountRequest source(byte[] querySource, int offset, int length, boolean unsafe) {
return source(new BytesArray(querySource, offset, length), unsafe);
public CountRequest source(byte[] querySource, int offset, int length) {
return source(new BytesArray(querySource, offset, length));
}
public CountRequest source(BytesReference querySource, boolean unsafe) {
public CountRequest source(BytesReference querySource) {
this.source = querySource;
this.sourceUnsafe = unsafe;
return this;
}
@ -246,7 +233,6 @@ public class CountRequest extends BroadcastOperationRequest<CountRequest> {
minScore = in.readFloat();
routing = in.readOptionalString();
preference = in.readOptionalString();
sourceUnsafe = false;
source = in.readBytesReference();
types = in.readStringArray();
terminateAfter = in.readVInt();

View File

@ -112,15 +112,7 @@ public class CountRequestBuilder extends BroadcastOperationRequestBuilder<CountR
* The source to execute.
*/
public CountRequestBuilder setSource(BytesReference source) {
request().source(source, false);
return this;
}
/**
* The source to execute.
*/
public CountRequestBuilder setSource(BytesReference source, boolean unsafe) {
request().source(source, unsafe);
request().source(source);
return this;
}

View File

@ -71,7 +71,6 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
@Override
protected void doExecute(final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
request.beforeLocalFork();
createIndexAction.execute(new CreateIndexRequest(request).index(request.index()).cause("auto(delete api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse result) {

View File

@ -56,7 +56,6 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<DeleteByQueryRequest> {
private BytesReference source;
private boolean sourceUnsafe;
private String[] types = Strings.EMPTY_ARRAY;
@Nullable
@ -94,9 +93,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
* The source to execute.
*/
public BytesReference source() {
if (sourceUnsafe) {
source = source.copyBytesArray();
}
return source;
}
@ -105,7 +101,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
*/
public DeleteByQueryRequest source(QuerySourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
@ -115,7 +110,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
*/
public DeleteByQueryRequest source(String query) {
this.source = new BytesArray(query.getBytes(Charsets.UTF_8));
this.sourceUnsafe = false;
return this;
}
@ -135,7 +129,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
public DeleteByQueryRequest source(XContentBuilder builder) {
this.source = builder.bytes();
this.sourceUnsafe = false;
return this;
}
@ -143,21 +136,18 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
* The source to execute.
*/
public DeleteByQueryRequest source(byte[] source) {
return source(source, 0, source.length, false);
return source(source, 0, source.length);
}
/**
* The source to execute.
*/
public DeleteByQueryRequest source(byte[] source, int offset, int length, boolean unsafe) {
this.source = new BytesArray(source, offset, length);
this.sourceUnsafe = unsafe;
return this;
public DeleteByQueryRequest source(byte[] source, int offset, int length) {
return source(new BytesArray(source, offset, length));
}
public DeleteByQueryRequest source(BytesReference source, boolean unsafe) {
public DeleteByQueryRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -202,7 +192,6 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
sourceUnsafe = false;
source = in.readBytesReference();
routing = in.readOptionalString();
types = in.readStringArray();

View File

@ -113,23 +113,15 @@ public class DeleteByQueryRequestBuilder extends IndicesReplicationOperationRequ
* The source to execute.
*/
public DeleteByQueryRequestBuilder setSource(BytesReference source) {
request().source(source, false);
request().source(source);
return this;
}
/**
* The source to execute.
*/
public DeleteByQueryRequestBuilder setSource(BytesReference source, boolean unsafe) {
request().source(source, unsafe);
return this;
}
/**
* The source to execute.
*/
public DeleteByQueryRequestBuilder setSource(byte[] source, int offset, int length, boolean unsafe) {
request().source(source, offset, length, unsafe);
public DeleteByQueryRequestBuilder setSource(byte[] source, int offset, int length) {
request().source(source, offset, length);
return this;
}

View File

@ -50,7 +50,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
private String preference;
private BytesReference source;
private boolean sourceUnsafe;
private String[] types = Strings.EMPTY_ARRAY;
@ -74,14 +73,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
return validationException;
}
@Override
protected void beforeStart() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
}
/**
* The minimum score of the documents to include in the count.
*/
@ -145,7 +136,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
*/
public ExistsRequest source(QuerySourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
@ -164,7 +154,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
public ExistsRequest source(XContentBuilder builder) {
this.source = builder.bytes();
this.sourceUnsafe = false;
return this;
}
@ -174,7 +163,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
*/
public ExistsRequest source(String querySource) {
this.source = new BytesArray(querySource);
this.sourceUnsafe = false;
return this;
}
@ -182,19 +170,18 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
* The source to execute.
*/
public ExistsRequest source(byte[] querySource) {
return source(querySource, 0, querySource.length, false);
return source(querySource, 0, querySource.length);
}
/**
* The source to execute.
*/
public ExistsRequest source(byte[] querySource, int offset, int length, boolean unsafe) {
return source(new BytesArray(querySource, offset, length), unsafe);
public ExistsRequest source(byte[] querySource, int offset, int length) {
return source(new BytesArray(querySource, offset, length));
}
public ExistsRequest source(BytesReference querySource, boolean unsafe) {
public ExistsRequest source(BytesReference querySource) {
this.source = querySource;
this.sourceUnsafe = unsafe;
return this;
}
@ -219,7 +206,6 @@ public class ExistsRequest extends BroadcastOperationRequest<ExistsRequest> {
minScore = in.readFloat();
routing = in.readOptionalString();
preference = in.readOptionalString();
sourceUnsafe = false;
source = in.readBytesReference();
types = in.readStringArray();

View File

@ -91,15 +91,7 @@ public class ExistsRequestBuilder extends BroadcastOperationRequestBuilder<Exist
* The source to execute.
*/
public ExistsRequestBuilder setSource(BytesReference source) {
request().source(source, false);
return this;
}
/**
* The source to execute.
*/
public ExistsRequestBuilder setSource(BytesReference source, boolean unsafe) {
request().source(source, unsafe);
request().source(source);
return this;
}

View File

@ -42,7 +42,6 @@ public class ExplainRequest extends SingleShardOperationRequest<ExplainRequest>
private String routing;
private String preference;
private BytesReference source;
private boolean sourceUnsafe;
private String[] fields;
private FetchSourceContext fetchSourceContext;
@ -107,19 +106,13 @@ public class ExplainRequest extends SingleShardOperationRequest<ExplainRequest>
return source;
}
public boolean sourceUnsafe() {
return sourceUnsafe;
}
public ExplainRequest source(QuerySourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
public ExplainRequest source(BytesReference source, boolean unsafe) {
public ExplainRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -157,14 +150,6 @@ public class ExplainRequest extends SingleShardOperationRequest<ExplainRequest>
return this;
}
@Override
protected void beforeLocalFork() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
}
@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = super.validate();
@ -188,7 +173,6 @@ public class ExplainRequest extends SingleShardOperationRequest<ExplainRequest>
routing = in.readOptionalString();
preference = in.readOptionalString();
source = in.readBytesReference();
sourceUnsafe = false;
filteringAlias = in.readStringArray();
if (in.readBoolean()) {
fields = in.readStringArray();

View File

@ -158,8 +158,8 @@ public class ExplainRequestBuilder extends SingleShardOperationRequestBuilder<Ex
/**
* Sets the full source of the explain request (for example, wrapping an actual query).
*/
public ExplainRequestBuilder setSource(BytesReference source, boolean unsafe) {
request().source(source, unsafe);
public ExplainRequestBuilder setSource(BytesReference source) {
request().source(source);
return this;
}

View File

@ -138,7 +138,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
private long ttl = -1;
private BytesReference source;
private boolean sourceUnsafe;
private OpType opType = OpType.INDEX;
private boolean autoGeneratedId = false;
@ -173,7 +172,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
this.timestamp = indexRequest.timestamp;
this.ttl = indexRequest.ttl;
this.source = indexRequest.source;
this.sourceUnsafe = indexRequest.sourceUnsafe;
this.opType = indexRequest.opType;
this.autoGeneratedId = indexRequest.autoGeneratedId;
this.refresh = indexRequest.refresh;
@ -227,15 +225,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
return validationException;
}
/**
* Before we fork on a local thread, make sure we copy over the bytes if they are unsafe
*/
@Override
public void beforeLocalFork() {
// only fork if copy over if source is unsafe
safeSource();
}
/**
* Sets the content type that will be used when generating a document from user provided objects (like Map).
*/
@ -354,14 +343,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
return source;
}
public BytesReference safeSource() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
return source;
}
public Map<String, Object> sourceAsMap() {
return XContentHelper.convertToMap(source, false).v2();
}
@ -398,7 +379,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
*/
public IndexRequest source(String source) {
this.source = new BytesArray(source.getBytes(Charsets.UTF_8));
this.sourceUnsafe = false;
return this;
}
@ -407,7 +387,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
*/
public IndexRequest source(XContentBuilder sourceBuilder) {
source = sourceBuilder.bytes();
sourceUnsafe = false;
return this;
}
@ -455,6 +434,9 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
if (source.length % 2 != 0) {
throw new IllegalArgumentException("The number of object passed must be even but was [" + source.length + "]");
}
if (source.length == 2 && source[0] instanceof BytesReference && source[1] instanceof Boolean) {
throw new IllegalArgumentException("you are using the removed method for source with bytes and unsafe flag, the unsafe flag was removed, please just use source(BytesReference)");
}
try {
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.startObject();
@ -471,9 +453,8 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
/**
* Sets the document to index in bytes form.
*/
public IndexRequest source(BytesReference source, boolean unsafe) {
public IndexRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -493,20 +474,7 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
* @param length The length of the data
*/
public IndexRequest source(byte[] source, int offset, int length) {
return source(source, offset, length, false);
}
/**
* Sets the document to index in bytes form.
*
* @param source The source to index
* @param offset The offset in the byte array
* @param length The length of the data
* @param unsafe Is the byte array safe to be used form a different thread
*/
public IndexRequest source(byte[] source, int offset, int length, boolean unsafe) {
this.source = new BytesArray(source, offset, length);
this.sourceUnsafe = unsafe;
return this;
}
@ -687,7 +655,6 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
timestamp = in.readOptionalString();
ttl = in.readLong();
source = in.readBytesReference();
sourceUnsafe = false;
opType = OpType.fromId(in.readByte());
refresh = in.readBoolean();

View File

@ -78,19 +78,11 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder
return this;
}
/**
* Sets the source.
*/
public IndexRequestBuilder setSource(BytesReference source, boolean unsafe) {
request.source(source, unsafe);
return this;
}
/**
* Sets the source.
*/
public IndexRequestBuilder setSource(BytesReference source) {
request.source(source, false);
request.source(source);
return this;
}
@ -154,19 +146,6 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder
return this;
}
/**
* Sets the document to index in bytes form.
*
* @param source The source to index
* @param offset The offset in the byte array
* @param length The length of the data
* @param unsafe Is the byte array safe to be used form a different thread
*/
public IndexRequestBuilder setSource(byte[] source, int offset, int length, boolean unsafe) {
request.source(source, offset, length, unsafe);
return this;
}
/**
* Constructs a simple document with a field and a value.
*/

View File

@ -85,7 +85,6 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
protected void doExecute(final IndexRequest request, final ActionListener<IndexResponse> listener) {
// if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
request.beforeLocalFork(); // we fork on another thread...
CreateIndexRequest createIndexRequest = new CreateIndexRequest(request);
createIndexRequest.index(request.index());
createIndexRequest.mapping(request.type());

View File

@ -64,7 +64,6 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
private String id;
private BytesReference source;
private boolean sourceUnsafe;
private IndexRequest.OpType opType = IndexRequest.OpType.INDEX;
@ -171,14 +170,6 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
return source;
}
public BytesReference safeSource() {
if (sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
return source;
}
public Map<String, Object> sourceAsMap() {
return XContentHelper.convertToMap(source, false).v2();
}
@ -215,7 +206,6 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
*/
public PutIndexedScriptRequest source(String source) {
this.source = new BytesArray(source.getBytes(Charsets.UTF_8));
this.sourceUnsafe = false;
return this;
}
@ -224,7 +214,6 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
*/
public PutIndexedScriptRequest source(XContentBuilder sourceBuilder) {
source = sourceBuilder.bytes();
sourceUnsafe = false;
return this;
}
@ -248,9 +237,8 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
/**
* Sets the document to index in bytes form.
*/
public PutIndexedScriptRequest source(BytesReference source, boolean unsafe) {
public PutIndexedScriptRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -270,21 +258,7 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
* @param length The length of the data
*/
public PutIndexedScriptRequest source(byte[] source, int offset, int length) {
return source(source, offset, length, false);
}
/**
* Sets the document to index in bytes form.
*
* @param source The source to index
* @param offset The offset in the byte array
* @param length The length of the data
* @param unsafe Is the byte array safe to be used form a different thread
*/
public PutIndexedScriptRequest source(byte[] source, int offset, int length, boolean unsafe) {
this.source = new BytesArray(source, offset, length);
this.sourceUnsafe = unsafe;
return this;
return source(new BytesArray(source, offset, length));
}
/**
@ -344,7 +318,6 @@ public class PutIndexedScriptRequest extends ActionRequest<PutIndexedScriptReque
scriptLang = in.readString();
id = in.readOptionalString();
source = in.readBytesReference();
sourceUnsafe = false;
opType = IndexRequest.OpType.fromId(in.readByte());
version = in.readLong();

View File

@ -56,19 +56,11 @@ public class PutIndexedScriptRequestBuilder extends ActionRequestBuilder<PutInde
return this;
}
/**
* Sets the source.
*/
public PutIndexedScriptRequestBuilder setSource(BytesReference source, boolean unsafe) {
request.source(source, unsafe);
return this;
}
/**
* Sets the source.
*/
public PutIndexedScriptRequestBuilder setSource(BytesReference source) {
request.source(source, false);
request.source(source);
return this;
}
@ -132,20 +124,6 @@ public class PutIndexedScriptRequestBuilder extends ActionRequestBuilder<PutInde
return this;
}
/**
* Sets the document to index in bytes form.
*
* @param source The source to index
* @param offset The offset in the byte array
* @param length The length of the data
* @param unsafe Is the byte array safe to be used form a different thread
*/
public PutIndexedScriptRequestBuilder setSource(byte[] source, int offset, int length, boolean unsafe) {
request.source(source, offset, length, unsafe);
return this;
}
/**
* Constructs a simple document with a field name and value pairs.
* <b>Note: the number of objects passed to this method must be an even number.</b>

View File

@ -22,7 +22,6 @@ package org.elasticsearch.action.mlt;
import com.google.common.collect.Lists;
import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.Version;
import org.elasticsearch.action.*;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchType;
@ -33,7 +32,6 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.search.Scroll;
@ -86,7 +84,6 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
private Scroll searchScroll;
private BytesReference searchSource;
private boolean searchSourceUnsafe;
MoreLikeThisRequest() {
}
@ -401,20 +398,12 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
return this.include;
}
void beforeLocalFork() {
if (searchSourceUnsafe) {
searchSource = searchSource.copyBytesArray();
searchSourceUnsafe = false;
}
}
/**
* An optional search source request allowing to control the search request for the
* more like this documents.
*/
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
this.searchSource = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.searchSourceUnsafe = false;
return this;
}
@ -424,7 +413,6 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
*/
public MoreLikeThisRequest searchSource(String searchSource) {
this.searchSource = new BytesArray(searchSource);
this.searchSourceUnsafe = false;
return this;
}
@ -440,7 +428,6 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
public MoreLikeThisRequest searchSource(XContentBuilder builder) {
this.searchSource = builder.bytes();
this.searchSourceUnsafe = false;
return this;
}
@ -449,24 +436,23 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
* more like this documents.
*/
public MoreLikeThisRequest searchSource(byte[] searchSource) {
return searchSource(searchSource, 0, searchSource.length, false);
return searchSource(searchSource, 0, searchSource.length);
}
/**
* An optional search source request allowing to control the search request for the
* more like this documents.
*/
public MoreLikeThisRequest searchSource(byte[] searchSource, int offset, int length, boolean unsafe) {
return searchSource(new BytesArray(searchSource, offset, length), unsafe);
public MoreLikeThisRequest searchSource(byte[] searchSource, int offset, int length) {
return searchSource(new BytesArray(searchSource, offset, length));
}
/**
* An optional search source request allowing to control the search request for the
* more like this documents.
*/
public MoreLikeThisRequest searchSource(BytesReference searchSource, boolean unsafe) {
public MoreLikeThisRequest searchSource(BytesReference searchSource) {
this.searchSource = searchSource;
this.searchSourceUnsafe = unsafe;
return this;
}
@ -478,10 +464,6 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
return this.searchSource;
}
public boolean searchSourceUnsafe() {
return searchSourceUnsafe;
}
/**
* The search type of the mlt search query.
*/
@ -656,7 +638,6 @@ public class MoreLikeThisRequest extends ActionRequest<MoreLikeThisRequest> impl
searchScroll = readScroll(in);
}
searchSourceUnsafe = false;
searchSource = in.readBytesReference();
searchSize = in.readVInt();

View File

@ -132,7 +132,6 @@ public class TransportMoreLikeThisAction extends HandledTransportAction<MoreLike
.listenerThreaded(true)
.operationThreaded(true);
request.beforeLocalFork();
getAction.execute(getRequest, new ActionListener<GetResponse>() {
@Override
public void onResponse(GetResponse getResponse) {
@ -221,7 +220,7 @@ public class TransportMoreLikeThisAction extends HandledTransportAction<MoreLike
searchRequest.extraSource(extraSource);
if (request.searchSource() != null) {
searchRequest.source(request.searchSource(), request.searchSourceUnsafe());
searchRequest.source(request.searchSource());
}
searchAction.execute(searchRequest, new ActionListener<SearchResponse>() {

View File

@ -81,14 +81,14 @@ public class MultiPercolateRequest extends ActionRequest<MultiPercolateRequest>
/**
* Embeds a percolate request which request body is defined as raw bytes to this multi percolate request
*/
public MultiPercolateRequest add(byte[] data, int from, int length, boolean contentUnsafe) throws Exception {
return add(new BytesArray(data, from, length), contentUnsafe, true);
public MultiPercolateRequest add(byte[] data, int from, int length) throws Exception {
return add(new BytesArray(data, from, length), true);
}
/**
* Embeds a percolate request which request body is defined as raw bytes to this multi percolate request
*/
public MultiPercolateRequest add(BytesReference data, boolean contentUnsafe, boolean allowExplicitIndex) throws Exception {
public MultiPercolateRequest add(BytesReference data, boolean allowExplicitIndex) throws Exception {
XContent xContent = XContentFactory.xContent(data);
int from = 0;
int length = data.length();
@ -153,7 +153,7 @@ public class MultiPercolateRequest extends ActionRequest<MultiPercolateRequest>
break;
}
percolateRequest.source(data.slice(from, nextMarker - from), contentUnsafe);
percolateRequest.source(data.slice(from, nextMarker - from));
// move pointers
from = nextMarker + 1;

View File

@ -54,7 +54,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
private boolean onlyCount;
private BytesReference source;
private boolean unsafe;
private BytesReference docSource;
@ -156,17 +155,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
return this;
}
/**
* Before we fork on a local thread, make sure we copy over the bytes if they are unsafe
*/
@Override
public void beforeLocalFork() {
if (unsafe) {
source = source.copyBytesArray();
unsafe = false;
}
}
/**
* @return The request body in its raw form.
*/
@ -200,7 +188,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
*/
public PercolateRequest source(String document) {
this.source = new BytesArray(document);
this.unsafe = false;
return this;
}
@ -209,7 +196,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
*/
public PercolateRequest source(XContentBuilder documentBuilder) {
source = documentBuilder.bytes();
unsafe = false;
return this;
}
@ -224,22 +210,14 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
* Raw version of {@link #source(PercolateSourceBuilder)}
*/
public PercolateRequest source(byte[] source, int offset, int length) {
return source(source, offset, length, false);
return source(new BytesArray(source, offset, length));
}
/**
* Raw version of {@link #source(PercolateSourceBuilder)}
*/
public PercolateRequest source(byte[] source, int offset, int length, boolean unsafe) {
return source(new BytesArray(source, offset, length), unsafe);
}
/**
* Raw version of {@link #source(PercolateSourceBuilder)}
*/
public PercolateRequest source(BytesReference source, boolean unsafe) {
public PercolateRequest source(BytesReference source) {
this.source = source;
this.unsafe = unsafe;
return this;
}
@ -256,7 +234,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
} catch (Exception e) {
throw new SearchSourceBuilderException("Failed to build search source", e);
}
this.unsafe = false;
return this;
}
@ -302,7 +279,6 @@ public class PercolateRequest extends BroadcastOperationRequest<PercolateRequest
documentType = in.readString();
routing = in.readOptionalString();
preference = in.readOptionalString();
unsafe = false;
source = in.readBytesReference();
docSource = in.readBytesReference();
if (in.readBoolean()) {

View File

@ -214,15 +214,7 @@ public class PercolateRequestBuilder extends BroadcastOperationRequestBuilder<Pe
* Raw variant of {@link #setSource(PercolateSourceBuilder)}
*/
public PercolateRequestBuilder setSource(BytesReference source) {
request.source(source, false);
return this;
}
/**
* Raw variant of {@link #setSource(PercolateSourceBuilder)}
*/
public PercolateRequestBuilder setSource(BytesReference source, boolean unsafe) {
request.source(source, unsafe);
request.source(source);
return this;
}
@ -242,14 +234,6 @@ public class PercolateRequestBuilder extends BroadcastOperationRequestBuilder<Pe
return this;
}
/**
* Raw variant of {@link #setSource(PercolateSourceBuilder)}
*/
public PercolateRequestBuilder setSource(byte[] source, int offset, int length, boolean unsafe) {
request.source(source, offset, length, unsafe);
return this;
}
private PercolateSourceBuilder sourceBuilder() {
if (sourceBuilder == null) {
sourceBuilder = new PercolateSourceBuilder();

View File

@ -70,16 +70,16 @@ public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> implem
return this;
}
public MultiSearchRequest add(byte[] data, int from, int length, boolean contentUnsafe,
public MultiSearchRequest add(byte[] data, int from, int length,
@Nullable String[] indices, @Nullable String[] types, @Nullable String searchType) throws Exception {
return add(new BytesArray(data, from, length), contentUnsafe, indices, types, searchType, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true);
return add(new BytesArray(data, from, length), indices, types, searchType, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true);
}
public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IndicesOptions indicesOptions) throws Exception {
return add(data, contentUnsafe, indices, types, searchType, null, indicesOptions, true);
public MultiSearchRequest add(BytesReference data, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, IndicesOptions indicesOptions) throws Exception {
return add(data, indices, types, searchType, null, indicesOptions, true);
}
public MultiSearchRequest add(BytesReference data, boolean contentUnsafe, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IndicesOptions indicesOptions, boolean allowExplicitIndex) throws Exception {
public MultiSearchRequest add(BytesReference data, @Nullable String[] indices, @Nullable String[] types, @Nullable String searchType, @Nullable String routing, IndicesOptions indicesOptions, boolean allowExplicitIndex) throws Exception {
XContent xContent = XContentFactory.xContent(data);
int from = 0;
int length = data.length();
@ -196,7 +196,7 @@ public class MultiSearchRequest extends ActionRequest<MultiSearchRequest> implem
break;
}
searchRequest.source(data.slice(from, nextMarker - from), contentUnsafe);
searchRequest.source(data.slice(from, nextMarker - from));
// move pointers
from = nextMarker + 1;

View File

@ -70,16 +70,13 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
private String preference;
private BytesReference templateSource;
private boolean templateSourceUnsafe;
private String templateName;
private ScriptService.ScriptType templateType;
private Map<String, Object> templateParams = Collections.emptyMap();
private BytesReference source;
private boolean sourceUnsafe;
private BytesReference extraSource;
private boolean extraSourceUnsafe;
private Boolean queryCache;
private Scroll scroll;
@ -104,14 +101,11 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
this.routing = searchRequest.routing;
this.preference = searchRequest.preference;
this.templateSource = searchRequest.templateSource;
this.templateSourceUnsafe = searchRequest.templateSourceUnsafe;
this.templateName = searchRequest.templateName;
this.templateType = searchRequest.templateType;
this.templateParams = searchRequest.templateParams;
this.source = searchRequest.source;
this.sourceUnsafe = searchRequest.sourceUnsafe;
this.extraSource = searchRequest.extraSource;
this.extraSourceUnsafe = searchRequest.extraSourceUnsafe;
this.queryCache = searchRequest.queryCache;
this.scroll = searchRequest.scroll;
this.types = searchRequest.types;
@ -152,23 +146,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
return validationException;
}
public void beforeStart() {
// we always copy over if needed, the reason is that a request might fail while being search remotely
// and then we need to keep the buffer around
if (source != null && sourceUnsafe) {
source = source.copyBytesArray();
sourceUnsafe = false;
}
if (extraSource != null && extraSourceUnsafe) {
extraSource = extraSource.copyBytesArray();
extraSourceUnsafe = false;
}
if (templateSource != null && templateSourceUnsafe) {
templateSource = templateSource.copyBytesArray();
templateSourceUnsafe = false;
}
}
/**
* Sets the indices the search will be executed on.
*/
@ -273,7 +250,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
*/
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.sourceUnsafe = false;
return this;
}
@ -283,7 +259,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
*/
public SearchRequest source(String source) {
this.source = new BytesArray(source);
this.sourceUnsafe = false;
return this;
}
@ -302,7 +277,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
public SearchRequest source(XContentBuilder builder) {
this.source = builder.bytes();
this.sourceUnsafe = false;
return this;
}
@ -310,7 +284,7 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
* The search source to execute.
*/
public SearchRequest source(byte[] source) {
return source(source, 0, source.length, false);
return source(source, 0, source.length);
}
@ -318,22 +292,14 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
* The search source to execute.
*/
public SearchRequest source(byte[] source, int offset, int length) {
return source(source, offset, length, false);
return source(new BytesArray(source, offset, length));
}
/**
* The search source to execute.
*/
public SearchRequest source(byte[] source, int offset, int length, boolean unsafe) {
return source(new BytesArray(source, offset, length), unsafe);
}
/**
* The search source to execute.
*/
public SearchRequest source(BytesReference source, boolean unsafe) {
public SearchRequest source(BytesReference source) {
this.source = source;
this.sourceUnsafe = unsafe;
return this;
}
@ -360,7 +326,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
return this;
}
this.extraSource = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE);
this.extraSourceUnsafe = false;
return this;
}
@ -376,7 +341,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
public SearchRequest extraSource(XContentBuilder builder) {
this.extraSource = builder.bytes();
this.extraSourceUnsafe = false;
return this;
}
@ -385,7 +349,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
*/
public SearchRequest extraSource(String source) {
this.extraSource = new BytesArray(source);
this.extraSourceUnsafe = false;
return this;
}
@ -393,38 +356,29 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
* Allows to provide additional source that will be used as well.
*/
public SearchRequest extraSource(byte[] source) {
return extraSource(source, 0, source.length, false);
return extraSource(source, 0, source.length);
}
/**
* Allows to provide additional source that will be used as well.
*/
public SearchRequest extraSource(byte[] source, int offset, int length) {
return extraSource(source, offset, length, false);
return extraSource(new BytesArray(source, offset, length));
}
/**
* Allows to provide additional source that will be used as well.
*/
public SearchRequest extraSource(byte[] source, int offset, int length, boolean unsafe) {
return extraSource(new BytesArray(source, offset, length), unsafe);
}
/**
* Allows to provide additional source that will be used as well.
*/
public SearchRequest extraSource(BytesReference source, boolean unsafe) {
public SearchRequest extraSource(BytesReference source) {
this.extraSource = source;
this.extraSourceUnsafe = unsafe;
return this;
}
/**
* Allows to provide template as source.
*/
public SearchRequest templateSource(BytesReference template, boolean unsafe) {
public SearchRequest templateSource(BytesReference template) {
this.templateSource = template;
this.templateSourceUnsafe = unsafe;
return this;
}
@ -433,7 +387,6 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
*/
public SearchRequest templateSource(String template) {
this.templateSource = new BytesArray(template);
this.templateSourceUnsafe = false;
return this;
}
@ -558,16 +511,12 @@ public class SearchRequest extends ActionRequest<SearchRequest> implements Indic
scroll = readScroll(in);
}
sourceUnsafe = false;
source = in.readBytesReference();
extraSourceUnsafe = false;
extraSource = in.readBytesReference();
types = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
templateSourceUnsafe = false;
templateSource = in.readBytesReference();
templateName = in.readOptionalString();
templateType = ScriptService.ScriptType.readFrom(in);

View File

@ -850,21 +850,10 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
* {@link #setExtraSource(BytesReference)}.
*/
public SearchRequestBuilder setSource(BytesReference source) {
request.source(source, false);
request.source(source);
return this;
}
/**
* Sets the source of the request as a json string. Note, settings anything other
* than the search type will cause this source to be overridden, consider using
* {@link #setExtraSource(BytesReference)}.
*/
public SearchRequestBuilder setSource(BytesReference source, boolean unsafe) {
request.source(source, unsafe);
return this;
}
/**
* Sets the source of the request as a json string. Note, settings anything other
* than the search type will cause this source to be overridden, consider using
@ -879,15 +868,7 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
* Sets the source of the request as a json string. Allows to set other parameters.
*/
public SearchRequestBuilder setExtraSource(BytesReference source) {
request.extraSource(source, false);
return this;
}
/**
* Sets the source of the request as a json string. Allows to set other parameters.
*/
public SearchRequestBuilder setExtraSource(BytesReference source, boolean unsafe) {
request.extraSource(source, unsafe);
request.extraSource(source);
return this;
}
@ -975,7 +956,7 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
}
public SearchRequestBuilder setTemplateSource(BytesReference source) {
request.templateSource(source, true);
request.templateSource(source);
return this;
}

View File

@ -137,7 +137,6 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
listener.onResponse(new SearchResponse(InternalSearchResponse.empty(), null, 0, 0, buildTookInMillis(), ShardSearchFailure.EMPTY_ARRAY));
return;
}
request.beforeStart();
int shardIndex = -1;
for (final ShardIterator shardIt : shardsIts) {
shardIndex++;

View File

@ -39,7 +39,7 @@ import java.util.Arrays;
* {@link org.elasticsearch.client.Requests#suggestRequest(String...)}.
* <p/>
* <p>The request requires the suggest query source to be set either using
* {@link #suggest(org.elasticsearch.common.bytes.BytesReference)} / {@link #suggest(org.elasticsearch.common.bytes.BytesReference, boolean)}
* {@link #suggest(org.elasticsearch.common.bytes.BytesReference)} / {@link #suggest(org.elasticsearch.common.bytes.BytesReference)}
* or by using {@link #suggest(org.elasticsearch.search.suggest.SuggestBuilder)}
* (Best created using the {link @org.elasticsearch.search.suggest.SuggestBuilders)}).
*
@ -57,7 +57,6 @@ public final class SuggestRequest extends BroadcastOperationRequest<SuggestReque
private String preference;
private BytesReference suggestSource;
private boolean suggestSourceUnsafe;
SuggestRequest() {
}
@ -76,13 +75,6 @@ public final class SuggestRequest extends BroadcastOperationRequest<SuggestReque
return validationException;
}
@Override
protected void beforeStart() {
if (suggestSourceUnsafe) {
suggest(suggestSource.copyBytesArray(), false);
}
}
/**
* The Phrase to get correction suggestions for
*/
@ -94,7 +86,8 @@ public final class SuggestRequest extends BroadcastOperationRequest<SuggestReque
* set a new source for the suggest query
*/
public SuggestRequest suggest(BytesReference suggestSource) {
return suggest(suggestSource, false);
this.suggestSource = suggestSource;
return this;
}
/**
@ -112,7 +105,11 @@ public final class SuggestRequest extends BroadcastOperationRequest<SuggestReque
public SuggestRequest suggest(SuggestBuilder.SuggestionBuilder suggestionBuilder) {
return suggest(suggestionBuilder.buildAsBytes(Requests.CONTENT_TYPE));
}
public SuggestRequest suggest(String source) {
return suggest(new BytesArray(source));
}
/**
* A comma separated list of routing values to control the shards the search will be executed on.
*/
@ -171,15 +168,4 @@ public final class SuggestRequest extends BroadcastOperationRequest<SuggestReque
}
return "[" + Arrays.toString(indices) + "]" + ", suggestSource[" + sSource + "]";
}
public SuggestRequest suggest(BytesReference suggestSource, boolean contentUnsafe) {
this.suggestSource = suggestSource;
this.suggestSourceUnsafe = contentUnsafe;
return this;
}
public SuggestRequest suggest(String source) {
return suggest(new BytesArray(source));
}
}

View File

@ -76,14 +76,6 @@ public abstract class BroadcastOperationRequest<T extends BroadcastOperationRequ
return (T) this;
}
protected void beforeStart() {
}
protected void beforeLocalFork() {
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -141,7 +141,6 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
}
return;
}
request.beforeStart();
// count the local operations, and perform the non local ones
int shardIndex = -1;
for (final ShardIterator shardIt : shardsIts) {

View File

@ -186,11 +186,4 @@ public abstract class ShardReplicationOperationRequest<T extends ShardReplicatio
out.writeString(index);
out.writeBoolean(canHaveDuplicates);
}
/**
* Called before the request gets forked into a local thread.
*/
public void beforeLocalFork() {
}
}

View File

@ -88,11 +88,7 @@ public abstract class TransportIndexReplicationOperationAction<Request extends I
for (final ShardIterator shardIt : groups) {
final ShardRequest shardRequest = newShardRequestInstance(request, shardIt.shardId().id());
// TODO for now, we fork operations on shardIt of the index
shardRequest.beforeLocalFork(); // optimize for local fork
shardRequest.operationThreaded(true);
// no need for threaded listener, we will fork when its done based on the index request
shardRequest.listenerThreaded(false);
shardAction.execute(shardRequest, new ActionListener<ShardResponse>() {

View File

@ -387,7 +387,6 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
if (shard.currentNodeId().equals(observer.observedState().nodes().localNodeId())) {
try {
if (internalRequest.request().operationThreaded()) {
internalRequest.request().beforeLocalFork();
threadPool.executor(executor).execute(new Runnable() {
@Override
public void run() {
@ -457,7 +456,6 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
return;
}
// make it threaded operation so we fork on the discovery listener thread
internalRequest.request().beforeLocalFork();
internalRequest.request().operationThreaded(true);
observer.waitForNextChange(new ClusterStateObserver.Listener() {
@ -652,7 +650,6 @@ public abstract class TransportShardReplicationOperationAction<Request extends S
});
} else {
if (internalRequest.request().operationThreaded()) {
internalRequest.request().beforeLocalFork();
try {
threadPool.executor(executor).execute(new AbstractRunnable() {
@Override

View File

@ -104,9 +104,6 @@ public abstract class SingleShardOperationRequest<T extends SingleShardOperation
return (T) this;
}
protected void beforeLocalFork() {
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

View File

@ -187,7 +187,6 @@ public abstract class TransportShardSingleOperationAction<Request extends Single
}
try {
if (internalRequest.request().operationThreaded()) {
internalRequest.request().beforeLocalFork();
threadPool.executor(executor).execute(new Runnable() {
@Override
public void run() {

View File

@ -78,11 +78,6 @@ public class DfsOnlyRequest extends BroadcastOperationRequest<DfsOnlyRequest> {
return searchRequest.validate();
}
@Override
protected void beforeStart() {
searchRequest.beforeStart();
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

View File

@ -112,12 +112,6 @@ public class NettyHttpRequest extends HttpRequest {
return content.length() > 0;
}
@Override
public boolean contentUnsafe() {
// Netty http decoder always copies over the http content
return false;
}
@Override
public BytesReference content() {
return content;

View File

@ -66,11 +66,6 @@ public abstract class RestRequest extends ContextHolder implements ToXContent.Pa
public abstract boolean hasContent();
/**
* Is the byte array content safe or unsafe for usage on other threads
*/
public abstract boolean contentUnsafe();
public abstract BytesReference content();
public abstract String header(String name);

View File

@ -60,7 +60,7 @@ public class RestValidateQueryAction extends BaseRestHandler {
validateQueryRequest.listenerThreaded(false);
validateQueryRequest.indicesOptions(IndicesOptions.fromRequest(request, validateQueryRequest.indicesOptions()));
if (request.hasContent()) {
validateQueryRequest.source(request.content(), request.contentUnsafe());
validateQueryRequest.source(request.content());
} else {
String source = request.param("source");
if (source != null) {

View File

@ -63,7 +63,7 @@ public class RestPutWarmerAction extends BaseRestHandler {
SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")))
.types(Strings.splitStringByCommaToArray(request.param("type")))
.queryCache(request.paramAsBoolean("query_cache", null))
.source(request.content(), request.contentUnsafe());
.source(request.content());
searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
putWarmerRequest.searchRequest(searchRequest);
putWarmerRequest.timeout(request.paramAsTime("timeout", putWarmerRequest.timeout()));

View File

@ -82,7 +82,7 @@ public class RestBulkAction extends BaseRestHandler {
}
bulkRequest.timeout(request.paramAsTime("timeout", BulkShardRequest.DEFAULT_TIMEOUT));
bulkRequest.refresh(request.paramAsBoolean("refresh", bulkRequest.refresh()));
bulkRequest.add(request.content(), request.contentUnsafe(), defaultIndex, defaultType, defaultRouting, null, allowExplicitIndex);
bulkRequest.add(request.content(), defaultIndex, defaultType, defaultRouting, null, allowExplicitIndex);
client.bulk(bulkRequest, new RestBuilderListener<BulkResponse>(channel) {
@Override

View File

@ -61,7 +61,7 @@ public class RestCountAction extends BaseRestHandler {
countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions()));
countRequest.listenerThreaded(false);
if (request.hasContent()) {
countRequest.source(request.content(), request.contentUnsafe());
countRequest.source(request.content());
} else {
String source = request.param("source");
if (source != null) {

View File

@ -55,7 +55,7 @@ public class RestDeleteByQueryAction extends BaseRestHandler {
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(Strings.splitStringByCommaToArray(request.param("index")));
deleteByQueryRequest.listenerThreaded(false);
if (request.hasContent()) {
deleteByQueryRequest.source(request.content(), request.contentUnsafe());
deleteByQueryRequest.source(request.content());
} else {
String source = request.param("source");
if (source != null) {

View File

@ -50,7 +50,7 @@ public class RestExistsAction extends BaseRestHandler {
existsRequest.indicesOptions(IndicesOptions.fromRequest(request, existsRequest.indicesOptions()));
existsRequest.listenerThreaded(false);
if (request.hasContent()) {
existsRequest.source(request.content(), request.contentUnsafe());
existsRequest.source(request.content());
} else {
String source = request.param("source");
if (source != null) {

View File

@ -66,9 +66,9 @@ public class RestExplainAction extends BaseRestHandler {
String sourceString = request.param("source");
String queryString = request.param("q");
if (request.hasContent()) {
explainRequest.source(request.content(), request.contentUnsafe());
explainRequest.source(request.content());
} else if (sourceString != null) {
explainRequest.source(new BytesArray(request.param("source")), false);
explainRequest.source(new BytesArray(request.param("source")));
} else if (queryString != null) {
QueryStringQueryBuilder queryStringBuilder = QueryBuilders.queryStringQuery(queryString);
queryStringBuilder.defaultField(request.param("df"));

View File

@ -79,7 +79,7 @@ public class RestIndexAction extends BaseRestHandler {
if (request.hasParam("ttl")) {
indexRequest.ttl(request.paramAsTime("ttl", null).millis());
}
indexRequest.source(request.content(), request.contentUnsafe());
indexRequest.source(request.content());
indexRequest.timeout(request.paramAsTime("timeout", IndexRequest.DEFAULT_TIMEOUT));
indexRequest.refresh(request.paramAsBoolean("refresh", indexRequest.refresh()));
indexRequest.version(RestActions.parseVersion(request));

View File

@ -77,7 +77,7 @@ public class RestMoreLikeThisAction extends BaseRestHandler {
mltRequest.searchScroll(new Scroll(parseTimeValue(searchScroll, null)));
}
if (request.hasContent()) {
mltRequest.searchSource(request.content(), request.contentUnsafe());
mltRequest.searchSource(request.content());
} else {
String searchSource = request.param("search_source");
if (searchSource != null) {

View File

@ -59,7 +59,7 @@ public class RestMultiPercolateAction extends BaseRestHandler {
multiPercolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, multiPercolateRequest.indicesOptions()));
multiPercolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index")));
multiPercolateRequest.documentType(restRequest.param("type"));
multiPercolateRequest.add(RestActions.getRestContent(restRequest), restRequest.contentUnsafe(), allowExplicitIndex);
multiPercolateRequest.add(RestActions.getRestContent(restRequest), allowExplicitIndex);
client.multiPercolate(multiPercolateRequest, new RestToXContentListener<MultiPercolateResponse>(restChannel));
}

View File

@ -63,7 +63,7 @@ public class RestPercolateAction extends BaseRestHandler {
percolateRequest.documentType(restRequest.param("type"));
percolateRequest.routing(restRequest.param("routing"));
percolateRequest.preference(restRequest.param("preference"));
percolateRequest.source(RestActions.getRestContent(restRequest), restRequest.contentUnsafe());
percolateRequest.source(RestActions.getRestContent(restRequest));
percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions()));
executePercolate(percolateRequest, restChannel, client);
@ -87,7 +87,7 @@ public class RestPercolateAction extends BaseRestHandler {
percolateRequest.getRequest(getRequest);
percolateRequest.routing(restRequest.param("percolate_routing"));
percolateRequest.preference(restRequest.param("percolate_preference"));
percolateRequest.source(RestActions.getRestContent(restRequest), restRequest.contentUnsafe());
percolateRequest.source(RestActions.getRestContent(restRequest));
percolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, percolateRequest.indicesOptions()));
executePercolate(percolateRequest, restChannel, client);

View File

@ -79,7 +79,7 @@ public class RestPutIndexedScriptAction extends BaseRestHandler {
PutIndexedScriptRequest putRequest = new PutIndexedScriptRequest(getScriptLang(request), request.param("id")).listenerThreaded(false);
putRequest.version(request.paramAsLong("version", putRequest.version()));
putRequest.versionType(VersionType.fromString(request.param("version_type"), putRequest.versionType()));
putRequest.source(request.content(), request.contentUnsafe());
putRequest.source(request.content());
String sOpType = request.param("op_type");
if (sOpType != null) {
try {

View File

@ -61,7 +61,7 @@ public class RestMultiSearchAction extends BaseRestHandler {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String[] types = Strings.splitStringByCommaToArray(request.param("type"));
IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, multiSearchRequest.indicesOptions());
multiSearchRequest.add(RestActions.getRestContent(request), request.contentUnsafe(), indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex);
multiSearchRequest.add(RestActions.getRestContent(request), indices, types, request.param("search_type"), request.param("routing"), indicesOptions, allowExplicitIndex);
client.multiSearch(multiSearchRequest, new RestToXContentListener<MultiSearchResponse>(channel));
}

View File

@ -89,9 +89,9 @@ public class RestSearchAction extends BaseRestHandler {
boolean isTemplateRequest = request.path().endsWith("/template");
if (request.hasContent()) {
if (isTemplateRequest) {
searchRequest.templateSource(request.content(), request.contentUnsafe());
searchRequest.templateSource(request.content());
} else {
searchRequest.source(request.content(), request.contentUnsafe());
searchRequest.source(request.content());
}
} else {
String source = request.param("source");

View File

@ -61,7 +61,7 @@ public class RestSuggestAction extends BaseRestHandler {
suggestRequest.indicesOptions(IndicesOptions.fromRequest(request, suggestRequest.indicesOptions()));
suggestRequest.listenerThreaded(false);
if (request.hasContent()) {
suggestRequest.suggest(request.content(), request.contentUnsafe());
suggestRequest.suggest(request.content());
} else {
String source = request.param("source");
if (source != null) {

View File

@ -336,11 +336,11 @@ public class ScriptService extends AbstractComponent implements Closeable {
public void putScriptToIndex(PutIndexedScriptRequest request, ActionListener<IndexResponse> listener) {
String scriptLang = validateScriptLanguage(request.scriptLang());
//verify that the script compiles
validate(request.safeSource(), scriptLang);
validate(request.source(), scriptLang);
IndexRequest indexRequest = new IndexRequest(request).index(SCRIPT_INDEX).type(scriptLang).id(request.id())
.version(request.version()).versionType(request.versionType())
.source(request.safeSource(), true).opType(request.opType()).refresh(true); //Always refresh after indexing a template
.source(request.source()).opType(request.opType()).refresh(true); //Always refresh after indexing a template
client.index(indexRequest, listener);
}

View File

@ -33,7 +33,7 @@ public class BulkIntegrationTests extends ElasticsearchIntegrationTest {
public void testBulkIndexCreatesMapping() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/bulk-log.json");
BulkRequestBuilder bulkBuilder = new BulkRequestBuilder(client());
bulkBuilder.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
bulkBuilder.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
bulkBuilder.get();
assertBusy(new Runnable() {
@Override

View File

@ -48,7 +48,7 @@ public class BulkRequestTests extends ElasticsearchTestCase {
bulkAction = Strings.replace(bulkAction, "\r\n", "\n");
}
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
assertThat(bulkRequest.numberOfActions(), equalTo(3));
assertThat(((IndexRequest) bulkRequest.requests().get(0)).source().toBytes(), equalTo(new BytesArray("{ \"field1\" : \"value1\" }").toBytes()));
assertThat(bulkRequest.requests().get(1), instanceOf(DeleteRequest.class));
@ -59,7 +59,7 @@ public class BulkRequestTests extends ElasticsearchTestCase {
public void testSimpleBulk2() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk2.json");
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
@ -67,7 +67,7 @@ public class BulkRequestTests extends ElasticsearchTestCase {
public void testSimpleBulk3() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk3.json");
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
@ -75,7 +75,7 @@ public class BulkRequestTests extends ElasticsearchTestCase {
public void testSimpleBulk4() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk4.json");
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), true, null, null);
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
assertThat(bulkRequest.numberOfActions(), equalTo(4));
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).id(), equalTo("1"));
assertThat(((UpdateRequest) bulkRequest.requests().get(0)).retryOnConflict(), equalTo(2));
@ -94,14 +94,14 @@ public class BulkRequestTests extends ElasticsearchTestCase {
public void testBulkAllowExplicitIndex() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
try {
new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), true, null, null, false);
new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), null, null, false);
fail();
} catch (Exception e) {
}
bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk5.json");
new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), true, "test", null, false);
new BulkRequest().add(new BytesArray(bulkAction.getBytes(Charsets.UTF_8)), "test", null, false);
}
@Test

View File

@ -134,7 +134,6 @@ public class MoreLikeThisRequestTests extends ElasticsearchTestCase {
assertThat(mltRequest2.searchSource().length(), equalTo(0));
} else {
assertThat(mltRequest2.searchSource().length(), equalTo(mltRequest.searchSource().length()));
assertThat(mltRequest2.searchSourceUnsafe(), equalTo(mltRequest.searchSourceUnsafe()));
}
if (mltRequest.stopWords() != null && mltRequest.stopWords().length > 0) {

View File

@ -36,7 +36,7 @@ public class MultiPercolatorRequestTests extends ElasticsearchTestCase {
@Test
public void testParseBulkRequests() throws Exception {
byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate1.json");
MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length, false);
MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length);
assertThat(request.requests().size(), equalTo(6));
PercolateRequest percolateRequest = request.requests().get(0);
@ -123,7 +123,7 @@ public class MultiPercolatorRequestTests extends ElasticsearchTestCase {
byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate2.json");
MultiPercolateRequest request = new MultiPercolateRequest();
request.indices("my-index1").documentType("my-type1").indicesOptions(IndicesOptions.lenientExpandOpen());
request.add(data, 0, data.length, false);
request.add(data, 0, data.length);
assertThat(request.requests().size(), equalTo(3));
PercolateRequest percolateRequest = request.requests().get(0);

View File

@ -34,7 +34,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase {
@Test
public void simpleAdd() throws Exception {
byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch1.json");
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null);
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null);
assertThat(request.requests().size(), equalTo(5));
assertThat(request.requests().get(0).indices()[0], equalTo("test"));
assertThat(request.requests().get(0).indicesOptions(), equalTo(IndicesOptions.fromOptions(true, true, true, true, IndicesOptions.strictExpandOpenAndForbidClosed())));
@ -54,7 +54,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase {
@Test
public void simpleAdd2() throws Exception {
byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch2.json");
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null);
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null);
assertThat(request.requests().size(), equalTo(5));
assertThat(request.requests().get(0).indices()[0], equalTo("test"));
assertThat(request.requests().get(0).types().length, equalTo(0));
@ -72,7 +72,7 @@ public class MultiSearchRequestTests extends ElasticsearchTestCase {
@Test
public void simpleAdd3() throws Exception {
byte[] data = Streams.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch3.json");
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, false, null, null, null);
MultiSearchRequest request = new MultiSearchRequest().add(data, 0, data.length, null, null, null);
assertThat(request.requests().size(), equalTo(4));
assertThat(request.requests().get(0).indices()[0], equalTo("test0"));
assertThat(request.requests().get(0).indices()[1], equalTo("test1"));

View File

@ -430,8 +430,8 @@ public class BulkTests extends ElasticsearchIntegrationTest {
byte[] addChild = new BytesArray("{ \"update\" : { \"_index\" : \"test\", \"_type\" : \"child\", \"_id\" : \"child1\", \"parent\" : \"parent1\"}}\n" +
"{\"doc\" : { \"field1\" : \"value1\"}, \"doc_as_upsert\" : \"true\"}\n").array();
builder.add(addParent, 0, addParent.length, false);
builder.add(addChild, 0, addChild.length, false);
builder.add(addParent, 0, addParent.length);
builder.add(addChild, 0, addChild.length);
BulkResponse bulkResponse = builder.get();
assertThat(bulkResponse.getItems().length, equalTo(2));
@ -467,8 +467,8 @@ public class BulkTests extends ElasticsearchIntegrationTest {
byte[] addChild = new BytesArray("{\"update\" : { \"_id\" : \"child1\", \"_type\" : \"child\", \"_index\" : \"test\", \"parent\" : \"parent1\"} }\n" +
"{ \"script\" : \"ctx._source.field2 = 'value2'\", \"upsert\" : {\"field1\" : \"value1\"}}\n").array();
builder.add(addParent, 0, addParent.length, false);
builder.add(addChild, 0, addChild.length, false);
builder.add(addParent, 0, addParent.length);
builder.add(addChild, 0, addChild.length);
BulkResponse bulkResponse = builder.get();
assertThat(bulkResponse.getItems().length, equalTo(2));
@ -505,10 +505,10 @@ public class BulkTests extends ElasticsearchIntegrationTest {
"{\"index\" : { \"_id\" : \"child2\", \"_type\" : \"child\", \"_index\" : \"test\"} }\n" + "{ \"field1\" : \"value1\"}\n")
.array();
builder.add(addParent, 0, addParent.length, false);
builder.add(addChildOK, 0, addChildOK.length, false);
builder.add(addChildMissingRouting, 0, addChildMissingRouting.length, false);
builder.add(addChildOK, 0, addChildOK.length, false);
builder.add(addParent, 0, addParent.length);
builder.add(addChildOK, 0, addChildOK.length);
builder.add(addChildMissingRouting, 0, addChildMissingRouting.length);
builder.add(addChildOK, 0, addChildOK.length);
BulkResponse bulkResponse = builder.get();
assertThat(bulkResponse.getItems().length, equalTo(4));
@ -578,7 +578,7 @@ public class BulkTests extends ElasticsearchIntegrationTest {
"{\"index\": {\"_id\": \"2\"}}\n" +
"{\"name\": \"Good\", \"last_modified\" : \"2013-04-05\"}\n";
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get();
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get();
assertThat(bulkResponse.getItems().length, is(2));
assertThat(bulkResponse.getItems()[0].isFailed(), is(true));
assertThat(bulkResponse.getItems()[1].isFailed(), is(false));
@ -605,7 +605,7 @@ public class BulkTests extends ElasticsearchIntegrationTest {
"{\"index\": { \"_id\" : \"24000\" } }\n" +
"{\"name\": \"Good\", \"my_routing\" : \"48000\"}\n";
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get();
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get();
assertThat(bulkResponse.getItems().length, is(2));
assertThat(bulkResponse.getItems()[0].isFailed(), is(true));
assertThat(bulkResponse.getItems()[1].isFailed(), is(false));
@ -632,7 +632,7 @@ public class BulkTests extends ElasticsearchIntegrationTest {
"{\"index\": {} }\n" +
"{\"name\": \"Good\", \"my_id\" : \"48\"}\n";
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), false, "test", "type").setRefresh(true).get();
BulkResponse bulkResponse = client().prepareBulk().add(brokenBuildRequestData.getBytes(Charsets.UTF_8), 0, brokenBuildRequestData.length(), "test", "type").setRefresh(true).get();
assertThat(bulkResponse.getItems().length, is(2));
assertThat(bulkResponse.getItems()[0].isFailed(), is(true));
assertThat(bulkResponse.getItems()[1].isFailed(), is(false));

View File

@ -44,7 +44,7 @@ public class IndexRequestBuilderTests extends ElasticsearchIntegrationTest {
client().prepareIndex("test", "test").setSource((Object)"test_field", (Object)"foobar"),
client().prepareIndex("test", "test").setSource("{\"test_field\" : \"foobar\"}"),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}")),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}"), randomBoolean()),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}")),
client().prepareIndex("test", "test").setSource(new BytesArray("{\"test_field\" : \"foobar\"}").toBytes()),
client().prepareIndex("test", "test").setSource(map)
};

View File

@ -169,7 +169,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest {
String query = "{ \"template\" : { \"query\": {\"match_{{template}}\": {} } }, \"params\" : { \"template\":\"all\" } }";
BytesReference bytesRef = new BytesArray(query);
searchRequest.templateSource(bytesRef, false);
searchRequest.templateSource(bytesRef);
SearchResponse searchResponse = client().search(searchRequest).get();
assertHitCount(searchResponse, 2);
@ -183,7 +183,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest {
try {
String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\" } }";
BytesReference bytesRef = new BytesArray(query);
searchRequest.templateSource(bytesRef, false);
searchRequest.templateSource(bytesRef);
client().search(searchRequest).get();
fail("expected exception");
} catch (Exception ex) {
@ -191,7 +191,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest {
}
String query = "{ \"template\" : { \"query\": {\"match_all\": {}}, \"size\" : \"{{my_size}}\" }, \"params\" : { \"my_size\": 1 } }";
BytesReference bytesRef = new BytesArray(query);
searchRequest.templateSource(bytesRef, false);
searchRequest.templateSource(bytesRef);
SearchResponse searchResponse = client().search(searchRequest).get();
assertThat(searchResponse.getHits().hits().length, equalTo(1));

View File

@ -71,11 +71,6 @@ public class RestRequestTests extends ElasticsearchTestCase {
return false;
}
@Override
public boolean contentUnsafe() {
return false;
}
@Override
public BytesReference content() {
return null;

View File

@ -411,7 +411,7 @@ public class GeoFilterTests extends ElasticsearchIntegrationTest {
.string();
client().admin().indices().prepareCreate("countries").addMapping("country", mapping).execute().actionGet();
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, false, null, null).execute().actionGet();
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, null).execute().actionGet();
for (BulkItemResponse item : bulk.getItems()) {
assertFalse("unable to index data", item.isFailed());

View File

@ -63,11 +63,6 @@ public class FakeRestRequest extends RestRequest {
return false;
}
@Override
public boolean contentUnsafe() {
return false;
}
@Override
public BytesReference content() {
return null;