From 372bdec45f9354d72dbc620b2748baeae9181726 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sun, 28 Feb 2010 01:36:45 +0200 Subject: [PATCH] more docs --- .../indices/create/CreateIndexRequest.java | 38 +++++++++- .../indices/create/CreateIndexResponse.java | 10 ++- .../create/TransportCreateIndexAction.java | 4 +- .../admin/indices/create/package-info.java | 23 ++++++ .../indices/delete/DeleteIndexRequest.java | 24 +++++- .../indices/delete/DeleteIndexResponse.java | 10 ++- .../delete/TransportDeleteIndexAction.java | 4 +- .../admin/indices/delete/package-info.java | 23 ++++++ .../admin/indices/flush/FlushRequest.java | 27 ++++++- .../admin/indices/flush/FlushResponse.java | 4 +- .../indices/flush/ShardFlushRequest.java | 4 +- .../indices/flush/ShardFlushResponse.java | 4 +- .../indices/flush/TransportFlushAction.java | 4 +- .../admin/indices/flush/package-info.java | 23 ++++++ .../admin/indices/gateway/package-info.java | 23 ++++++ .../snapshot/GatewaySnapshotRequest.java | 24 ++++-- .../snapshot/GatewaySnapshotResponse.java | 31 +++++--- .../snapshot/IndexGatewaySnapshotRequest.java | 4 +- .../IndexGatewaySnapshotResponse.java | 16 +++- .../snapshot/ShardGatewaySnapshotRequest.java | 8 +- .../ShardGatewaySnapshotResponse.java | 4 +- .../gateway/snapshot/package-info.java | 23 ++++++ .../admin/indices/mapping/package-info.java | 23 ++++++ .../mapping/put/PutMappingRequest.java | 73 +++++++++++++++---- .../mapping/put/PutMappingResponse.java | 8 +- .../put/TransportPutMappingAction.java | 4 +- .../indices/mapping/put/package-info.java | 23 ++++++ .../indices/optimize/OptimizeRequest.java | 5 +- .../indices/optimize/OptimizeResponse.java | 4 +- .../optimize/ShardOptimizeRequest.java | 4 +- .../optimize/ShardOptimizeResponse.java | 4 +- .../optimize/TransportOptimizeAction.java | 4 +- .../admin/indices/optimize/package-info.java | 23 ++++++ .../action/admin/indices/package-info.java | 23 ++++++ .../admin/indices/refresh/RefreshRequest.java | 22 ++++-- .../indices/refresh/RefreshResponse.java | 4 +- .../indices/refresh/ShardRefreshRequest.java | 4 +- .../indices/refresh/ShardRefreshResponse.java | 4 +- .../refresh/TransportRefreshAction.java | 4 +- .../admin/indices/refresh/package-info.java | 23 ++++++ .../action/admin/package-info.java | 23 ++++++ .../action/index/IndexRequest.java | 1 - .../broadcast/BroadcastOperationRequest.java | 12 +++ .../master/MasterNodeOperationRequest.java | 4 +- .../IndicesReplicationOperationRequest.java | 6 ++ .../java/org/elasticsearch/util/Unicode.java | 12 ++- .../util/json/BinaryJsonBuilder.java | 6 ++ .../elasticsearch/util/json/JsonBuilder.java | 2 + .../integration/terms/TermsActionTests.java | 10 ++- 49 files changed, 585 insertions(+), 85 deletions(-) create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/package-info.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/package-info.java diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index d633bf9e1aa..f354c19e49e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -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)}. + * + *

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 10s. + */ TimeValue timeout() { return timeout; } + /** + * Timeout to wait for the index creation to be acknowledged by current cluster nodes. Defaults + * to 10s. + */ public CreateIndexRequest timeout(TimeValue timeout) { this.timeout = timeout; return this; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java index c190c6b7ef8..b3eb9a13477 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java index 84f99bac226..4df629a3b18 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java new file mode 100644 index 00000000000..179ddaa99b7 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/create/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java index 7e69dc3cd9b..ea2d91bf961 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java @@ -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 10s. + */ TimeValue timeout() { return timeout; } + /** + * Timeout to wait for the index deletion to be acknowledged by current cluster nodes. Defaults + * to 10s. + */ public DeleteIndexRequest timeout(TimeValue timeout) { this.timeout = timeout; return this; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java index 5e8a781999f..26683b98bd2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexResponse.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java index a2926601e80..a40b342d8c6 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java new file mode 100644 index 00000000000..c8c7618ea2a --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/delete/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java index dc7f62c3408..9c85e885394 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushRequest.java @@ -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. + * + *

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 false. + */ public boolean refresh() { return this.refresh; } + /** + * Should a refresh be performed once the flush is done. Defaults to false. + */ 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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java index 2f8acc56e3b..2479ceaecf5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/FlushResponse.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java index c5e61e647b8..382d49a1464 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java index 42e8da294d2..d7f4ce99440 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushResponse.java @@ -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() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index 1dc941a6d59..bb4b383b2bc 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/package-info.java new file mode 100644 index 00000000000..33e24685e54 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/flush/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/package-info.java new file mode 100644 index 00000000000..2ef1102231f --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotRequest.java index f76cb64b50b..2bf31961b0d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotResponse.java index 19213be17ce..35b61c17f74 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/GatewaySnapshotResponse.java @@ -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 { - private Map indexResponses = new HashMap(); + private Map indices = new HashMap(); GatewaySnapshotResponse() { } - public Map indices() { - return indexResponses; + @Override public Iterator iterator() { + return indices.values().iterator(); } + /** + * A map of index level responses of the gateway snapshot operation. + */ + public Map 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); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotRequest.java index 1ab7b36d0f5..779c35a3f45 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotRequest.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotResponse.java index 72010cd47fb..31579e4618a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/IndexGatewaySnapshotResponse.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java index 245d0ec0a35..fcea97c1a7e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotRequest.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotResponse.java index 2c93b7d9069..95c4165a6e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/ShardGatewaySnapshotResponse.java @@ -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() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java new file mode 100644 index 00000000000..21204f16c89 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/gateway/snapshot/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java new file mode 100644 index 00000000000..0676efde518 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index e88585df8bd..b3bb78d49a5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -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...)}. + * + *

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 + * 10s. + */ TimeValue timeout() { return timeout; } + /** + * Timeout to wait till the put mapping gets acknowledged of all current cluster nodes. Defaults to + * 10s. + */ 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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java index 2eeba668d95..9126311b10e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingResponse.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index ebf0b6d449d..3e7123e8ea2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java new file mode 100644 index 00000000000..93d8886da1b --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java index 3dde3e36804..81bdb33bfcd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeRequest.java @@ -36,7 +36,10 @@ import java.io.IOException; *

{@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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java index 4b1cf6ae1ad..a931d2f8a86 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/OptimizeResponse.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java index c7f59798191..34659b370b5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java index 9af321952d1..0e9010f3aa1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeResponse.java @@ -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() { } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java index 12d690eed3e..7468417f8c7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/package-info.java new file mode 100644 index 00000000000..d28a8fc85cc --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/optimize/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/package-info.java new file mode 100644 index 00000000000..72b0561cd8c --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java index 221cfda0726..79a87368dd4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java index 2c54f3cacda..135eefc003e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/RefreshResponse.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java index 2539951f652..ab9df657caf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java index f0e1849bbdc..59526899b11 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/ShardRefreshResponse.java @@ -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() { } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java index 7c87ee5caab..21331dae70b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/package-info.java new file mode 100644 index 00000000000..d3a4f5993a2 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/package-info.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/package-info.java new file mode 100644 index 00000000000..6611abb3264 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/package-info.java @@ -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; \ No newline at end of file diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 609f47a20c4..af390cd655f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -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); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java index 507eac49835..45539778fd5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/BroadcastOperationRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java index 3f3cf347881..c31206416b4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/master/MasterNodeOperationRequest.java @@ -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 { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java index 0fa5b2fc96d..b69b2c50fdb 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/support/replication/IndicesReplicationOperationRequest.java @@ -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; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/Unicode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/Unicode.java index d14ffefb4b2..572becc63df 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/Unicode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/Unicode.java @@ -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; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/BinaryJsonBuilder.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/BinaryJsonBuilder.java index 15451f26ee7..3017850dca5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/BinaryJsonBuilder.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/BinaryJsonBuilder.java @@ -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 { flush(); return bos.copiedByteArray(); } + + @Override public String string() throws IOException { + flush(); + return Unicode.fromBytes(bos.unsafeByteArray(), 0, bos.size()); + } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/JsonBuilder.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/JsonBuilder.java index 7db974a431b..3dff21f8f8c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/JsonBuilder.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/json/JsonBuilder.java @@ -310,6 +310,8 @@ public abstract class JsonBuilder { public abstract byte[] copiedBytes() throws IOException; + public abstract String string() throws IOException; + public void close() { try { generator.close(); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/terms/TermsActionTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/terms/TermsActionTests.java index efb1ea470b3..07b0edd9c12 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/terms/TermsActionTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/terms/TermsActionTests.java @@ -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");