more docs
This commit is contained in:
parent
bcca36fa67
commit
372bdec45f
|
@ -35,7 +35,14 @@ import static org.elasticsearch.util.settings.ImmutableSettings.Builder.*;
|
|||
import static org.elasticsearch.util.settings.ImmutableSettings.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A request to create an index. Best created with {@link org.elasticsearch.client.Requests#createIndexRequest(String)}.
|
||||
*
|
||||
* <p>The index created can optionally be created with {@link #settings(org.elasticsearch.util.settings.Settings)}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#create(CreateIndexRequest)
|
||||
* @see org.elasticsearch.client.Requests#createIndexRequest(String)
|
||||
* @see CreateIndexResponse
|
||||
*/
|
||||
public class CreateIndexRequest extends MasterNodeOperationRequest {
|
||||
|
||||
|
@ -45,18 +52,24 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
|||
|
||||
private TimeValue timeout = new TimeValue(10, TimeUnit.SECONDS);
|
||||
|
||||
CreateIndexRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new request to create an index with the specified name.
|
||||
*/
|
||||
public CreateIndexRequest(String index) {
|
||||
this(index, EMPTY_SETTINGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new request to create an index with the specified name and settings.
|
||||
*/
|
||||
public CreateIndexRequest(String index, Settings settings) {
|
||||
this.index = index;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
CreateIndexRequest() {
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (index == null) {
|
||||
|
@ -65,23 +78,40 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The index name to create.
|
||||
*/
|
||||
String index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to created the index with.
|
||||
*/
|
||||
Settings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to created the index with.
|
||||
*/
|
||||
public CreateIndexRequest settings(Settings settings) {
|
||||
this.settings = settings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait for the index creation to be acknowledged by current cluster nodes. Defaults
|
||||
* to <tt>10s</tt>.
|
||||
*/
|
||||
TimeValue timeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait for the index creation to be acknowledged by current cluster nodes. Defaults
|
||||
* to <tt>10s</tt>.
|
||||
*/
|
||||
public CreateIndexRequest timeout(TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
|
|
|
@ -27,7 +27,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A response for a create index action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class CreateIndexResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -36,10 +38,14 @@ public class CreateIndexResponse implements ActionResponse, Streamable {
|
|||
CreateIndexResponse() {
|
||||
}
|
||||
|
||||
public CreateIndexResponse(boolean acknowledged) {
|
||||
CreateIndexResponse(boolean acknowledged) {
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the index creation been acknowledged by all current cluster nodes within the
|
||||
* provided {@link CreateIndexRequest#timeout(org.elasticsearch.util.TimeValue)}.
|
||||
*/
|
||||
public boolean acknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ import org.elasticsearch.transport.TransportService;
|
|||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Create index action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportCreateIndexAction extends TransportMasterNodeOperationAction<CreateIndexRequest, CreateIndexResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create index action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.create;
|
|
@ -31,7 +31,9 @@ import static org.elasticsearch.action.Actions.*;
|
|||
import static org.elasticsearch.util.TimeValue.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A request to delete an index. Best created with {@link org.elasticsearch.client.Requests#deleteIndexRequest(String)}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
||||
|
||||
|
@ -39,11 +41,14 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
|||
|
||||
private TimeValue timeout = timeValueSeconds(10);
|
||||
|
||||
public DeleteIndexRequest(String index) {
|
||||
this.index = index;
|
||||
DeleteIndexRequest() {
|
||||
}
|
||||
|
||||
DeleteIndexRequest() {
|
||||
/**
|
||||
* Constructs a new delete index request for the specified index.
|
||||
*/
|
||||
public DeleteIndexRequest(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
|
@ -54,14 +59,25 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* The index to delete.
|
||||
*/
|
||||
String index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait for the index deletion to be acknowledged by current cluster nodes. Defaults
|
||||
* to <tt>10s</tt>.
|
||||
*/
|
||||
TimeValue timeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait for the index deletion to be acknowledged by current cluster nodes. Defaults
|
||||
* to <tt>10s</tt>.
|
||||
*/
|
||||
public DeleteIndexRequest timeout(TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
|
|
|
@ -27,7 +27,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A response for a delete index action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class DeleteIndexResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -36,10 +38,14 @@ public class DeleteIndexResponse implements ActionResponse, Streamable {
|
|||
DeleteIndexResponse() {
|
||||
}
|
||||
|
||||
public DeleteIndexResponse(boolean acknowledged) {
|
||||
DeleteIndexResponse(boolean acknowledged) {
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the index deletion been acknowledged by all current cluster nodes within the
|
||||
* provided {@link DeleteIndexRequest#timeout(org.elasticsearch.util.TimeValue)}.
|
||||
*/
|
||||
public boolean acknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@ import org.elasticsearch.transport.TransportService;
|
|||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Delete index action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportDeleteIndexAction extends TransportMasterNodeOperationAction<DeleteIndexRequest, DeleteIndexResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete index action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.delete;
|
|
@ -27,7 +27,16 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A flush request to flush one or more indices. The flush process of an index basically frees memory from the index
|
||||
* by flushing data to the index storage and clearing the internal transaction log. By default, ElasticSearch uses
|
||||
* memory heuristics in order to automatically trigger flush operations as required in order to clear memory.
|
||||
*
|
||||
* <p>Best created with {@link org.elasticsearch.client.Requests#flushRequest(String...)}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.Requests#flushRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#flush(FlushRequest)
|
||||
* @see FlushResponse
|
||||
*/
|
||||
public class FlushRequest extends BroadcastOperationRequest {
|
||||
|
||||
|
@ -37,26 +46,42 @@ public class FlushRequest extends BroadcastOperationRequest {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new flush request against one or more indices. If nothing is provided, all indices will
|
||||
* be flushed.
|
||||
*/
|
||||
public FlushRequest(String... indices) {
|
||||
super(indices, null);
|
||||
// we want to do the refresh in parallel on local shards...
|
||||
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a refresh be performed once the flush is done. Defaults to <tt>false</tt>.
|
||||
*/
|
||||
public boolean refresh() {
|
||||
return this.refresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a refresh be performed once the flush is done. Defaults to <tt>false</tt>.
|
||||
*/
|
||||
public FlushRequest refresh(boolean refresh) {
|
||||
this.refresh = refresh;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public FlushRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override public FlushRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
|
|
|
@ -28,7 +28,9 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A response to flush action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FlushResponse extends BroadcastOperationResponse {
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardFlushRequest extends BroadcastShardOperationRequest {
|
||||
class ShardFlushRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private boolean refresh;
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardFlushResponse extends BroadcastShardOperationResponse {
|
||||
class ShardFlushResponse extends BroadcastShardOperationResponse {
|
||||
|
||||
ShardFlushResponse() {
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
|||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Flush Action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportFlushAction extends TransportBroadcastOperationAction<FlushRequest, FlushResponse, ShardFlushRequest, ShardFlushResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Flush index/indices action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.flush;
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indices Gateway Administrative Actions.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.gateway;
|
|
@ -23,18 +23,32 @@ import org.elasticsearch.action.support.replication.IndicesReplicationOperationR
|
|||
import org.elasticsearch.util.TimeValue;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Gateway snapshot allows to explicitly perform a snapshot through the gateway of one or more indices (backup them).
|
||||
* By default, each index gateway periodically snapshot changes, though it can be disabled and be controlled completely
|
||||
* through this API. Best created using {@link org.elasticsearch.client.Requests#gatewaySnapshotRequest(String...)}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.Requests#gatewaySnapshotRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#gatewaySnapshot(GatewaySnapshotRequest)
|
||||
* @see GatewaySnapshotResponse
|
||||
*/
|
||||
public class GatewaySnapshotRequest extends IndicesReplicationOperationRequest {
|
||||
|
||||
public GatewaySnapshotRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
GatewaySnapshotRequest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new gateway snapshot against one or more indices. No indices means the gateway snapshot
|
||||
* will be executed against all indices.
|
||||
*/
|
||||
public GatewaySnapshotRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public GatewaySnapshotRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
|
|
|
@ -26,25 +26,38 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Reponse for the gateway snapshot action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GatewaySnapshotResponse implements ActionResponse, Streamable {
|
||||
public class GatewaySnapshotResponse implements ActionResponse, Streamable, Iterable<IndexGatewaySnapshotResponse> {
|
||||
|
||||
private Map<String, IndexGatewaySnapshotResponse> indexResponses = new HashMap<String, IndexGatewaySnapshotResponse>();
|
||||
private Map<String, IndexGatewaySnapshotResponse> indices = new HashMap<String, IndexGatewaySnapshotResponse>();
|
||||
|
||||
GatewaySnapshotResponse() {
|
||||
|
||||
}
|
||||
|
||||
public Map<String, IndexGatewaySnapshotResponse> indices() {
|
||||
return indexResponses;
|
||||
@Override public Iterator<IndexGatewaySnapshotResponse> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of index level responses of the gateway snapshot operation.
|
||||
*/
|
||||
public Map<String, IndexGatewaySnapshotResponse> indices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* The index level gateway snapshot response for the given index.
|
||||
*/
|
||||
public IndexGatewaySnapshotResponse index(String index) {
|
||||
return indexResponses.get(index);
|
||||
return indices.get(index);
|
||||
}
|
||||
|
||||
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
||||
|
@ -52,13 +65,13 @@ public class GatewaySnapshotResponse implements ActionResponse, Streamable {
|
|||
for (int i = 0; i < size; i++) {
|
||||
IndexGatewaySnapshotResponse response = new IndexGatewaySnapshotResponse();
|
||||
response.readFrom(in);
|
||||
indexResponses.put(response.index(), response);
|
||||
indices.put(response.index(), response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void writeTo(DataOutput out) throws IOException {
|
||||
out.writeInt(indexResponses.size());
|
||||
for (IndexGatewaySnapshotResponse indexGatewaySnapshotResponse : indexResponses.values()) {
|
||||
out.writeInt(indices.size());
|
||||
for (IndexGatewaySnapshotResponse indexGatewaySnapshotResponse : indices.values()) {
|
||||
indexGatewaySnapshotResponse.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexGatewaySnapshotRequest extends IndexReplicationOperationRequest {
|
||||
|
||||
public IndexGatewaySnapshotRequest(String index) {
|
||||
IndexGatewaySnapshotRequest(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* An index level gateway snapshot response.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable {
|
||||
|
||||
|
@ -47,18 +49,30 @@ public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* The index the gateway snapshot has performed on.
|
||||
*/
|
||||
public String index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of successful shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int successfulShards() {
|
||||
return successfulShards;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of failed shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int failedShards() {
|
||||
return failedShards;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of total shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int totalShards() {
|
||||
return successfulShards + failedShards;
|
||||
}
|
||||
|
|
|
@ -26,18 +26,18 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardGatewaySnapshotRequest extends ShardReplicationOperationRequest {
|
||||
class ShardGatewaySnapshotRequest extends ShardReplicationOperationRequest {
|
||||
|
||||
private int shardId;
|
||||
|
||||
public ShardGatewaySnapshotRequest(IndexGatewaySnapshotRequest request, int shardId) {
|
||||
ShardGatewaySnapshotRequest(IndexGatewaySnapshotRequest request, int shardId) {
|
||||
this(request.index(), shardId);
|
||||
timeout = request.timeout();
|
||||
}
|
||||
|
||||
public ShardGatewaySnapshotRequest(String index, int shardId) {
|
||||
ShardGatewaySnapshotRequest(String index, int shardId) {
|
||||
this.index = index;
|
||||
this.shardId = shardId;
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardGatewaySnapshotResponse implements ActionResponse, Streamable {
|
||||
class ShardGatewaySnapshotResponse implements ActionResponse, Streamable {
|
||||
|
||||
ShardGatewaySnapshotResponse() {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* GAteway Snapshot Action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.gateway.snapshot;
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indices Mapping Administrative Actions.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.mapping;
|
|
@ -19,10 +19,12 @@
|
|||
|
||||
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
|
||||
import org.elasticsearch.util.Required;
|
||||
import org.elasticsearch.util.TimeValue;
|
||||
import org.elasticsearch.util.json.JsonBuilder;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
@ -33,7 +35,17 @@ import static org.elasticsearch.action.Actions.*;
|
|||
import static org.elasticsearch.util.TimeValue.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Puts mapping definition registered under a specific type into one or more indices. Best created with
|
||||
* {@link org.elasticsearch.client.Requests#putMappingRequest(String...)}.
|
||||
*
|
||||
* <p>If the mappings already exists, the new mappings will be merged with the new one. If there are elements
|
||||
* that can't be merged are detected, the request will be rejected unless the {@link #ignoreDuplicates(boolean)}
|
||||
* is set. In such a case, the duplicate mappings will be rejected.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.Requests#putMappingRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#putMapping(PutMappingRequest)
|
||||
* @see PutMappingResponse
|
||||
*/
|
||||
public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||
|
||||
|
@ -50,20 +62,14 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
|||
PutMappingRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new put mapping request against one or more indices. If nothing is set then
|
||||
* it will be executed against all indices.
|
||||
*/
|
||||
public PutMappingRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
public PutMappingRequest(String index, String mappingType, String mappingSource) {
|
||||
this(new String[]{index}, mappingType, mappingSource);
|
||||
}
|
||||
|
||||
public PutMappingRequest(String[] indices, String mappingType, String mappingSource) {
|
||||
this.indices = indices;
|
||||
this.mappingType = mappingType;
|
||||
this.mappingSource = mappingSource;
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (mappingSource == null) {
|
||||
|
@ -72,14 +78,16 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
@Override public PutMappingRequest listenerThreaded(boolean threadedListener) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The indices the mappings will be put.
|
||||
*/
|
||||
String[] indices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping type.
|
||||
*/
|
||||
String type() {
|
||||
return mappingType;
|
||||
}
|
||||
|
@ -93,28 +101,63 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
String mappingSource() {
|
||||
return mappingSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
@Required public PutMappingRequest mappingSource(JsonBuilder mappingBuilder) {
|
||||
try {
|
||||
return mappingSource(mappingBuilder.string());
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchIllegalArgumentException("Failed to build json for mapping request", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
@Required public PutMappingRequest mappingSource(String mappingSource) {
|
||||
this.mappingSource = mappingSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait till the put mapping gets acknowledged of all current cluster nodes. Defaults to
|
||||
* <tt>10s</tt>.
|
||||
*/
|
||||
TimeValue timeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeout to wait till the put mapping gets acknowledged of all current cluster nodes. Defaults to
|
||||
* <tt>10s</tt>.
|
||||
*/
|
||||
public PutMappingRequest timeout(TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is already a mapping definition registered against the type, then it will be merged. If there are
|
||||
* elements that can't be merged are detected, the request will be rejected unless the
|
||||
* {@link #ignoreDuplicates(boolean)} is set. In such a case, the duplicate mappings will be rejected.
|
||||
*/
|
||||
public boolean ignoreDuplicates() {
|
||||
return ignoreDuplicates;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is already a mapping definition registered against the type, then it will be merged. If there are
|
||||
* elements that can't be merged are detected, the request will be rejected unless the
|
||||
* {@link #ignoreDuplicates(boolean)} is set. In such a case, the duplicate mappings will be rejected.
|
||||
*/
|
||||
public PutMappingRequest ignoreDuplicates(boolean ignoreDuplicates) {
|
||||
this.ignoreDuplicates = ignoreDuplicates;
|
||||
return this;
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The response of put mapping operation.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class PutMappingResponse implements ActionResponse, Streamable {
|
||||
|
@ -37,10 +39,14 @@ public class PutMappingResponse implements ActionResponse, Streamable {
|
|||
|
||||
}
|
||||
|
||||
public PutMappingResponse(boolean acknowledged) {
|
||||
PutMappingResponse(boolean acknowledged) {
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the put mapping creation been acknowledged by all current cluster nodes within the
|
||||
* provided {@link PutMappingRequest#timeout(org.elasticsearch.util.TimeValue)}.
|
||||
*/
|
||||
public boolean acknowledged() {
|
||||
return acknowledged;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,9 @@ import java.util.concurrent.TimeUnit;
|
|||
import static org.elasticsearch.action.Actions.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Put mapping action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportPutMappingAction extends TransportMasterNodeOperationAction<PutMappingRequest, PutMappingResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Put Mapping Action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.mapping.put;
|
|
@ -36,7 +36,10 @@ import java.io.IOException;
|
|||
* <p>{@link #maxNumSegments(int)} allows to control the number of segments to optimize down to. By default, will
|
||||
* cause the optimize process to optimize down to half the configured number of segments.
|
||||
*
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.Requests#optimizeRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#optimize(OptimizeRequest)
|
||||
* @see OptimizeResponse
|
||||
*/
|
||||
public class OptimizeRequest extends BroadcastOperationRequest {
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A response for optimize action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class OptimizeResponse extends BroadcastOperationResponse {
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardOptimizeRequest extends BroadcastShardOperationRequest {
|
||||
class ShardOptimizeRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private boolean waitForMerge = true;
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardOptimizeResponse extends BroadcastShardOperationResponse {
|
||||
class ShardOptimizeResponse extends BroadcastShardOperationResponse {
|
||||
|
||||
ShardOptimizeResponse() {
|
||||
}
|
||||
|
|
|
@ -43,7 +43,9 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
|||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Optimize index/indices action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportOptimizeAction extends TransportBroadcastOperationAction<OptimizeRequest, OptimizeResponse, ShardOptimizeRequest, ShardOptimizeResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Optimize index/indices action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.optimize;
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indices Administrative Actions.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices;
|
|
@ -27,27 +27,39 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A refresh request making all operations performed since the last refresh available for search. The (near) real-time
|
||||
* capabilities depends on the index engine used. For example, the robin one requires refresh to be called, but by
|
||||
* default a refresh is scheduled periodically.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
* @see org.elasticsearch.client.Requests#refreshRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#refresh(RefreshRequest)
|
||||
* @see RefreshResponse
|
||||
*/
|
||||
public class RefreshRequest extends BroadcastOperationRequest {
|
||||
|
||||
private boolean waitForOperations = true;
|
||||
|
||||
RefreshRequest() {
|
||||
}
|
||||
|
||||
public RefreshRequest(String... indices) {
|
||||
super(indices, null);
|
||||
// we want to do the refresh in parallel on local shards...
|
||||
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
|
||||
}
|
||||
|
||||
RefreshRequest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public RefreshRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override public RefreshRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
|
|
|
@ -28,7 +28,9 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* The response of a refresh action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class RefreshResponse extends BroadcastOperationResponse {
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardRefreshRequest extends BroadcastShardOperationRequest {
|
||||
class ShardRefreshRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private boolean waitForOperations = true;
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShardRefreshResponse extends BroadcastShardOperationResponse {
|
||||
class ShardRefreshResponse extends BroadcastShardOperationResponse {
|
||||
|
||||
ShardRefreshResponse() {
|
||||
}
|
||||
|
|
|
@ -43,7 +43,9 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
|||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* Refresh action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportRefreshAction extends TransportBroadcastOperationAction<RefreshRequest, RefreshResponse, ShardRefreshRequest, ShardRefreshResponse> {
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Refresh index/indices action.
|
||||
*/
|
||||
package org.elasticsearch.action.admin.indices.refresh;
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Administrative Actions.
|
||||
*/
|
||||
package org.elasticsearch.action.admin;
|
|
@ -206,7 +206,6 @@ public class IndexRequest extends ShardReplicationOperationRequest {
|
|||
*/
|
||||
@Required public IndexRequest source(JsonBuilder jsonBuilder) {
|
||||
try {
|
||||
jsonBuilder.flush();
|
||||
return source(jsonBuilder.copiedBytes());
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchIllegalArgumentException("Failed to build json for index request", e);
|
||||
|
|
|
@ -60,19 +60,31 @@ public abstract class BroadcastOperationRequest implements ActionRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public boolean listenerThreaded() {
|
||||
return this.listenerThreaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public BroadcastOperationRequest listenerThreaded(boolean listenerThreaded) {
|
||||
this.listenerThreaded = listenerThreaded;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public BroadcastOperationThreading operationThreading() {
|
||||
return operationThreading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public BroadcastOperationRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
this.operationThreading = operationThreading;
|
||||
return this;
|
||||
|
|
|
@ -26,7 +26,9 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* A based request for master based operation.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class MasterNodeOperationRequest implements ActionRequest {
|
||||
|
||||
|
|
|
@ -50,10 +50,16 @@ public class IndicesReplicationOperationRequest implements ActionRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public boolean listenerThreaded() {
|
||||
return this.threadedListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public IndicesReplicationOperationRequest listenerThreaded(boolean threadedListener) {
|
||||
this.threadedListener = threadedListener;
|
||||
return this;
|
||||
|
|
|
@ -67,10 +67,14 @@ public class Unicode {
|
|||
}
|
||||
|
||||
public static String fromBytes(byte[] source) {
|
||||
return fromBytes(source, 0, source.length);
|
||||
}
|
||||
|
||||
public static String fromBytes(byte[] source, int offset, int length) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
UnicodeUtil.UTF16Result result = unsafeFromBytesAsUtf16(source);
|
||||
UnicodeUtil.UTF16Result result = unsafeFromBytesAsUtf16(source, offset, length);
|
||||
return new String(result.result, 0, result.length);
|
||||
}
|
||||
|
||||
|
@ -84,11 +88,15 @@ public class Unicode {
|
|||
}
|
||||
|
||||
public static UnicodeUtil.UTF16Result unsafeFromBytesAsUtf16(byte[] source) {
|
||||
return unsafeFromBytesAsUtf16(source, 0, source.length);
|
||||
}
|
||||
|
||||
public static UnicodeUtil.UTF16Result unsafeFromBytesAsUtf16(byte[] source, int offset, int length) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
UnicodeUtil.UTF16Result result = cachedUtf16Result.get();
|
||||
UnicodeUtil.UTF8toUTF16(source, 0, source.length, result);
|
||||
UnicodeUtil.UTF8toUTF16(source, offset, length, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.codehaus.jackson.JsonEncoding;
|
|||
import org.codehaus.jackson.JsonFactory;
|
||||
import org.codehaus.jackson.JsonGenerator;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.util.Unicode;
|
||||
import org.elasticsearch.util.io.FastByteArrayOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -116,4 +117,9 @@ public class BinaryJsonBuilder extends JsonBuilder<BinaryJsonBuilder> {
|
|||
flush();
|
||||
return bos.copiedByteArray();
|
||||
}
|
||||
|
||||
@Override public String string() throws IOException {
|
||||
flush();
|
||||
return Unicode.fromBytes(bos.unsafeByteArray(), 0, bos.size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,6 +310,8 @@ public abstract class JsonBuilder<T extends JsonBuilder> {
|
|||
|
||||
public abstract byte[] copiedBytes() throws IOException;
|
||||
|
||||
public abstract String string() throws IOException;
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
generator.close();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.test.integration.terms;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||
import org.elasticsearch.action.admin.indices.status.IndexStatus;
|
||||
import org.elasticsearch.action.terms.TermsRequest;
|
||||
|
@ -34,7 +36,7 @@ import static org.hamcrest.MatcherAssert.*;
|
|||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
@Test
|
||||
public class TermsActionTests extends AbstractServersTests {
|
||||
|
@ -61,7 +63,11 @@ public class TermsActionTests extends AbstractServersTests {
|
|||
protected void verifyTermsActions(Client client) throws Exception {
|
||||
logger.info("Creating index test");
|
||||
client.admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
Thread.sleep(500);
|
||||
logger.info("Running Cluster Health");
|
||||
ClusterHealthResponse clusterHealth = client.admin().cluster().health(clusterHealth().waitForGreenStatus()).actionGet();
|
||||
logger.info("Done Cluster Health, status " + clusterHealth.status());
|
||||
assertThat(clusterHealth.timedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
IndexStatus indexStatus = client.admin().indices().status(indicesStatus("test")).actionGet().index("test");
|
||||
|
||||
|
|
Loading…
Reference in New Issue