mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
more groovy client work
This commit is contained in:
parent
1b8bb9890e
commit
02cb297691
@ -55,8 +55,9 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
||||
return indices;
|
||||
}
|
||||
|
||||
void indices(String[] indices) {
|
||||
public ClusterHealthRequest indices(String[] indices) {
|
||||
this.indices = indices;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TimeValue timeout() {
|
||||
|
@ -66,6 +66,10 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
||||
return clusterName;
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The validation failures on the cluster level (without index validation failures).
|
||||
*/
|
||||
@ -73,6 +77,13 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
||||
return this.validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* The validation failures on the cluster level (without index validation failures).
|
||||
*/
|
||||
public List<String> getValidationFailures() {
|
||||
return validationFailures();
|
||||
}
|
||||
|
||||
/**
|
||||
* All the validation failures, including index level validation failures.
|
||||
*/
|
||||
@ -84,19 +95,38 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
||||
return allFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* All the validation failures, including index level validation failures.
|
||||
*/
|
||||
public List<String> getAllValidationFailures() {
|
||||
return allValidationFailures();
|
||||
}
|
||||
|
||||
|
||||
public int activeShards() {
|
||||
return activeShards;
|
||||
}
|
||||
|
||||
public int getActiveShards() {
|
||||
return activeShards();
|
||||
}
|
||||
|
||||
public int relocatingShards() {
|
||||
return relocatingShards;
|
||||
}
|
||||
|
||||
public int getRelocatingShards() {
|
||||
return relocatingShards();
|
||||
}
|
||||
|
||||
public int activePrimaryShards() {
|
||||
return activePrimaryShards;
|
||||
}
|
||||
|
||||
public int getActivePrimaryShards() {
|
||||
return activePrimaryShards();
|
||||
}
|
||||
|
||||
/**
|
||||
* <tt>true</tt> if the waitForXXX has timeout out and did not match.
|
||||
*/
|
||||
@ -104,14 +134,26 @@ public class ClusterHealthResponse implements ActionResponse, Iterable<ClusterIn
|
||||
return this.timedOut;
|
||||
}
|
||||
|
||||
public boolean isTimedOut() {
|
||||
return this.timedOut();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public ClusterHealthStatus getStatus() {
|
||||
return status();
|
||||
}
|
||||
|
||||
public Map<String, ClusterIndexHealth> indices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
public Map<String, ClusterIndexHealth> getIndices() {
|
||||
return indices();
|
||||
}
|
||||
|
||||
@Override public Iterator<ClusterIndexHealth> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
@ -69,38 +69,74 @@ public class ClusterIndexHealth implements Iterable<ClusterShardHealth>, Streama
|
||||
return index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
public List<String> validationFailures() {
|
||||
return this.validationFailures;
|
||||
}
|
||||
|
||||
public List<String> getValidationFailures() {
|
||||
return validationFailures();
|
||||
}
|
||||
|
||||
public int numberOfShards() {
|
||||
return numberOfShards;
|
||||
}
|
||||
|
||||
public int getNumberOfShards() {
|
||||
return numberOfShards();
|
||||
}
|
||||
|
||||
public int numberOfReplicas() {
|
||||
return numberOfReplicas;
|
||||
}
|
||||
|
||||
public int getNumberOfReplicas() {
|
||||
return numberOfReplicas();
|
||||
}
|
||||
|
||||
public int activeShards() {
|
||||
return activeShards;
|
||||
}
|
||||
|
||||
public int getActiveShards() {
|
||||
return activeShards();
|
||||
}
|
||||
|
||||
public int relocatingShards() {
|
||||
return relocatingShards;
|
||||
}
|
||||
|
||||
public int getRelocatingShards() {
|
||||
return relocatingShards();
|
||||
}
|
||||
|
||||
public int activePrimaryShards() {
|
||||
return activePrimaryShards;
|
||||
}
|
||||
|
||||
public int getActivePrimaryShards() {
|
||||
return activePrimaryShards();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public ClusterHealthStatus getStatus() {
|
||||
return status();
|
||||
}
|
||||
|
||||
public Map<Integer, ClusterShardHealth> shards() {
|
||||
return this.shards;
|
||||
}
|
||||
|
||||
public Map<Integer, ClusterShardHealth> getShards() {
|
||||
return shards();
|
||||
}
|
||||
|
||||
@Override public Iterator<ClusterShardHealth> iterator() {
|
||||
return shards.values().iterator();
|
||||
}
|
||||
|
@ -52,22 +52,42 @@ public class ClusterShardHealth implements Streamable {
|
||||
return shardId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
public ClusterHealthStatus status() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public ClusterHealthStatus getStatus() {
|
||||
return status();
|
||||
}
|
||||
|
||||
public int relocatingShards() {
|
||||
return relocatingShards;
|
||||
}
|
||||
|
||||
public int getRelocatingShards() {
|
||||
return relocatingShards();
|
||||
}
|
||||
|
||||
public int activeShards() {
|
||||
return activeShards;
|
||||
}
|
||||
|
||||
public int getActiveShards() {
|
||||
return activeShards();
|
||||
}
|
||||
|
||||
public boolean primaryActive() {
|
||||
return primaryActive;
|
||||
}
|
||||
|
||||
public boolean isPrimaryActive() {
|
||||
return primaryActive();
|
||||
}
|
||||
|
||||
static ClusterShardHealth readClusterShardHealth(StreamInput in) throws IOException {
|
||||
ClusterShardHealth ret = new ClusterShardHealth();
|
||||
ret.readFrom(in);
|
||||
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class NodeInfo extends NodeOperationResponse {
|
||||
|
||||
@ -56,10 +56,18 @@ public class NodeInfo extends NodeOperationResponse {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, String> getAttributes() {
|
||||
return attributes();
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings();
|
||||
}
|
||||
|
||||
public static NodeInfo readNodeInfo(StreamInput in) throws IOException {
|
||||
NodeInfo nodeInfo = new NodeInfo();
|
||||
nodeInfo.readFrom(in);
|
||||
|
@ -44,6 +44,10 @@ public class ClusterStateResponse implements ActionResponse {
|
||||
return this.clusterState;
|
||||
}
|
||||
|
||||
public ClusterState getState() {
|
||||
return state();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
clusterState = ClusterState.Builder.readFrom(in, null, null);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import org.elasticsearch.util.TimeValue;
|
||||
import org.elasticsearch.util.io.stream.StreamInput;
|
||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||
import org.elasticsearch.util.json.JsonBuilder;
|
||||
import org.elasticsearch.util.settings.ImmutableSettings;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -123,6 +124,14 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to crete the index with (either json/yaml/properties format)
|
||||
*/
|
||||
public CreateIndexRequest settings(String source) {
|
||||
this.settings = ImmutableSettings.settingsBuilder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
|
@ -50,6 +50,14 @@ public class CreateIndexResponse implements ActionResponse, Streamable {
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the index creation been acknowledged by all current cluster nodes within the
|
||||
* provided {@link CreateIndexRequest#timeout(org.elasticsearch.util.TimeValue)}.
|
||||
*/
|
||||
public boolean getAcknowledged() {
|
||||
return acknowledged();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
acknowledged = in.readBoolean();
|
||||
}
|
||||
|
@ -50,6 +50,14 @@ public class DeleteIndexResponse implements ActionResponse, Streamable {
|
||||
return acknowledged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the index deletion been acknowledged by all current cluster nodes within the
|
||||
* provided {@link DeleteIndexRequest#timeout(org.elasticsearch.util.TimeValue)}.
|
||||
*/
|
||||
public boolean getAcknowledged() {
|
||||
return acknowledged();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
acknowledged = in.readBoolean();
|
||||
}
|
||||
|
@ -53,6 +53,13 @@ public class GatewaySnapshotResponse implements ActionResponse, Streamable, Iter
|
||||
return indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of index level responses of the gateway snapshot operation.
|
||||
*/
|
||||
public Map<String, IndexGatewaySnapshotResponse> getIndices() {
|
||||
return indices();
|
||||
}
|
||||
|
||||
/**
|
||||
* The index level gateway snapshot response for the given index.
|
||||
*/
|
||||
|
@ -56,6 +56,13 @@ public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* The index the gateway snapshot has performed on.
|
||||
*/
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of successful shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
@ -63,6 +70,13 @@ public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable
|
||||
return successfulShards;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of successful shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int getSuccessfulShards() {
|
||||
return successfulShards();
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of failed shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
@ -70,6 +84,13 @@ public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable
|
||||
return failedShards;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of failed shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int getFailedShards() {
|
||||
return failedShards();
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of total shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
@ -77,6 +98,13 @@ public class IndexGatewaySnapshotResponse implements ActionResponse, Streamable
|
||||
return successfulShards + failedShards;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of total shards the gateway snapshot operation was performed on.
|
||||
*/
|
||||
public int getTotalShards() {
|
||||
return totalShards();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
index = in.readUTF();
|
||||
successfulShards = in.readVInt();
|
||||
|
@ -112,16 +112,16 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
String mappingSource() {
|
||||
String source() {
|
||||
return mappingSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
@Required public PutMappingRequest mappingSource(JsonBuilder mappingBuilder) {
|
||||
@Required public PutMappingRequest source(JsonBuilder mappingBuilder) {
|
||||
try {
|
||||
return mappingSource(mappingBuilder.string());
|
||||
return source(mappingBuilder.string());
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchIllegalArgumentException("Failed to build json for mapping request", e);
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
@Required public PutMappingRequest mappingSource(String mappingSource) {
|
||||
@Required public PutMappingRequest source(String mappingSource) {
|
||||
this.mappingSource = mappingSource;
|
||||
return this;
|
||||
}
|
||||
|
@ -51,6 +51,14 @@ public class PutMappingResponse implements ActionResponse, Streamable {
|
||||
return 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 getAcknowledged() {
|
||||
return acknowledged();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
acknowledged = in.readBoolean();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class TransportPutMappingAction extends TransportMasterNodeOperationActio
|
||||
request.indices(clusterState.metaData().concreteIndices(request.indices()));
|
||||
final String[] indices = request.indices();
|
||||
|
||||
MetaDataService.PutMappingResult result = metaDataService.putMapping(indices, request.type(), request.mappingSource(), request.ignoreConflicts(), request.timeout());
|
||||
MetaDataService.PutMappingResult result = metaDataService.putMapping(indices, request.type(), request.source(), request.ignoreConflicts(), request.timeout());
|
||||
return new PutMappingResponse(result.acknowledged());
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ import org.elasticsearch.util.SizeValue;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
|
||||
@ -41,13 +41,25 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return numDocs;
|
||||
}
|
||||
|
||||
public int getNumDocs() {
|
||||
return numDocs;
|
||||
}
|
||||
|
||||
public int maxDoc() {
|
||||
return maxDoc;
|
||||
}
|
||||
|
||||
public int getMaxDoc() {
|
||||
return maxDoc();
|
||||
}
|
||||
|
||||
public int deletedDocs() {
|
||||
return deletedDocs;
|
||||
}
|
||||
|
||||
public int getDeletedDocs() {
|
||||
return deletedDocs();
|
||||
}
|
||||
}
|
||||
|
||||
private final ShardId shardId;
|
||||
@ -63,10 +75,22 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return this.shardId;
|
||||
}
|
||||
|
||||
public ShardId getShardId() {
|
||||
return shardId();
|
||||
}
|
||||
|
||||
public ShardStatus[] shards() {
|
||||
return this.shards;
|
||||
}
|
||||
|
||||
public ShardStatus[] getShards() {
|
||||
return shards();
|
||||
}
|
||||
|
||||
public ShardStatus getAt(int position) {
|
||||
return shards[position];
|
||||
}
|
||||
|
||||
public SizeValue storeSize() {
|
||||
long bytes = -1;
|
||||
for (ShardStatus shard : shards()) {
|
||||
@ -83,6 +107,10 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return new SizeValue(bytes);
|
||||
}
|
||||
|
||||
public SizeValue getStoreSize() {
|
||||
return storeSize();
|
||||
}
|
||||
|
||||
public SizeValue estimatedFlushableMemorySize() {
|
||||
long bytes = -1;
|
||||
for (ShardStatus shard : shards()) {
|
||||
@ -99,6 +127,10 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return new SizeValue(bytes);
|
||||
}
|
||||
|
||||
public SizeValue getEstimatedFlushableMemorySize() {
|
||||
return estimatedFlushableMemorySize();
|
||||
}
|
||||
|
||||
public long translogOperations() {
|
||||
long translogOperations = -1;
|
||||
for (ShardStatus shard : shards()) {
|
||||
@ -112,6 +144,10 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return translogOperations;
|
||||
}
|
||||
|
||||
public long getTranslogOperations() {
|
||||
return translogOperations();
|
||||
}
|
||||
|
||||
public Docs docs() {
|
||||
Docs docs = new Docs();
|
||||
for (ShardStatus shard : shards()) {
|
||||
@ -141,6 +177,10 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||
return docs;
|
||||
}
|
||||
|
||||
public Docs getDocs() {
|
||||
return docs();
|
||||
}
|
||||
|
||||
@Override public Iterator<ShardStatus> iterator() {
|
||||
return Iterators.forArray(shards);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import java.util.Map;
|
||||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
|
||||
@ -45,13 +45,25 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return numDocs;
|
||||
}
|
||||
|
||||
public long getNumDocs() {
|
||||
return numDocs();
|
||||
}
|
||||
|
||||
public long maxDoc() {
|
||||
return maxDoc;
|
||||
}
|
||||
|
||||
public long getMaxDoc() {
|
||||
return maxDoc();
|
||||
}
|
||||
|
||||
public long deletedDocs() {
|
||||
return deletedDocs;
|
||||
}
|
||||
|
||||
public long getDeletedDocs() {
|
||||
return deletedDocs();
|
||||
}
|
||||
}
|
||||
|
||||
private final String index;
|
||||
@ -83,6 +95,10 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
/**
|
||||
* A shard id to index shard status map (note, index shard status is the replication shard group that maps
|
||||
* to the shard id).
|
||||
@ -91,10 +107,18 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return this.indexShards;
|
||||
}
|
||||
|
||||
public Map<Integer, IndexShardStatus> getShards() {
|
||||
return shards();
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings();
|
||||
}
|
||||
|
||||
public SizeValue storeSize() {
|
||||
long bytes = -1;
|
||||
for (IndexShardStatus shard : this) {
|
||||
@ -111,6 +135,10 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return new SizeValue(bytes);
|
||||
}
|
||||
|
||||
public SizeValue getStoreSize() {
|
||||
return storeSize();
|
||||
}
|
||||
|
||||
public SizeValue estimatedFlushableMemorySize() {
|
||||
long bytes = -1;
|
||||
for (IndexShardStatus shard : this) {
|
||||
@ -127,6 +155,10 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return new SizeValue(bytes);
|
||||
}
|
||||
|
||||
public SizeValue getEstimatedFlushableMemorySize() {
|
||||
return estimatedFlushableMemorySize();
|
||||
}
|
||||
|
||||
public long translogOperations() {
|
||||
long translogOperations = -1;
|
||||
for (IndexShardStatus shard : this) {
|
||||
@ -140,6 +172,10 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return translogOperations;
|
||||
}
|
||||
|
||||
public long getTranslogOperations() {
|
||||
return translogOperations();
|
||||
}
|
||||
|
||||
public Docs docs() {
|
||||
Docs docs = new Docs();
|
||||
for (IndexShardStatus shard : this) {
|
||||
@ -165,6 +201,10 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||
return docs;
|
||||
}
|
||||
|
||||
public Docs getDocs() {
|
||||
return docs();
|
||||
}
|
||||
|
||||
@Override public Iterator<IndexShardStatus> iterator() {
|
||||
return indexShards.values().iterator();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.util.Strings;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndicesStatusRequest extends BroadcastOperationRequest {
|
||||
|
||||
|
@ -65,10 +65,22 @@ public class IndicesStatusResponse extends BroadcastOperationResponse {
|
||||
return this.shards;
|
||||
}
|
||||
|
||||
public ShardStatus[] getShards() {
|
||||
return this.shards;
|
||||
}
|
||||
|
||||
public ShardStatus getAt(int position) {
|
||||
return shards[position];
|
||||
}
|
||||
|
||||
public IndexStatus index(String index) {
|
||||
return indices().get(index);
|
||||
}
|
||||
|
||||
public Map<String, IndexStatus> getIndices() {
|
||||
return indices();
|
||||
}
|
||||
|
||||
public Map<String, IndexStatus> indices() {
|
||||
if (indicesStatus != null) {
|
||||
return indicesStatus;
|
||||
|
@ -47,13 +47,25 @@ public class ShardStatus extends BroadcastShardOperationResponse {
|
||||
return numDocs;
|
||||
}
|
||||
|
||||
public int getNumDocs() {
|
||||
return numDocs();
|
||||
}
|
||||
|
||||
public int maxDoc() {
|
||||
return maxDoc;
|
||||
}
|
||||
|
||||
public int getMaxDoc() {
|
||||
return maxDoc();
|
||||
}
|
||||
|
||||
public int deletedDocs() {
|
||||
return deletedDocs;
|
||||
}
|
||||
|
||||
public int getDeletedDocs() {
|
||||
return deletedDocs();
|
||||
}
|
||||
}
|
||||
|
||||
private ShardRouting shardRouting;
|
||||
@ -82,30 +94,58 @@ public class ShardStatus extends BroadcastShardOperationResponse {
|
||||
return this.shardRouting;
|
||||
}
|
||||
|
||||
public ShardRouting getShardRouting() {
|
||||
return shardRouting();
|
||||
}
|
||||
|
||||
public IndexShardState state() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public IndexShardState getState() {
|
||||
return state();
|
||||
}
|
||||
|
||||
public SizeValue storeSize() {
|
||||
return storeSize;
|
||||
}
|
||||
|
||||
public SizeValue getStoreSize() {
|
||||
return storeSize();
|
||||
}
|
||||
|
||||
public SizeValue estimatedFlushableMemorySize() {
|
||||
return estimatedFlushableMemorySize;
|
||||
}
|
||||
|
||||
public SizeValue getEstimatedFlushableMemorySize() {
|
||||
return estimatedFlushableMemorySize();
|
||||
}
|
||||
|
||||
public long translogId() {
|
||||
return translogId;
|
||||
}
|
||||
|
||||
public long getTranslogId() {
|
||||
return translogId();
|
||||
}
|
||||
|
||||
public long translogOperations() {
|
||||
return translogOperations;
|
||||
}
|
||||
|
||||
public long getTranslogOperations() {
|
||||
return translogOperations();
|
||||
}
|
||||
|
||||
public Docs docs() {
|
||||
return docs;
|
||||
}
|
||||
|
||||
public Docs getDocs() {
|
||||
return docs();
|
||||
}
|
||||
|
||||
public static ShardStatus readIndexShardStatus(StreamInput in) throws IOException {
|
||||
ShardStatus shardStatus = new ShardStatus();
|
||||
shardStatus.readFrom(in);
|
||||
|
@ -47,10 +47,18 @@ public abstract class BroadcastShardOperationResponse implements Streamable {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
public int shardId() {
|
||||
return this.shardId;
|
||||
}
|
||||
|
||||
public int getShardId() {
|
||||
return shardId();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
index = in.readUTF();
|
||||
shardId = in.readVInt();
|
||||
|
@ -44,6 +44,10 @@ public abstract class NodeOperationResponse implements Streamable {
|
||||
return node;
|
||||
}
|
||||
|
||||
public DiscoveryNode getNode() {
|
||||
return node();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ public abstract class NodesOperationRequest implements ActionRequest {
|
||||
return nodesIds;
|
||||
}
|
||||
|
||||
public NodesOperationRequest nodesIds(String... nodesIds) {
|
||||
this.nodesIds = nodesIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
@ -52,10 +52,22 @@ public abstract class NodesOperationResponse<NodeResponse extends NodeOperationR
|
||||
return this.clusterName;
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName().value();
|
||||
}
|
||||
|
||||
public NodeResponse[] nodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public NodeResponse[] getNodes() {
|
||||
return nodes();
|
||||
}
|
||||
|
||||
public NodeResponse getAt(int position) {
|
||||
return nodes[position];
|
||||
}
|
||||
|
||||
@Override public Iterator<NodeResponse> iterator() {
|
||||
return nodesMap().values().iterator();
|
||||
}
|
||||
@ -70,6 +82,10 @@ public abstract class NodesOperationResponse<NodeResponse extends NodeOperationR
|
||||
return nodesMap;
|
||||
}
|
||||
|
||||
public Map<String, NodeResponse> getNodesMap() {
|
||||
return nodesMap();
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
clusterName = ClusterName.readClusterName(in);
|
||||
}
|
||||
|
@ -60,22 +60,42 @@ public class ClusterState {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version();
|
||||
}
|
||||
|
||||
public DiscoveryNodes nodes() {
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
public DiscoveryNodes getNodes() {
|
||||
return nodes();
|
||||
}
|
||||
|
||||
public MetaData metaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
public MetaData getMetaData() {
|
||||
return metaData();
|
||||
}
|
||||
|
||||
public RoutingTable routingTable() {
|
||||
return routingTable;
|
||||
}
|
||||
|
||||
public RoutingTable getRoutingTable() {
|
||||
return routingTable();
|
||||
}
|
||||
|
||||
public RoutingNodes routingNodes() {
|
||||
return routingTable.routingNodes(metaData);
|
||||
}
|
||||
|
||||
public RoutingNodes getRoutingNodes() {
|
||||
return readOnlyRoutingNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a built (on demand) routing nodes view of the routing table. <b>NOTE, the routing nodes
|
||||
* are mutable, use them just for read operations</b>
|
||||
|
@ -74,30 +74,58 @@ public class IndexMetaData {
|
||||
return index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
public int numberOfShards() {
|
||||
return settings.getAsInt(SETTING_NUMBER_OF_SHARDS, -1);
|
||||
}
|
||||
|
||||
public int getNumberOfShards() {
|
||||
return numberOfShards();
|
||||
}
|
||||
|
||||
public int numberOfReplicas() {
|
||||
return settings.getAsInt(SETTING_NUMBER_OF_REPLICAS, -1);
|
||||
}
|
||||
|
||||
public int getNumberOfReplicas() {
|
||||
return numberOfReplicas();
|
||||
}
|
||||
|
||||
public int totalNumberOfShards() {
|
||||
return totalNumberOfShards;
|
||||
}
|
||||
|
||||
public int getTotalNumberOfShards() {
|
||||
return totalNumberOfShards();
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings();
|
||||
}
|
||||
|
||||
public ImmutableSet<String> aliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
public ImmutableSet<String> getAliases() {
|
||||
return aliases();
|
||||
}
|
||||
|
||||
public ImmutableMap<String, String> mappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, String> getMappings() {
|
||||
return mappings();
|
||||
}
|
||||
|
||||
public String mapping(String mappingType) {
|
||||
return mappings.get(mappingType);
|
||||
}
|
||||
|
@ -127,6 +127,10 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
public ImmutableSet<String> getAliases() {
|
||||
return aliases();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the concrete indices.
|
||||
*/
|
||||
@ -134,6 +138,10 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||
return allIndices;
|
||||
}
|
||||
|
||||
public String[] getConcreteAllIndices() {
|
||||
return concreteAllIndices();
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the provided indices (possibly aliased) into actual indices.
|
||||
*/
|
||||
@ -195,14 +203,26 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||
return this.indices;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, IndexMetaData> getIndices() {
|
||||
return indices();
|
||||
}
|
||||
|
||||
public int maxNumberOfShardsPerNode() {
|
||||
return this.maxNumberOfShardsPerNode;
|
||||
}
|
||||
|
||||
public int getMaxNumberOfShardsPerNode() {
|
||||
return maxNumberOfShardsPerNode();
|
||||
}
|
||||
|
||||
public int totalNumberOfShards() {
|
||||
return this.totalNumberOfShards;
|
||||
}
|
||||
|
||||
public int getTotalNumberOfShards() {
|
||||
return totalNumberOfShards();
|
||||
}
|
||||
|
||||
@Override public UnmodifiableIterator<IndexMetaData> iterator() {
|
||||
return indices.values().iterator();
|
||||
}
|
||||
|
@ -70,6 +70,13 @@ public class DiscoveryNode implements Streamable, Serializable {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* The address that the node can be communicated with.
|
||||
*/
|
||||
public TransportAddress getAddress() {
|
||||
return address();
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique id of the node.
|
||||
*/
|
||||
@ -77,6 +84,13 @@ public class DiscoveryNode implements Streamable, Serializable {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique id of the node.
|
||||
*/
|
||||
public String getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the node.
|
||||
*/
|
||||
@ -84,6 +98,13 @@ public class DiscoveryNode implements Streamable, Serializable {
|
||||
return this.nodeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the node.
|
||||
*/
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this node hold data (shards) or not.
|
||||
*/
|
||||
@ -91,6 +112,13 @@ public class DiscoveryNode implements Streamable, Serializable {
|
||||
return dataNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this node hold data (shards) or not.
|
||||
*/
|
||||
public boolean isDataNode() {
|
||||
return dataNode();
|
||||
}
|
||||
|
||||
public static DiscoveryNode readNode(StreamInput in) throws IOException {
|
||||
DiscoveryNode node = new DiscoveryNode();
|
||||
node.readFrom(in);
|
||||
|
@ -83,14 +83,26 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
||||
return nodes.size();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size();
|
||||
}
|
||||
|
||||
public ImmutableMap<String, DiscoveryNode> nodes() {
|
||||
return this.nodes;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, DiscoveryNode> getNodes() {
|
||||
return nodes();
|
||||
}
|
||||
|
||||
public ImmutableMap<String, DiscoveryNode> dataNodes() {
|
||||
return this.dataNodes;
|
||||
}
|
||||
|
||||
public ImmutableMap<String, DiscoveryNode> getDataNodes() {
|
||||
return dataNodes();
|
||||
}
|
||||
|
||||
public DiscoveryNode get(String nodeId) {
|
||||
return nodes.get(nodeId);
|
||||
}
|
||||
@ -103,18 +115,34 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
||||
return this.masterNodeId;
|
||||
}
|
||||
|
||||
public String getMasterNodeId() {
|
||||
return masterNodeId();
|
||||
}
|
||||
|
||||
public String localNodeId() {
|
||||
return this.localNodeId;
|
||||
}
|
||||
|
||||
public String getLocalNodeId() {
|
||||
return localNodeId();
|
||||
}
|
||||
|
||||
public DiscoveryNode localNode() {
|
||||
return nodes.get(localNodeId);
|
||||
}
|
||||
|
||||
public DiscoveryNode getLocalNode() {
|
||||
return localNode();
|
||||
}
|
||||
|
||||
public DiscoveryNode masterNode() {
|
||||
return nodes.get(masterNodeId);
|
||||
}
|
||||
|
||||
public DiscoveryNode getMasterNode() {
|
||||
return masterNode();
|
||||
}
|
||||
|
||||
public DiscoveryNodes removeDeadMembers(Set<String> newNodes, String masterNodeId) {
|
||||
Builder builder = new Builder().masterNodeId(masterNodeId).localNodeId(localNodeId);
|
||||
for (DiscoveryNode node : this) {
|
||||
|
@ -73,10 +73,18 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return this.shardId;
|
||||
}
|
||||
|
||||
@Override public int getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override public boolean unassigned() {
|
||||
return state == ShardRoutingState.UNASSIGNED;
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index();
|
||||
}
|
||||
|
||||
public void validate(RoutingTableValidation validation, MetaData metaData) {
|
||||
if (!metaData.hasIndex(index())) {
|
||||
validation.addIndexFailure(index(), "Exists in routing does not exists in metadata");
|
||||
@ -90,6 +94,10 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
||||
return shards;
|
||||
}
|
||||
|
||||
public ImmutableMap<Integer, IndexShardRoutingTable> getShards() {
|
||||
return shards();
|
||||
}
|
||||
|
||||
public IndexShardRoutingTable shard(int shardId) {
|
||||
return shards.get(shardId);
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||
return shardId;
|
||||
}
|
||||
|
||||
public ShardId getShardId() {
|
||||
return shardId();
|
||||
}
|
||||
|
||||
@Override public UnmodifiableIterator<ShardRouting> iterator() {
|
||||
return shards.iterator();
|
||||
}
|
||||
@ -63,10 +67,18 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
|
||||
return shards.size();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size();
|
||||
}
|
||||
|
||||
public ImmutableList<ShardRouting> shards() {
|
||||
return shards;
|
||||
}
|
||||
|
||||
public ImmutableList<ShardRouting> getShards() {
|
||||
return shards();
|
||||
}
|
||||
|
||||
public ShardsIterator shardsIt() {
|
||||
return new IndexShardsIterator(0);
|
||||
}
|
||||
|
@ -86,10 +86,18 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
return routingTable;
|
||||
}
|
||||
|
||||
public RoutingTable getRoutingTable() {
|
||||
return routingTable();
|
||||
}
|
||||
|
||||
public MetaData metaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
public MetaData getMetaData() {
|
||||
return metaData();
|
||||
}
|
||||
|
||||
public int requiredAverageNumberOfShardsPerNode() {
|
||||
return metaData.totalNumberOfShards() / nodesToShards.size();
|
||||
}
|
||||
@ -102,10 +110,18 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
return this.unassigned;
|
||||
}
|
||||
|
||||
public List<MutableShardRouting> getUnassigned() {
|
||||
return unassigned();
|
||||
}
|
||||
|
||||
public Map<String, RoutingNode> nodesToShards() {
|
||||
return nodesToShards;
|
||||
}
|
||||
|
||||
public Map<String, RoutingNode> getNodesToShards() {
|
||||
return nodesToShards();
|
||||
}
|
||||
|
||||
public RoutingNode node(String nodeId) {
|
||||
return nodesToShards.get(nodeId);
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ public class RoutingTable implements Iterable<IndexRoutingTable> {
|
||||
return indicesRouting;
|
||||
}
|
||||
|
||||
public Map<String, IndexRoutingTable> getIndicesRouting() {
|
||||
return indicesRouting();
|
||||
}
|
||||
|
||||
public RoutingNodes routingNodes(MetaData metaData) {
|
||||
return new RoutingNodes(metaData, this);
|
||||
}
|
||||
|
@ -34,8 +34,12 @@ public interface ShardRouting extends Streamable, Serializable {
|
||||
|
||||
String index();
|
||||
|
||||
String getIndex();
|
||||
|
||||
int id();
|
||||
|
||||
int getId();
|
||||
|
||||
boolean unassigned();
|
||||
|
||||
boolean initializing();
|
||||
|
@ -48,6 +48,10 @@ public class Index implements Serializable, Streamable {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "Index [" + name + "]";
|
||||
}
|
||||
|
@ -57,10 +57,18 @@ public class ShardId implements Serializable, Streamable {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return index().name();
|
||||
}
|
||||
|
||||
public int id() {
|
||||
return this.shardId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id();
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "Index Shard [" + index.name() + "][" + shardId + "]";
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class RestPutMappingAction extends BaseRestHandler {
|
||||
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
PutMappingRequest putMappingRequest = putMappingRequest(splitIndices(request.param("index")));
|
||||
putMappingRequest.type(request.param("type"));
|
||||
putMappingRequest.mappingSource(request.contentAsString());
|
||||
putMappingRequest.source(request.contentAsString());
|
||||
putMappingRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10)));
|
||||
putMappingRequest.ignoreConflicts(request.paramAsBoolean("ignore_conflicts", putMappingRequest.ignoreConflicts()));
|
||||
client.admin().indices().putMapping(putMappingRequest, new ActionListener<PutMappingResponse>() {
|
||||
|
@ -64,7 +64,7 @@ public abstract class AbstractSimpleIndexGatewayTests extends AbstractNodesTests
|
||||
|
||||
// create a mapping
|
||||
PutMappingResponse putMappingResponse = client("server1").admin().indices().putMapping(putMappingRequest("test").type("type1")
|
||||
.mappingSource(mappingSource())).actionGet();
|
||||
.source(mappingSource())).actionGet();
|
||||
assertThat(putMappingResponse.acknowledged(), equalTo(true));
|
||||
|
||||
// verify that mapping is there
|
||||
|
@ -57,7 +57,7 @@ public class HighlightSearchTests extends AbstractNodesTests {
|
||||
client.admin().indices().create(createIndexRequest("test")).actionGet();
|
||||
|
||||
logger.info("Update mapping (_all to store and have term vectors)");
|
||||
client.admin().indices().putMapping(putMappingRequest("test").mappingSource(mapping())).actionGet();
|
||||
client.admin().indices().putMapping(putMappingRequest("test").source(mapping())).actionGet();
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
index(client("server1"), Integer.toString(i), "test", i);
|
||||
|
@ -72,7 +72,7 @@ public class SimpleAttachmentIntegrationTests {
|
||||
@Test public void testSimpleAttachment() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/plugin/attachments/index/mapper/test-mapping.json");
|
||||
|
||||
node.client().admin().indices().putMapping(putMappingRequest("test").mappingSource(mapping)).actionGet();
|
||||
node.client().admin().indices().putMapping(putMappingRequest("test").source(mapping)).actionGet();
|
||||
|
||||
node.client().index(indexRequest("test").type("person")
|
||||
.source(jsonBuilder().startObject().field("file", copyToBytesFromClasspath("/org/elasticsearch/plugin/attachments/index/mapper/testXHTML.html")).endObject())).actionGet();
|
||||
|
@ -1,7 +1,17 @@
|
||||
package org.elasticsearch.groovy.client
|
||||
|
||||
import org.elasticsearch.action.ActionListener
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse
|
||||
import org.elasticsearch.action.admin.cluster.node.shutdown.NodesShutdownRequest
|
||||
import org.elasticsearch.action.admin.cluster.node.shutdown.NodesShutdownResponse
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse
|
||||
import org.elasticsearch.client.ClusterAdminClient
|
||||
import org.elasticsearch.client.internal.InternalClient
|
||||
import org.elasticsearch.groovy.client.action.GActionFuture
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
@ -19,4 +29,84 @@ class GClusterAdminClient {
|
||||
this.internalClient = gClient.client;
|
||||
this.clusterAdminClient = internalClient.admin().cluster();
|
||||
}
|
||||
|
||||
// HEALTH
|
||||
|
||||
GActionFuture<ClusterHealthResponse> health(Closure c) {
|
||||
ClusterHealthRequest request = new ClusterHealthRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
health(request)
|
||||
}
|
||||
|
||||
GActionFuture<ClusterHealthResponse> health(ClusterHealthRequest request) {
|
||||
GActionFuture<ClusterHealthResponse> future = new GActionFuture<ClusterHealthResponse>(internalClient.threadPool(), request);
|
||||
clusterAdminClient.health(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void status(ClusterHealthRequest request, ActionListener<ClusterHealthResponse> listener) {
|
||||
clusterAdminClient.health(request, listener)
|
||||
}
|
||||
|
||||
// STATE
|
||||
|
||||
GActionFuture<ClusterStateResponse> state(Closure c) {
|
||||
ClusterStateRequest request = new ClusterStateRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
state(request)
|
||||
}
|
||||
|
||||
GActionFuture<ClusterStateResponse> state(ClusterStateRequest request) {
|
||||
GActionFuture<ClusterStateResponse> future = new GActionFuture<ClusterStateResponse>(internalClient.threadPool(), request);
|
||||
clusterAdminClient.state(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void state(ClusterStateRequest request, ActionListener<ClusterStateResponse> listener) {
|
||||
clusterAdminClient.state(request, listener)
|
||||
}
|
||||
|
||||
// NODES INFO
|
||||
|
||||
GActionFuture<NodesInfoResponse> nodesInfo(Closure c) {
|
||||
NodesInfoRequest request = new NodesInfoRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
nodesInfo(request)
|
||||
}
|
||||
|
||||
GActionFuture<NodesInfoResponse> nodesInfo(NodesInfoRequest request) {
|
||||
GActionFuture<NodesInfoResponse> future = new GActionFuture<NodesInfoResponse>(internalClient.threadPool(), request);
|
||||
clusterAdminClient.nodesInfo(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void nodesInfo(NodesInfoRequest request, ActionListener<NodesInfoResponse> listener) {
|
||||
clusterAdminClient.nodesInfo(request, listener)
|
||||
}
|
||||
|
||||
// NODES INFO
|
||||
|
||||
GActionFuture<NodesShutdownResponse> nodesShutdown(Closure c) {
|
||||
NodesShutdownRequest request = new NodesShutdownRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
nodesShutdown(request)
|
||||
}
|
||||
|
||||
GActionFuture<NodesShutdownResponse> nodesShutdown(NodesShutdownRequest request) {
|
||||
GActionFuture<NodesShutdownResponse> future = new GActionFuture<NodesShutdownResponse>(internalClient.threadPool(), request);
|
||||
clusterAdminClient.nodesShutdown(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void nodesShutdown(NodesShutdownRequest request, ActionListener<NodesShutdownResponse> listener) {
|
||||
clusterAdminClient.nodesShutdown(request, listener)
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,58 @@
|
||||
package org.elasticsearch.groovy.client
|
||||
|
||||
import org.elasticsearch.action.ActionListener
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse
|
||||
import org.elasticsearch.action.admin.indices.flush.FlushRequest
|
||||
import org.elasticsearch.action.admin.indices.flush.FlushResponse
|
||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest
|
||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse
|
||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest
|
||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse
|
||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest
|
||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse
|
||||
import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest
|
||||
import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse
|
||||
import org.elasticsearch.client.IndicesAdminClient
|
||||
import org.elasticsearch.client.internal.InternalClient
|
||||
import org.elasticsearch.groovy.client.action.GActionFuture
|
||||
import org.elasticsearch.groovy.util.json.JsonBuilder
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
class GIndicesAdminClient {
|
||||
|
||||
static {
|
||||
CreateIndexRequest.metaClass.setSource = {Closure c ->
|
||||
delegate.settings(new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
CreateIndexRequest.metaClass.source = {Closure c ->
|
||||
delegate.settings(new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
CreateIndexRequest.metaClass.mapping = {String type, Closure c ->
|
||||
delegate.mapping(type, new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
CreateIndexRequest.metaClass.setMapping = {String type, Closure c ->
|
||||
delegate.mapping(type, new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
|
||||
PutMappingRequest.metaClass.setSource = {Closure c ->
|
||||
delegate.source(new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
PutMappingRequest.metaClass.source = {Closure c ->
|
||||
delegate.source(new JsonBuilder().buildAsString(c))
|
||||
}
|
||||
}
|
||||
|
||||
private final GClient gClient
|
||||
|
||||
private final InternalClient internalClient;
|
||||
@ -24,6 +65,68 @@ class GIndicesAdminClient {
|
||||
this.indicesAdminClient = internalClient.admin().indices();
|
||||
}
|
||||
|
||||
// STATUS
|
||||
|
||||
GActionFuture<IndicesStatusResponse> status(Closure c) {
|
||||
IndicesStatusRequest request = new IndicesStatusRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
status(request)
|
||||
}
|
||||
|
||||
GActionFuture<IndicesStatusResponse> status(IndicesStatusRequest request) {
|
||||
GActionFuture<IndicesStatusResponse> future = new GActionFuture<IndicesStatusResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.status(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void status(IndicesStatusRequest request, ActionListener<IndicesStatusResponse> listener) {
|
||||
indicesAdminClient.status(request, listener)
|
||||
}
|
||||
|
||||
// CREATE
|
||||
|
||||
GActionFuture<CreateIndexResponse> create(Closure c) {
|
||||
CreateIndexRequest request = new CreateIndexRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
create(request)
|
||||
}
|
||||
|
||||
GActionFuture<CreateIndexResponse> create(CreateIndexRequest request) {
|
||||
GActionFuture<CreateIndexResponse> future = new GActionFuture<CreateIndexResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.create(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void create(CreateIndexRequest request, ActionListener<CreateIndexResponse> listener) {
|
||||
indicesAdminClient.create(request, listener)
|
||||
}
|
||||
|
||||
// DELETE
|
||||
|
||||
GActionFuture<DeleteIndexResponse> delete(Closure c) {
|
||||
DeleteIndexRequest request = new DeleteIndexRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
delete(request)
|
||||
}
|
||||
|
||||
GActionFuture<DeleteIndexResponse> delete(DeleteIndexRequest request) {
|
||||
GActionFuture<DeleteIndexResponse> future = new GActionFuture<DeleteIndexResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.delete(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void delete(DeleteIndexRequest request, ActionListener<DeleteIndexResponse> listener) {
|
||||
indicesAdminClient.delete(request, listener)
|
||||
}
|
||||
|
||||
// REFRESH
|
||||
|
||||
GActionFuture<RefreshResponse> refresh(Closure c) {
|
||||
RefreshRequest request = new RefreshRequest()
|
||||
c.setDelegate request
|
||||
@ -41,4 +144,124 @@ class GIndicesAdminClient {
|
||||
void refresh(RefreshRequest request, ActionListener<RefreshResponse> listener) {
|
||||
indicesAdminClient.refresh(request, listener)
|
||||
}
|
||||
|
||||
// FLUSH
|
||||
|
||||
GActionFuture<FlushResponse> flush(Closure c) {
|
||||
FlushRequest request = new FlushRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
flush(request)
|
||||
}
|
||||
|
||||
GActionFuture<FlushResponse> flush(FlushRequest request) {
|
||||
GActionFuture<FlushResponse> future = new GActionFuture<FlushResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.flush(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void flush(FlushRequest request, ActionListener<FlushResponse> listener) {
|
||||
indicesAdminClient.flush(request, listener)
|
||||
}
|
||||
|
||||
// OPTIMIZE
|
||||
|
||||
GActionFuture<OptimizeResponse> optimize(Closure c) {
|
||||
OptimizeRequest request = new OptimizeRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
optimize(request)
|
||||
}
|
||||
|
||||
GActionFuture<OptimizeResponse> optimize(OptimizeRequest request) {
|
||||
GActionFuture<OptimizeResponse> future = new GActionFuture<OptimizeResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.optimize(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void optimize(OptimizeRequest request, ActionListener<OptimizeResponse> listener) {
|
||||
indicesAdminClient.optimize(request, listener)
|
||||
}
|
||||
|
||||
// PUT MAPPING
|
||||
|
||||
GActionFuture<PutMappingResponse> putMapping(Closure c) {
|
||||
PutMappingRequest request = new PutMappingRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
putMapping(request)
|
||||
}
|
||||
|
||||
GActionFuture<PutMappingResponse> putMapping(PutMappingRequest request) {
|
||||
GActionFuture<PutMappingResponse> future = new GActionFuture<PutMappingResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.putMapping(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void putMapping(PutMappingRequest request, ActionListener<PutMappingResponse> listener) {
|
||||
indicesAdminClient.putMapping(request, listener)
|
||||
}
|
||||
|
||||
// GATEWAY SNAPSHOT
|
||||
|
||||
GActionFuture<GatewaySnapshotResponse> gatewaySnapshot(Closure c) {
|
||||
GatewaySnapshotRequest request = new GatewaySnapshotRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
gatewaySnapshot(request)
|
||||
}
|
||||
|
||||
GActionFuture<GatewaySnapshotResponse> gatewaySnapshot(GatewaySnapshotRequest request) {
|
||||
GActionFuture<GatewaySnapshotResponse> future = new GActionFuture<GatewaySnapshotResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.gatewaySnapshot(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void gatewaySnapshot(GatewaySnapshotRequest request, ActionListener<GatewaySnapshotResponse> listener) {
|
||||
indicesAdminClient.gatewaySnapshot(request, listener)
|
||||
}
|
||||
|
||||
// Aliases
|
||||
|
||||
GActionFuture<IndicesAliasesResponse> aliases(Closure c) {
|
||||
IndicesAliasesRequest request = new IndicesAliasesRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
aliases(request)
|
||||
}
|
||||
|
||||
GActionFuture<IndicesAliasesResponse> aliases(IndicesAliasesRequest request) {
|
||||
GActionFuture<IndicesAliasesResponse> future = new GActionFuture<IndicesAliasesResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.aliases(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void aliases(IndicesAliasesRequest request, ActionListener<IndicesAliasesResponse> listener) {
|
||||
indicesAdminClient.aliases(request, listener)
|
||||
}
|
||||
|
||||
// CLEAR CACHE
|
||||
|
||||
GActionFuture<ClearIndicesCacheResponse> clearCache(Closure c) {
|
||||
ClearIndicesCacheRequest request = new ClearIndicesCacheRequest()
|
||||
c.setDelegate request
|
||||
c.resolveStrategy = gClient.resolveStrategy
|
||||
c.call()
|
||||
clearCache(request)
|
||||
}
|
||||
|
||||
GActionFuture<ClearIndicesCacheResponse> clearCache(ClearIndicesCacheRequest request) {
|
||||
GActionFuture<ClearIndicesCacheResponse> future = new GActionFuture<ClearIndicesCacheResponse>(internalClient.threadPool(), request);
|
||||
indicesAdminClient.clearCache(request, future)
|
||||
return future
|
||||
}
|
||||
|
||||
void aliases(ClearIndicesCacheRequest request, ActionListener<ClearIndicesCacheResponse> listener) {
|
||||
indicesAdminClient.clearCache(request, listener)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user