From 0c0f717abaf6895893cab43522543368222a8aa2 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Wed, 7 May 2014 10:33:48 +0200 Subject: [PATCH] Removed Index Status API The functionality of the index status API has been replaced by the recovery API. Relates #4854 --- .../elasticsearch/action/ActionModule.java | 3 - .../admin/indices/status/DocsStatus.java | 51 --- .../indices/status/GatewayRecoveryStatus.java | 133 -------- .../indices/status/GatewaySnapshotStatus.java | 104 ------ .../indices/status/IndexShardStatus.java | 170 --------- .../admin/indices/status/IndexStatus.java | 178 ---------- .../indices/status/IndicesStatusAction.java | 45 --- .../indices/status/IndicesStatusRequest.java | 83 ----- .../status/IndicesStatusRequestBuilder.java | 56 --- .../indices/status/IndicesStatusResponse.java | 322 ------------------ .../indices/status/PeerRecoveryStatus.java | 133 -------- .../admin/indices/status/ShardStatus.java | 282 --------------- .../status/TransportIndicesStatusAction.java | 265 -------------- .../client/IndicesAdminClient.java | 26 -- .../org/elasticsearch/client/Requests.java | 12 - .../support/AbstractIndicesAdminClient.java | 19 -- .../rest/action/RestActionModule.java | 2 - .../status/RestIndicesStatusAction.java | 75 ---- .../SimpleRecoveryLocalGatewayTests.java | 24 +- .../indices/IndicesOptionsTests.java | 14 - .../indices/state/SimpleIndexStateTests.java | 5 - .../nested/SimpleNestedTests.java | 45 +-- .../RollingRestartStressTest.java | 15 - 23 files changed, 35 insertions(+), 2027 deletions(-) delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusAction.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequestBuilder.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java delete mode 100644 src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java delete mode 100644 src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java diff --git a/src/main/java/org/elasticsearch/action/ActionModule.java b/src/main/java/org/elasticsearch/action/ActionModule.java index 5dfec1fccde..e7637065428 100644 --- a/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/src/main/java/org/elasticsearch/action/ActionModule.java @@ -103,8 +103,6 @@ import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettin import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction; -import org.elasticsearch.action.admin.indices.status.IndicesStatusAction; -import org.elasticsearch.action.admin.indices.status.TransportIndicesStatusAction; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction; @@ -220,7 +218,6 @@ public class ActionModule extends AbstractModule { registerAction(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class); registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class); - registerAction(IndicesStatusAction.INSTANCE, TransportIndicesStatusAction.class); registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class); registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class); registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java deleted file mode 100644 index 541ace01125..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/DocsStatus.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -/** - * - */ -public class DocsStatus { - - long numDocs = 0; - long maxDoc = 0; - long deletedDocs = 0; - - /** - * The number of docs. - */ - public long getNumDocs() { - return numDocs; - } - - /** - * The max doc. - */ - public long getMaxDoc() { - return maxDoc; - } - - /** - * The number of deleted docs in the index. - */ - public long getDeletedDocs() { - return deletedDocs; - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java deleted file mode 100644 index 6c6c18f7f13..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewayRecoveryStatus.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.TimeValue; - -/** - * - */ -public class GatewayRecoveryStatus { - - public enum Stage { - INIT((byte) 0), - INDEX((byte) 1), - TRANSLOG((byte) 2), - FINALIZE((byte) 3), - DONE((byte) 4); - - private final byte value; - - Stage(byte value) { - this.value = value; - } - - public byte value() { - return value; - } - - public static Stage fromValue(byte value) { - if (value == 0) { - return INIT; - } else if (value == 1) { - return INDEX; - } else if (value == 2) { - return TRANSLOG; - } else if (value == 3) { - return FINALIZE; - } else if (value == 4) { - return DONE; - } - throw new ElasticsearchIllegalArgumentException("No stage found for [" + value + ']'); - } - } - - final Stage stage; - - final long startTime; - - final long time; - - final long indexSize; - - final long reusedIndexSize; - - final long recoveredIndexSize; - - final long recoveredTranslogOperations; - - public GatewayRecoveryStatus(Stage stage, long startTime, long time, long indexSize, long reusedIndexSize, - long recoveredIndexSize, long recoveredTranslogOperations) { - this.stage = stage; - this.startTime = startTime; - this.time = time; - this.indexSize = indexSize; - this.reusedIndexSize = reusedIndexSize; - this.recoveredIndexSize = recoveredIndexSize; - this.recoveredTranslogOperations = recoveredTranslogOperations; - } - - public Stage getStage() { - return this.stage; - } - - public long getStartTime() { - return this.startTime; - } - - public TimeValue getTime() { - return TimeValue.timeValueMillis(time); - } - - public ByteSizeValue getIndexSize() { - return new ByteSizeValue(indexSize); - } - - public ByteSizeValue getReusedIndexSize() { - return new ByteSizeValue(reusedIndexSize); - } - - public ByteSizeValue getExpectedRecoveredIndexSize() { - return new ByteSizeValue(indexSize - reusedIndexSize); - } - - /** - * How much of the index has been recovered. - */ - public ByteSizeValue getRecoveredIndexSize() { - return new ByteSizeValue(recoveredIndexSize); - } - - public int getIndexRecoveryProgress() { - if (recoveredIndexSize == 0) { - if (indexSize != 0 && indexSize == reusedIndexSize) { - return 100; - } - return 0; - } - return (int) (((double) recoveredIndexSize) / getExpectedRecoveredIndexSize().bytes() * 100); - } - - public long getRecoveredTranslogOperations() { - return recoveredTranslogOperations; - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java deleted file mode 100644 index 1bcd48b2f6f..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/GatewaySnapshotStatus.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.TimeValue; - -/** - * - */ -public class GatewaySnapshotStatus { - - public static enum Stage { - NONE((byte) 0), - INDEX((byte) 1), - TRANSLOG((byte) 2), - FINALIZE((byte) 3), - DONE((byte) 4), - FAILURE((byte) 5); - - private final byte value; - - Stage(byte value) { - this.value = value; - } - - public byte value() { - return this.value; - } - - public static Stage fromValue(byte value) { - if (value == 0) { - return Stage.NONE; - } else if (value == 1) { - return Stage.INDEX; - } else if (value == 2) { - return Stage.TRANSLOG; - } else if (value == 3) { - return Stage.FINALIZE; - } else if (value == 4) { - return Stage.DONE; - } else if (value == 5) { - return Stage.FAILURE; - } - throw new ElasticsearchIllegalArgumentException("No stage found for [" + value + "]"); - } - } - - final Stage stage; - - final long startTime; - - final long time; - - final long indexSize; - - final int expectedNumberOfOperations; - - public GatewaySnapshotStatus(Stage stage, long startTime, long time, long indexSize, int expectedNumberOfOperations) { - this.stage = stage; - this.startTime = startTime; - this.time = time; - this.indexSize = indexSize; - this.expectedNumberOfOperations = expectedNumberOfOperations; - } - - public Stage getStage() { - return this.stage; - } - - public long getStartTime() { - return this.startTime; - } - - public TimeValue getTime() { - return TimeValue.timeValueMillis(time); - } - - public ByteSizeValue getIndexSize() { - return new ByteSizeValue(indexSize); - } - - public int getExpectedNumberOfOperations() { - return expectedNumberOfOperations; - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java deleted file mode 100644 index 5ad644b26e6..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexShardStatus.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import com.google.common.collect.Iterators; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.refresh.RefreshStats; -import org.elasticsearch.index.shard.ShardId; - -import java.util.Iterator; - -/** - * - */ -public class IndexShardStatus implements Iterable { - - private final ShardId shardId; - - private final ShardStatus[] shards; - - IndexShardStatus(ShardId shardId, ShardStatus[] shards) { - this.shardId = shardId; - this.shards = shards; - } - - public ShardId getShardId() { - return this.shardId; - } - - public ShardStatus[] getShards() { - return this.shards; - } - - public ShardStatus getAt(int position) { - return shards[position]; - } - - /** - * Returns only the primary shards store size in bytes. - */ - public ByteSizeValue getPrimaryStoreSize() { - long bytes = -1; - for (ShardStatus shard : getShards()) { - if (!shard.getShardRouting().primary()) { - // only sum docs for the primaries - continue; - } - if (shard.getStoreSize() != null) { - if (bytes == -1) { - bytes = 0; - } - bytes += shard.getStoreSize().bytes(); - } - } - if (bytes == -1) { - return null; - } - return new ByteSizeValue(bytes); - } - - /** - * Returns the full store size in bytes, of both primaries and replicas. - */ - public ByteSizeValue getStoreSize() { - long bytes = -1; - for (ShardStatus shard : getShards()) { - if (shard.getStoreSize() != null) { - if (bytes == -1) { - bytes = 0; - } - bytes += shard.getStoreSize().bytes(); - } - } - if (bytes == -1) { - return null; - } - return new ByteSizeValue(bytes); - } - - public long getTranslogOperations() { - long translogOperations = -1; - for (ShardStatus shard : getShards()) { - if (shard.getTranslogOperations() != -1) { - if (translogOperations == -1) { - translogOperations = 0; - } - translogOperations += shard.getTranslogOperations(); - } - } - return translogOperations; - } - - private transient DocsStatus docs; - - public DocsStatus getDocs() { - if (docs != null) { - return docs; - } - DocsStatus docs = null; - for (ShardStatus shard : getShards()) { - if (!shard.getShardRouting().primary()) { - // only sum docs for the primaries - continue; - } - if (shard.getDocs() == null) { - continue; - } - if (docs == null) { - docs = new DocsStatus(); - } - docs.numDocs += shard.getDocs().getNumDocs(); - docs.maxDoc += shard.getDocs().getMaxDoc(); - docs.deletedDocs += shard.getDocs().getDeletedDocs(); - } - this.docs = docs; - return this.docs; - } - - /** - * Total merges of this shard replication group. - */ - public MergeStats getMergeStats() { - MergeStats mergeStats = new MergeStats(); - for (ShardStatus shard : shards) { - mergeStats.add(shard.getMergeStats()); - } - return mergeStats; - } - - public RefreshStats getRefreshStats() { - RefreshStats refreshStats = new RefreshStats(); - for (ShardStatus shard : shards) { - refreshStats.add(shard.getRefreshStats()); - } - return refreshStats; - } - - public FlushStats getFlushStats() { - FlushStats flushStats = new FlushStats(); - for (ShardStatus shard : shards) { - flushStats.add(shard.flushStats); - } - return flushStats; - } - - @Override - public Iterator iterator() { - return Iterators.forArray(shards); - } - -} \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java deleted file mode 100644 index 334d907918a..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndexStatus.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import com.google.common.collect.Maps; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.refresh.RefreshStats; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * - */ -public class IndexStatus implements Iterable { - - private final String index; - - private final Map indexShards; - - IndexStatus(String index, ShardStatus[] shards) { - this.index = index; - - Map> tmpIndexShards = Maps.newHashMap(); - for (ShardStatus shard : shards) { - List lst = tmpIndexShards.get(shard.getShardRouting().id()); - if (lst == null) { - lst = newArrayList(); - tmpIndexShards.put(shard.getShardRouting().id(), lst); - } - lst.add(shard); - } - indexShards = Maps.newHashMap(); - for (Map.Entry> entry : tmpIndexShards.entrySet()) { - indexShards.put(entry.getKey(), new IndexShardStatus(entry.getValue().get(0).getShardRouting().shardId(), entry.getValue().toArray(new ShardStatus[entry.getValue().size()]))); - } - } - - public String getIndex() { - return this.index; - } - - /** - * A shard id to index shard status map (note, index shard status is the replication shard group that maps - * to the shard id). - */ - public Map getShards() { - return this.indexShards; - } - - /** - * Returns only the primary shards store size in bytes. - */ - public ByteSizeValue getPrimaryStoreSize() { - long bytes = -1; - for (IndexShardStatus shard : this) { - if (shard.getPrimaryStoreSize() != null) { - if (bytes == -1) { - bytes = 0; - } - bytes += shard.getPrimaryStoreSize().bytes(); - } - } - if (bytes == -1) { - return null; - } - return new ByteSizeValue(bytes); - } - - /** - * Returns the full store size in bytes, of both primaries and replicas. - */ - public ByteSizeValue getStoreSize() { - long bytes = -1; - for (IndexShardStatus shard : this) { - if (shard.getStoreSize() != null) { - if (bytes == -1) { - bytes = 0; - } - bytes += shard.getStoreSize().bytes(); - } - } - if (bytes == -1) { - return null; - } - return new ByteSizeValue(bytes); - } - - public long getTranslogOperations() { - long translogOperations = -1; - for (IndexShardStatus shard : this) { - if (shard.getTranslogOperations() != -1) { - if (translogOperations == -1) { - translogOperations = 0; - } - translogOperations += shard.getTranslogOperations(); - } - } - return translogOperations; - } - - private transient DocsStatus docs; - - public DocsStatus getDocs() { - if (docs != null) { - return docs; - } - DocsStatus docs = null; - for (IndexShardStatus shard : this) { - if (shard.getDocs() == null) { - continue; - } - if (docs == null) { - docs = new DocsStatus(); - } - docs.numDocs += shard.getDocs().getNumDocs(); - docs.maxDoc += shard.getDocs().getMaxDoc(); - docs.deletedDocs += shard.getDocs().getDeletedDocs(); - } - this.docs = docs; - return docs; - } - - /** - * Total merges of this index. - */ - public MergeStats getMergeStats() { - MergeStats mergeStats = new MergeStats(); - for (IndexShardStatus shard : this) { - mergeStats.add(shard.getMergeStats()); - } - return mergeStats; - } - - public RefreshStats getRefreshStats() { - RefreshStats refreshStats = new RefreshStats(); - for (IndexShardStatus shard : this) { - refreshStats.add(shard.getRefreshStats()); - } - return refreshStats; - } - - public FlushStats getFlushStats() { - FlushStats flushStats = new FlushStats(); - for (IndexShardStatus shard : this) { - flushStats.add(shard.getFlushStats()); - } - return flushStats; - } - - @Override - public Iterator iterator() { - return indexShards.values().iterator(); - } - -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusAction.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusAction.java deleted file mode 100644 index 8c394fbb463..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusAction.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.action.admin.indices.IndicesAction; -import org.elasticsearch.client.IndicesAdminClient; - -/** - */ -public class IndicesStatusAction extends IndicesAction { - - public static final IndicesStatusAction INSTANCE = new IndicesStatusAction(); - public static final String NAME = "indices/status"; - - private IndicesStatusAction() { - super(NAME); - } - - @Override - public IndicesStatusResponse newResponse() { - return new IndicesStatusResponse(); - } - - @Override - public IndicesStatusRequestBuilder newRequestBuilder(IndicesAdminClient client) { - return new IndicesStatusRequestBuilder(client); - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java deleted file mode 100644 index ff2045dd964..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -/** - * - */ -public class IndicesStatusRequest extends BroadcastOperationRequest { - - private boolean recovery = false; - - private boolean snapshot = false; - - public IndicesStatusRequest() { - this(Strings.EMPTY_ARRAY); - } - - public IndicesStatusRequest(String... indices) { - super(indices); - } - - /** - * Should the status include recovery information. Defaults to false. - */ - public IndicesStatusRequest recovery(boolean recovery) { - this.recovery = recovery; - return this; - } - - public boolean recovery() { - return this.recovery; - } - - /** - * Should the status include recovery information. Defaults to false. - */ - public IndicesStatusRequest snapshot(boolean snapshot) { - this.snapshot = snapshot; - return this; - } - - public boolean snapshot() { - return this.snapshot; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeBoolean(recovery); - out.writeBoolean(snapshot); - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - recovery = in.readBoolean(); - snapshot = in.readBoolean(); - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequestBuilder.java deleted file mode 100644 index b93d6faba99..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusRequestBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder; -import org.elasticsearch.client.IndicesAdminClient; -import org.elasticsearch.client.internal.InternalIndicesAdminClient; - -/** - * - */ -public class IndicesStatusRequestBuilder extends BroadcastOperationRequestBuilder { - - public IndicesStatusRequestBuilder(IndicesAdminClient indicesClient) { - super((InternalIndicesAdminClient) indicesClient, new IndicesStatusRequest()); - } - - /** - * Should the status include recovery information. Defaults to false. - */ - public IndicesStatusRequestBuilder setRecovery(boolean recovery) { - request.recovery(recovery); - return this; - } - - /** - * Should the status include recovery information. Defaults to false. - */ - public IndicesStatusRequestBuilder setSnapshot(boolean snapshot) { - request.snapshot(snapshot); - return this; - } - - @Override - protected void doExecute(ActionListener listener) { - ((IndicesAdminClient) client).status(request, listener); - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java deleted file mode 100644 index 79e6092446f..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/IndicesStatusResponse.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import com.google.common.collect.Sets; -import org.elasticsearch.action.ShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.SettingsFilter; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentBuilderString; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.refresh.RefreshStats; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Maps.newHashMap; -import static org.elasticsearch.action.admin.indices.status.ShardStatus.readIndexShardStatus; - -/** - * - */ -public class IndicesStatusResponse extends BroadcastOperationResponse implements ToXContent { - - protected ShardStatus[] shards; - - private Map indicesStatus; - - IndicesStatusResponse() { - } - - IndicesStatusResponse(ShardStatus[] shards, ClusterState clusterState, int totalShards, int successfulShards, int failedShards, List shardFailures) { - super(totalShards, successfulShards, failedShards, shardFailures); - this.shards = shards; - } - - public ShardStatus[] getShards() { - return this.shards; - } - - public ShardStatus getAt(int position) { - return shards[position]; - } - - public IndexStatus getIndex(String index) { - return getIndices().get(index); - } - - public Map getIndices() { - if (indicesStatus != null) { - return indicesStatus; - } - Map indicesStatus = newHashMap(); - - Set indices = Sets.newHashSet(); - for (ShardStatus shard : shards) { - indices.add(shard.getIndex()); - } - - for (String index : indices) { - List shards = newArrayList(); - for (ShardStatus shard : this.shards) { - if (shard.getShardRouting().index().equals(index)) { - shards.add(shard); - } - } - indicesStatus.put(index, new IndexStatus(index, shards.toArray(new ShardStatus[shards.size()]))); - } - this.indicesStatus = indicesStatus; - return indicesStatus; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeVInt(getShards().length); - for (ShardStatus status : getShards()) { - status.writeTo(out); - } - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - shards = new ShardStatus[in.readVInt()]; - for (int i = 0; i < shards.length; i++) { - shards[i] = readIndexShardStatus(in); - } - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - return toXContent(builder, params, null); - } - - public XContentBuilder toXContent(XContentBuilder builder, Params params, @Nullable SettingsFilter settingsFilter) throws IOException { - builder.startObject(Fields.INDICES); - for (IndexStatus indexStatus : getIndices().values()) { - builder.startObject(indexStatus.getIndex(), XContentBuilder.FieldCaseConversion.NONE); - - builder.startObject(Fields.INDEX); - if (indexStatus.getStoreSize() != null) { - builder.byteSizeField(Fields.PRIMARY_SIZE_IN_BYTES, Fields.PRIMARY_SIZE, indexStatus.getPrimaryStoreSize()); - builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, indexStatus.getStoreSize()); - } - builder.endObject(); - if (indexStatus.getTranslogOperations() != -1) { - builder.startObject(Fields.TRANSLOG); - builder.field(Fields.OPERATIONS, indexStatus.getTranslogOperations()); - builder.endObject(); - } - - if (indexStatus.getDocs() != null) { - builder.startObject(Fields.DOCS); - builder.field(Fields.NUM_DOCS, indexStatus.getDocs().getNumDocs()); - builder.field(Fields.MAX_DOC, indexStatus.getDocs().getMaxDoc()); - builder.field(Fields.DELETED_DOCS, indexStatus.getDocs().getDeletedDocs()); - builder.endObject(); - } - - MergeStats mergeStats = indexStatus.getMergeStats(); - if (mergeStats != null) { - mergeStats.toXContent(builder, params); - } - RefreshStats refreshStats = indexStatus.getRefreshStats(); - if (refreshStats != null) { - refreshStats.toXContent(builder, params); - } - FlushStats flushStats = indexStatus.getFlushStats(); - if (flushStats != null) { - flushStats.toXContent(builder, params); - } - - builder.startObject(Fields.SHARDS); - for (IndexShardStatus indexShardStatus : indexStatus) { - builder.startArray(Integer.toString(indexShardStatus.getShardId().id())); - for (ShardStatus shardStatus : indexShardStatus) { - builder.startObject(); - - builder.startObject(Fields.ROUTING) - .field(Fields.STATE, shardStatus.getShardRouting().state()) - .field(Fields.PRIMARY, shardStatus.getShardRouting().primary()) - .field(Fields.NODE, shardStatus.getShardRouting().currentNodeId()) - .field(Fields.RELOCATING_NODE, shardStatus.getShardRouting().relocatingNodeId()) - .field(Fields.SHARD, shardStatus.getShardRouting().shardId().id()) - .field(Fields.INDEX, shardStatus.getShardRouting().shardId().index().name()) - .endObject(); - - builder.field(Fields.STATE, shardStatus.getState()); - if (shardStatus.getStoreSize() != null) { - builder.startObject(Fields.INDEX); - builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, shardStatus.getStoreSize()); - builder.endObject(); - } - if (shardStatus.getTranslogId() != -1) { - builder.startObject(Fields.TRANSLOG); - builder.field(Fields.ID, shardStatus.getTranslogId()); - builder.field(Fields.OPERATIONS, shardStatus.getTranslogOperations()); - builder.endObject(); - } - - if (shardStatus.getDocs() != null) { - builder.startObject(Fields.DOCS); - builder.field(Fields.NUM_DOCS, shardStatus.getDocs().getNumDocs()); - builder.field(Fields.MAX_DOC, shardStatus.getDocs().getMaxDoc()); - builder.field(Fields.DELETED_DOCS, shardStatus.getDocs().getDeletedDocs()); - builder.endObject(); - } - - mergeStats = shardStatus.getMergeStats(); - if (mergeStats != null) { - mergeStats.toXContent(builder, params); - } - - refreshStats = shardStatus.getRefreshStats(); - if (refreshStats != null) { - refreshStats.toXContent(builder, params); - } - flushStats = shardStatus.getFlushStats(); - if (flushStats != null) { - flushStats.toXContent(builder, params); - } - - if (shardStatus.getPeerRecoveryStatus() != null) { - PeerRecoveryStatus peerRecoveryStatus = shardStatus.getPeerRecoveryStatus(); - builder.startObject(Fields.PEER_RECOVERY); - builder.field(Fields.STAGE, peerRecoveryStatus.getStage()); - builder.field(Fields.START_TIME_IN_MILLIS, peerRecoveryStatus.getStartTime()); - builder.timeValueField(Fields.TIME_IN_MILLIS, Fields.TIME, peerRecoveryStatus.getTime()); - - builder.startObject(Fields.INDEX); - builder.field(Fields.PROGRESS, peerRecoveryStatus.getIndexRecoveryProgress()); - builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, peerRecoveryStatus.getIndexSize()); - builder.byteSizeField(Fields.REUSED_SIZE_IN_BYTES, Fields.REUSED_SIZE, peerRecoveryStatus.getReusedIndexSize()); - builder.byteSizeField(Fields.EXPECTED_RECOVERED_SIZE_IN_BYTES, Fields.EXPECTED_RECOVERED_SIZE, peerRecoveryStatus.getExpectedRecoveredIndexSize()); - builder.byteSizeField(Fields.RECOVERED_SIZE_IN_BYTES, Fields.RECOVERED_SIZE, peerRecoveryStatus.getRecoveredIndexSize()); - builder.endObject(); - - builder.startObject(Fields.TRANSLOG); - builder.field(Fields.RECOVERED, peerRecoveryStatus.getRecoveredTranslogOperations()); - builder.endObject(); - - builder.endObject(); - } - - if (shardStatus.getGatewayRecoveryStatus() != null) { - GatewayRecoveryStatus gatewayRecoveryStatus = shardStatus.getGatewayRecoveryStatus(); - builder.startObject(Fields.GATEWAY_RECOVERY); - builder.field(Fields.STAGE, gatewayRecoveryStatus.getStage()); - builder.field(Fields.START_TIME_IN_MILLIS, gatewayRecoveryStatus.getStartTime()); - builder.timeValueField(Fields.TIME_IN_MILLIS, Fields.TIME, gatewayRecoveryStatus.getTime()); - - builder.startObject(Fields.INDEX); - builder.field(Fields.PROGRESS, gatewayRecoveryStatus.getIndexRecoveryProgress()); - builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, gatewayRecoveryStatus.getIndexSize()); - builder.byteSizeField(Fields.REUSED_SIZE_IN_BYTES, Fields.REUSED_SIZE, gatewayRecoveryStatus.getReusedIndexSize()); - builder.byteSizeField(Fields.EXPECTED_RECOVERED_SIZE_IN_BYTES, Fields.EXPECTED_RECOVERED_SIZE, gatewayRecoveryStatus.getExpectedRecoveredIndexSize()); - builder.byteSizeField(Fields.RECOVERED_SIZE_IN_BYTES, Fields.RECOVERED_SIZE, gatewayRecoveryStatus.getRecoveredIndexSize()); - builder.endObject(); - - builder.startObject(Fields.TRANSLOG); - builder.field(Fields.RECOVERED, gatewayRecoveryStatus.getRecoveredTranslogOperations()); - builder.endObject(); - - builder.endObject(); - } - - if (shardStatus.getGatewaySnapshotStatus() != null) { - GatewaySnapshotStatus gatewaySnapshotStatus = shardStatus.getGatewaySnapshotStatus(); - builder.startObject(Fields.GATEWAY_SNAPSHOT); - builder.field(Fields.STAGE, gatewaySnapshotStatus.getStage()); - builder.field(Fields.START_TIME_IN_MILLIS, gatewaySnapshotStatus.getStartTime()); - builder.timeValueField(Fields.TIME_IN_MILLIS, Fields.TIME, gatewaySnapshotStatus.getTime()); - - builder.startObject(Fields.INDEX); - builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, gatewaySnapshotStatus.getIndexSize()); - builder.endObject(); - - builder.startObject(Fields.TRANSLOG); - builder.field(Fields.EXPECTED_OPERATIONS, gatewaySnapshotStatus.getExpectedNumberOfOperations()); - builder.endObject(); - - builder.endObject(); - } - - builder.endObject(); - } - builder.endArray(); - } - builder.endObject(); - - builder.endObject(); - } - builder.endObject(); - return builder; - } - - static final class Fields { - static final XContentBuilderString INDICES = new XContentBuilderString("indices"); - static final XContentBuilderString INDEX = new XContentBuilderString("index"); - static final XContentBuilderString PRIMARY_SIZE = new XContentBuilderString("primary_size"); - static final XContentBuilderString PRIMARY_SIZE_IN_BYTES = new XContentBuilderString("primary_size_in_bytes"); - static final XContentBuilderString SIZE = new XContentBuilderString("size"); - static final XContentBuilderString SIZE_IN_BYTES = new XContentBuilderString("size_in_bytes"); - static final XContentBuilderString TRANSLOG = new XContentBuilderString("translog"); - static final XContentBuilderString OPERATIONS = new XContentBuilderString("operations"); - static final XContentBuilderString DOCS = new XContentBuilderString("docs"); - static final XContentBuilderString NUM_DOCS = new XContentBuilderString("num_docs"); - static final XContentBuilderString MAX_DOC = new XContentBuilderString("max_doc"); - static final XContentBuilderString DELETED_DOCS = new XContentBuilderString("deleted_docs"); - static final XContentBuilderString SHARDS = new XContentBuilderString("shards"); - static final XContentBuilderString ROUTING = new XContentBuilderString("routing"); - static final XContentBuilderString STATE = new XContentBuilderString("state"); - static final XContentBuilderString PRIMARY = new XContentBuilderString("primary"); - static final XContentBuilderString NODE = new XContentBuilderString("node"); - static final XContentBuilderString RELOCATING_NODE = new XContentBuilderString("relocating_node"); - static final XContentBuilderString SHARD = new XContentBuilderString("shard"); - static final XContentBuilderString ID = new XContentBuilderString("id"); - static final XContentBuilderString PEER_RECOVERY = new XContentBuilderString("peer_recovery"); - static final XContentBuilderString STAGE = new XContentBuilderString("stage"); - static final XContentBuilderString START_TIME_IN_MILLIS = new XContentBuilderString("start_time_in_millis"); - static final XContentBuilderString TIME = new XContentBuilderString("time"); - static final XContentBuilderString TIME_IN_MILLIS = new XContentBuilderString("time_in_millis"); - static final XContentBuilderString PROGRESS = new XContentBuilderString("progress"); - static final XContentBuilderString REUSED_SIZE = new XContentBuilderString("reused_size"); - static final XContentBuilderString REUSED_SIZE_IN_BYTES = new XContentBuilderString("reused_size_in_bytes"); - static final XContentBuilderString EXPECTED_RECOVERED_SIZE = new XContentBuilderString("expected_recovered_size"); - static final XContentBuilderString EXPECTED_RECOVERED_SIZE_IN_BYTES = new XContentBuilderString("expected_recovered_size_in_bytes"); - static final XContentBuilderString RECOVERED_SIZE = new XContentBuilderString("recovered_size"); - static final XContentBuilderString RECOVERED_SIZE_IN_BYTES = new XContentBuilderString("recovered_size_in_bytes"); - static final XContentBuilderString RECOVERED = new XContentBuilderString("recovered"); - static final XContentBuilderString GATEWAY_RECOVERY = new XContentBuilderString("gateway_recovery"); - static final XContentBuilderString GATEWAY_SNAPSHOT = new XContentBuilderString("gateway_snapshot"); - static final XContentBuilderString EXPECTED_OPERATIONS = new XContentBuilderString("expected_operations"); - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java deleted file mode 100644 index 1fe9cc00350..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/PeerRecoveryStatus.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.TimeValue; - -/** - * - */ -public class PeerRecoveryStatus { - - public enum Stage { - INIT((byte) 0), - INDEX((byte) 1), - TRANSLOG((byte) 2), - FINALIZE((byte) 3), - DONE((byte) 4); - - private final byte value; - - Stage(byte value) { - this.value = value; - } - - public byte value() { - return value; - } - - public static Stage fromValue(byte value) { - if (value == 0) { - return INIT; - } else if (value == 1) { - return INDEX; - } else if (value == 2) { - return TRANSLOG; - } else if (value == 3) { - return FINALIZE; - } else if (value == 4) { - return DONE; - } - throw new ElasticsearchIllegalArgumentException("No stage found for [" + value + ']'); - } - } - - final Stage stage; - - final long startTime; - - final long time; - - final long indexSize; - - final long reusedIndexSize; - - final long recoveredIndexSize; - - final long recoveredTranslogOperations; - - public PeerRecoveryStatus(Stage stage, long startTime, long time, long indexSize, long reusedIndexSize, - long recoveredIndexSize, long recoveredTranslogOperations) { - this.stage = stage; - this.startTime = startTime; - this.time = time; - this.indexSize = indexSize; - this.reusedIndexSize = reusedIndexSize; - this.recoveredIndexSize = recoveredIndexSize; - this.recoveredTranslogOperations = recoveredTranslogOperations; - } - - public Stage getStage() { - return this.stage; - } - - public long getStartTime() { - return this.startTime; - } - - public TimeValue getTime() { - return TimeValue.timeValueMillis(time); - } - - public ByteSizeValue getIndexSize() { - return new ByteSizeValue(indexSize); - } - - public ByteSizeValue getReusedIndexSize() { - return new ByteSizeValue(reusedIndexSize); - } - - public ByteSizeValue getExpectedRecoveredIndexSize() { - return new ByteSizeValue(indexSize - reusedIndexSize); - } - - /** - * How much of the index has been recovered. - */ - public ByteSizeValue getRecoveredIndexSize() { - return new ByteSizeValue(recoveredIndexSize); - } - - public int getIndexRecoveryProgress() { - if (recoveredIndexSize == 0) { - if (indexSize != 0 && indexSize == reusedIndexSize) { - return 100; - } - return 0; - } - return (int) (((double) recoveredIndexSize) / getExpectedRecoveredIndexSize().bytes() * 100); - } - - public long getRecoveredTranslogOperations() { - return recoveredTranslogOperations; - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java b/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java deleted file mode 100644 index 6ad2035d93f..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.action.support.broadcast.BroadcastShardOperationResponse; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.refresh.RefreshStats; -import org.elasticsearch.index.shard.IndexShardState; - -import java.io.IOException; - -import static org.elasticsearch.cluster.routing.ImmutableShardRouting.readShardRoutingEntry; -import static org.elasticsearch.common.unit.ByteSizeValue.readBytesSizeValue; - -/** - * Shard instance (actual allocated shard) status. - */ -public class ShardStatus extends BroadcastShardOperationResponse { - - private ShardRouting shardRouting; - - IndexShardState state; - - ByteSizeValue storeSize; - - long translogId = -1; - - long translogOperations = -1; - - DocsStatus docs; - - MergeStats mergeStats; - - RefreshStats refreshStats; - - FlushStats flushStats; - - PeerRecoveryStatus peerRecoveryStatus; - - GatewayRecoveryStatus gatewayRecoveryStatus; - - GatewaySnapshotStatus gatewaySnapshotStatus; - - ShardStatus() { - } - - ShardStatus(ShardRouting shardRouting) { - super(shardRouting.index(), shardRouting.id()); - this.shardRouting = shardRouting; - } - - /** - * The shard routing information (cluster wide shard state). - */ - public ShardRouting getShardRouting() { - return this.shardRouting; - } - - /** - * The shard state (index/local state). - */ - public IndexShardState getState() { - return state; - } - - /** - * The current size of the shard index storage. - */ - public ByteSizeValue getStoreSize() { - return storeSize; - } - - /** - * The transaction log id. - */ - public long getTranslogId() { - return translogId; - } - - /** - * The number of transaction operations in the transaction log. - */ - public long getTranslogOperations() { - return translogOperations; - } - - /** - * Docs level information for the shard index, null if not applicable. - */ - public DocsStatus getDocs() { - return docs; - } - - /** - * Index merge statistics. - */ - public MergeStats getMergeStats() { - return this.mergeStats; - } - - /** - * Refresh stats. - */ - public RefreshStats getRefreshStats() { - return this.refreshStats; - } - - public FlushStats getFlushStats() { - return this.flushStats; - } - - /** - * Peer recovery status (null if not applicable). Both real time if an on going recovery - * is in progress and summary once it is done. - */ - public PeerRecoveryStatus getPeerRecoveryStatus() { - return peerRecoveryStatus; - } - - /** - * Gateway recovery status (null if not applicable). Both real time if an on going recovery - * is in progress adn summary once it is done. - */ - public GatewayRecoveryStatus getGatewayRecoveryStatus() { - return gatewayRecoveryStatus; - } - - /** - * The current on going snapshot to the gateway or the last one if none is on going. - */ - public GatewaySnapshotStatus getGatewaySnapshotStatus() { - return gatewaySnapshotStatus; - } - - public static ShardStatus readIndexShardStatus(StreamInput in) throws IOException { - ShardStatus shardStatus = new ShardStatus(); - shardStatus.readFrom(in); - return shardStatus; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - shardRouting.writeTo(out); - out.writeByte(state.id()); - if (storeSize == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - storeSize.writeTo(out); - } - out.writeLong(translogId); - out.writeLong(translogOperations); - if (docs == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeLong(docs.getNumDocs()); - out.writeLong(docs.getMaxDoc()); - out.writeLong(docs.getDeletedDocs()); - } - if (peerRecoveryStatus == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeByte(peerRecoveryStatus.stage.value()); - out.writeVLong(peerRecoveryStatus.startTime); - out.writeVLong(peerRecoveryStatus.time); - out.writeVLong(peerRecoveryStatus.indexSize); - out.writeVLong(peerRecoveryStatus.reusedIndexSize); - out.writeVLong(peerRecoveryStatus.recoveredIndexSize); - out.writeVLong(peerRecoveryStatus.recoveredTranslogOperations); - } - - if (gatewayRecoveryStatus == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeByte(gatewayRecoveryStatus.stage.value()); - out.writeVLong(gatewayRecoveryStatus.startTime); - out.writeVLong(gatewayRecoveryStatus.time); - out.writeVLong(gatewayRecoveryStatus.indexSize); - out.writeVLong(gatewayRecoveryStatus.reusedIndexSize); - out.writeVLong(gatewayRecoveryStatus.recoveredIndexSize); - out.writeVLong(gatewayRecoveryStatus.recoveredTranslogOperations); - } - - if (gatewaySnapshotStatus == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - out.writeByte(gatewaySnapshotStatus.stage.value()); - out.writeVLong(gatewaySnapshotStatus.startTime); - out.writeVLong(gatewaySnapshotStatus.time); - out.writeVLong(gatewaySnapshotStatus.indexSize); - out.writeVInt(gatewaySnapshotStatus.getExpectedNumberOfOperations()); - } - - if (mergeStats == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - mergeStats.writeTo(out); - } - if (refreshStats == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - refreshStats.writeTo(out); - } - if (flushStats == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - flushStats.writeTo(out); - } - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - shardRouting = readShardRoutingEntry(in); - state = IndexShardState.fromId(in.readByte()); - if (in.readBoolean()) { - storeSize = readBytesSizeValue(in); - } - translogId = in.readLong(); - translogOperations = in.readLong(); - if (in.readBoolean()) { - docs = new DocsStatus(); - docs.numDocs = in.readLong(); - docs.maxDoc = in.readLong(); - docs.deletedDocs = in.readLong(); - } - if (in.readBoolean()) { - peerRecoveryStatus = new PeerRecoveryStatus(PeerRecoveryStatus.Stage.fromValue(in.readByte()), - in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong()); - } - - if (in.readBoolean()) { - gatewayRecoveryStatus = new GatewayRecoveryStatus(GatewayRecoveryStatus.Stage.fromValue(in.readByte()), - in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong(), in.readVLong()); - } - - if (in.readBoolean()) { - gatewaySnapshotStatus = new GatewaySnapshotStatus(GatewaySnapshotStatus.Stage.fromValue(in.readByte()), - in.readVLong(), in.readVLong(), in.readVLong(), in.readVInt()); - } - - if (in.readBoolean()) { - mergeStats = MergeStats.readMergeStats(in); - } - if (in.readBoolean()) { - refreshStats = RefreshStats.readRefreshStats(in); - } - if (in.readBoolean()) { - flushStats = FlushStats.readFlushStats(in); - } - } -} diff --git a/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java b/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java deleted file mode 100644 index cba944e5704..00000000000 --- a/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.action.admin.indices.status; - -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.ShardOperationFailedException; -import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException; -import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; -import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction; -import org.elasticsearch.cluster.ClusterService; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.block.ClusterBlockException; -import org.elasticsearch.cluster.block.ClusterBlockLevel; -import org.elasticsearch.cluster.routing.GroupShardsIterator; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.gateway.IndexShardGatewayService; -import org.elasticsearch.indices.recovery.RecoveryState; -import org.elasticsearch.index.service.InternalIndexService; -import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.service.InternalIndexShard; -import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.indices.recovery.RecoveryStatus; -import org.elasticsearch.indices.recovery.RecoveryTarget; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TransportService; - -import java.io.IOException; -import java.util.List; -import java.util.concurrent.atomic.AtomicReferenceArray; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * - */ -public class TransportIndicesStatusAction extends TransportBroadcastOperationAction { - - private final IndicesService indicesService; - - private final RecoveryTarget peerRecoveryTarget; - - @Inject - public TransportIndicesStatusAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService, RecoveryTarget peerRecoveryTarget) { - super(settings, threadPool, clusterService, transportService); - this.peerRecoveryTarget = peerRecoveryTarget; - this.indicesService = indicesService; - } - - @Override - protected String executor() { - return ThreadPool.Names.MANAGEMENT; - } - - @Override - protected String transportAction() { - return IndicesStatusAction.NAME; - } - - @Override - protected IndicesStatusRequest newRequest() { - return new IndicesStatusRequest(); - } - - /** - * Status goes across *all* shards. - */ - @Override - protected GroupShardsIterator shards(ClusterState state, IndicesStatusRequest request, String[] concreteIndices) { - return state.routingTable().allAssignedShardsGrouped(concreteIndices, true); - } - - @Override - protected ClusterBlockException checkGlobalBlock(ClusterState state, IndicesStatusRequest request) { - return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA); - } - - @Override - protected ClusterBlockException checkRequestBlock(ClusterState state, IndicesStatusRequest countRequest, String[] concreteIndices) { - return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, concreteIndices); - } - - @Override - protected IndicesStatusResponse newResponse(IndicesStatusRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) { - int successfulShards = 0; - int failedShards = 0; - List shardFailures = null; - final List shards = newArrayList(); - for (int i = 0; i < shardsResponses.length(); i++) { - Object shardResponse = shardsResponses.get(i); - if (shardResponse == null) { - // simply ignore non active shards - } else if (shardResponse instanceof BroadcastShardOperationFailedException) { - failedShards++; - if (shardFailures == null) { - shardFailures = newArrayList(); - } - shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse)); - } else { - shards.add((ShardStatus) shardResponse); - successfulShards++; - } - } - return new IndicesStatusResponse(shards.toArray(new ShardStatus[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures); - } - - @Override - protected IndexShardStatusRequest newShardRequest() { - return new IndexShardStatusRequest(); - } - - @Override - protected IndexShardStatusRequest newShardRequest(ShardRouting shard, IndicesStatusRequest request) { - return new IndexShardStatusRequest(shard.index(), shard.id(), request); - } - - @Override - protected ShardStatus newShardResponse() { - return new ShardStatus(); - } - - @Override - protected ShardStatus shardOperation(IndexShardStatusRequest request) throws ElasticsearchException { - InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index()); - InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId()); - ShardStatus shardStatus = new ShardStatus(indexShard.routingEntry()); - shardStatus.state = indexShard.state(); - try { - shardStatus.storeSize = indexShard.store().estimateSize(); - } catch (IOException e) { - // failure to get the store size... - } - if (indexShard.state() == IndexShardState.STARTED) { -// shardStatus.estimatedFlushableMemorySize = indexShard.estimateFlushableMemorySize(); - shardStatus.translogId = indexShard.translog().currentId(); - shardStatus.translogOperations = indexShard.translog().estimatedNumberOfOperations(); - Engine.Searcher searcher = indexShard.acquireSearcher("indices_status"); - try { - shardStatus.docs = new DocsStatus(); - shardStatus.docs.numDocs = searcher.reader().numDocs(); - shardStatus.docs.maxDoc = searcher.reader().maxDoc(); - shardStatus.docs.deletedDocs = searcher.reader().numDeletedDocs(); - } finally { - searcher.close(); - } - - shardStatus.mergeStats = indexShard.mergeScheduler().stats(); - shardStatus.refreshStats = indexShard.refreshStats(); - shardStatus.flushStats = indexShard.flushStats(); - } - - if (request.recovery) { - // check on going recovery (from peer or gateway) - RecoveryStatus peerRecoveryStatus = indexShard.recoveryStatus(); - if (peerRecoveryStatus == null) { - peerRecoveryStatus = peerRecoveryTarget.recoveryStatus(indexShard.shardId()); - } - if (peerRecoveryStatus != null) { - PeerRecoveryStatus.Stage stage; - switch (peerRecoveryStatus.stage()) { - case INIT: - stage = PeerRecoveryStatus.Stage.INIT; - break; - case INDEX: - stage = PeerRecoveryStatus.Stage.INDEX; - break; - case TRANSLOG: - stage = PeerRecoveryStatus.Stage.TRANSLOG; - break; - case FINALIZE: - stage = PeerRecoveryStatus.Stage.FINALIZE; - break; - case DONE: - stage = PeerRecoveryStatus.Stage.DONE; - break; - default: - stage = PeerRecoveryStatus.Stage.INIT; - } - shardStatus.peerRecoveryStatus = new PeerRecoveryStatus(stage, peerRecoveryStatus.recoveryState().getTimer().startTime(), - peerRecoveryStatus.recoveryState().getTimer().time(), - peerRecoveryStatus.recoveryState().getIndex().totalByteCount(), - peerRecoveryStatus.recoveryState().getIndex().reusedByteCount(), - peerRecoveryStatus.recoveryState().getIndex().recoveredByteCount(), peerRecoveryStatus.recoveryState().getTranslog().currentTranslogOperations()); - } - - IndexShardGatewayService gatewayService = indexService.shardInjector(request.shardId()).getInstance(IndexShardGatewayService.class); - RecoveryState gatewayRecoveryState = gatewayService.recoveryState(); - if (gatewayRecoveryState != null) { - GatewayRecoveryStatus.Stage stage; - switch (gatewayRecoveryState.getStage()) { - case INIT: - stage = GatewayRecoveryStatus.Stage.INIT; - break; - case INDEX: - stage = GatewayRecoveryStatus.Stage.INDEX; - break; - case TRANSLOG: - stage = GatewayRecoveryStatus.Stage.TRANSLOG; - break; - case DONE: - stage = GatewayRecoveryStatus.Stage.DONE; - break; - default: - stage = GatewayRecoveryStatus.Stage.INIT; - } - shardStatus.gatewayRecoveryStatus = new GatewayRecoveryStatus(stage, gatewayRecoveryState.getTimer().startTime(), gatewayRecoveryState.getTimer().time(), - gatewayRecoveryState.getIndex().totalByteCount(), gatewayRecoveryState.getIndex().reusedByteCount(), gatewayRecoveryState.getIndex().recoveredByteCount(), gatewayRecoveryState.getTranslog().currentTranslogOperations()); - } - } - return shardStatus; - } - - public static class IndexShardStatusRequest extends BroadcastShardOperationRequest { - - boolean recovery; - - boolean snapshot; - - IndexShardStatusRequest() { - } - - IndexShardStatusRequest(String index, int shardId, IndicesStatusRequest request) { - super(index, shardId, request); - recovery = request.recovery(); - snapshot = request.snapshot(); - } - - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - recovery = in.readBoolean(); - snapshot = in.readBoolean(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeBoolean(recovery); - out.writeBoolean(snapshot); - } - } -} diff --git a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java index a13abe5e756..5066f513535 100644 --- a/src/main/java/org/elasticsearch/client/IndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/IndicesAdminClient.java @@ -81,9 +81,6 @@ import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRespons import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; import org.elasticsearch.action.admin.indices.recovery.RecoveryRequest; import org.elasticsearch.action.admin.indices.recovery.RecoveryRequestBuilder; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; @@ -199,29 +196,6 @@ public interface IndicesAdminClient { */ RecoveryRequestBuilder prepareRecoveries(String... indices); - /** - * The status of one or more indices. - * - * @param request The indices status request - * @return The result future - * @see Requests#indicesStatusRequest(String...) - */ - ActionFuture status(IndicesStatusRequest request); - - /** - * The status of one or more indices. - * - * @param request The indices status request - * @param listener A listener to be notified with a result - * @see Requests#indicesStatusRequest(String...) - */ - void status(IndicesStatusRequest request, ActionListener listener); - - /** - * The status of one or more indices. - */ - IndicesStatusRequestBuilder prepareStatus(String... indices); - /** * The segments of one or more indices. * diff --git a/src/main/java/org/elasticsearch/client/Requests.java b/src/main/java/org/elasticsearch/client/Requests.java index 9cf5f46de14..165f5cb6536 100644 --- a/src/main/java/org/elasticsearch/client/Requests.java +++ b/src/main/java/org/elasticsearch/client/Requests.java @@ -51,7 +51,6 @@ import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.count.CountRequest; import org.elasticsearch.action.delete.DeleteRequest; @@ -184,17 +183,6 @@ public class Requests { return new SearchScrollRequest(scrollId); } - /** - * Creates an indices status request. - * - * @param indices The indices to query status about. Use null or _all to execute against all indices - * @return The indices status request - * @see org.elasticsearch.client.IndicesAdminClient#status(org.elasticsearch.action.admin.indices.status.IndicesStatusRequest) - */ - public static IndicesStatusRequest indicesStatusRequest(String... indices) { - return new IndicesStatusRequest(indices); - } - public static IndicesSegmentsRequest indicesSegmentsRequest(String... indices) { return new IndicesSegmentsRequest(indices); } diff --git a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java index 09df0bafa9e..950d665afe1 100644 --- a/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/support/AbstractIndicesAdminClient.java @@ -105,10 +105,6 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.action.admin.indices.status.IndicesStatusAction; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequestBuilder; @@ -420,21 +416,6 @@ public abstract class AbstractIndicesAdminClient implements InternalIndicesAdmin return new IndicesStatsRequestBuilder(this).setIndices(indices); } - @Override - public ActionFuture status(final IndicesStatusRequest request) { - return execute(IndicesStatusAction.INSTANCE, request); - } - - @Override - public void status(final IndicesStatusRequest request, final ActionListener listener) { - execute(IndicesStatusAction.INSTANCE, request, listener); - } - - @Override - public IndicesStatusRequestBuilder prepareStatus(String... indices) { - return new IndicesStatusRequestBuilder(this).setIndices(indices); - } - @Override public ActionFuture recoveries(final RecoveryRequest request) { return execute(RecoveryAction.INSTANCE, request); diff --git a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java index 27c6fc55e7f..c199a279a45 100644 --- a/src/main/java/org/elasticsearch/rest/action/RestActionModule.java +++ b/src/main/java/org/elasticsearch/rest/action/RestActionModule.java @@ -69,7 +69,6 @@ import org.elasticsearch.rest.action.admin.indices.segments.RestIndicesSegmentsA import org.elasticsearch.rest.action.admin.indices.settings.RestGetSettingsAction; import org.elasticsearch.rest.action.admin.indices.settings.RestUpdateSettingsAction; import org.elasticsearch.rest.action.admin.indices.stats.RestIndicesStatsAction; -import org.elasticsearch.rest.action.admin.indices.status.RestIndicesStatusAction; import org.elasticsearch.rest.action.admin.indices.template.delete.RestDeleteIndexTemplateAction; import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction; import org.elasticsearch.rest.action.admin.indices.template.head.RestHeadIndexTemplateAction; @@ -148,7 +147,6 @@ public class RestActionModule extends AbstractModule { bind(RestIndicesExistsAction.class).asEagerSingleton(); bind(RestTypesExistsAction.class).asEagerSingleton(); bind(RestIndicesStatsAction.class).asEagerSingleton(); - bind(RestIndicesStatusAction.class).asEagerSingleton(); bind(RestIndicesSegmentsAction.class).asEagerSingleton(); bind(RestGetAliasesAction.class).asEagerSingleton(); bind(RestAliasesExistAction.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java deleted file mode 100644 index b0044cfd7f8..00000000000 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch 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. - */ - -package org.elasticsearch.rest.action.admin.indices.status; - -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsFilter; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.rest.*; -import org.elasticsearch.rest.action.support.RestBuilderListener; - -import java.io.IOException; - -import static org.elasticsearch.rest.RestRequest.Method.GET; -import static org.elasticsearch.rest.RestStatus.OK; -import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; - -/** - * - */ -public class RestIndicesStatusAction extends BaseRestHandler { - - private final SettingsFilter settingsFilter; - - @Inject - public RestIndicesStatusAction(Settings settings, Client client, RestController controller, - SettingsFilter settingsFilter) { - super(settings, client); - controller.registerHandler(GET, "/_status", this); - controller.registerHandler(GET, "/{index}/_status", this); - - this.settingsFilter = settingsFilter; - } - - @Override - public void handleRequest(final RestRequest request, final RestChannel channel) { - IndicesStatusRequest indicesStatusRequest = new IndicesStatusRequest(Strings.splitStringByCommaToArray(request.param("index"))); - indicesStatusRequest.listenerThreaded(false); - indicesStatusRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesStatusRequest.indicesOptions())); - indicesStatusRequest.recovery(request.paramAsBoolean("recovery", indicesStatusRequest.recovery())); - indicesStatusRequest.snapshot(request.paramAsBoolean("snapshot", indicesStatusRequest.snapshot())); - client.admin().indices().status(indicesStatusRequest, new RestBuilderListener(channel) { - @Override - public RestResponse buildResponse(IndicesStatusResponse response, XContentBuilder builder) throws Exception { - builder.startObject(); - buildBroadcastShardsHeader(builder, response); - response.toXContent(builder, request, settingsFilter); - builder.endObject(); - return new BytesRestResponse(OK, builder); - } - }); - } -} diff --git a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java index 4b1fd5a735b..8ae7a4abc94 100644 --- a/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java @@ -20,9 +20,8 @@ package org.elasticsearch.gateway.local; import org.apache.lucene.util.LuceneTestCase.Slow; -import org.elasticsearch.action.admin.indices.status.IndexShardStatus; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; -import org.elasticsearch.action.admin.indices.status.ShardStatus; +import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; +import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; @@ -32,6 +31,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; import org.elasticsearch.test.TestCluster.RestartCallback; @@ -375,17 +375,17 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes logger.info("Running Cluster Health"); ensureGreen(); - IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus("test").setRecovery(true).execute().actionGet(); - for (IndexShardStatus indexShardStatus : statusResponse.getIndex("test")) { - for (ShardStatus shardStatus : indexShardStatus) { - if (!shardStatus.getShardRouting().primary()) { - logger.info("--> shard {}, recovered {}, reuse {}", shardStatus.getShardId(), shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize(), shardStatus.getPeerRecoveryStatus().getReusedIndexSize()); - assertThat(shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize().bytes(), greaterThan(0l)); - assertThat(shardStatus.getPeerRecoveryStatus().getReusedIndexSize().bytes(), greaterThan(0l)); - assertThat(shardStatus.getPeerRecoveryStatus().getReusedIndexSize().bytes(), greaterThan(shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize().bytes())); - } + RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").get(); + for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) { + RecoveryState recoveryState = response.recoveryState(); + if (!recoveryState.getPrimary()) { + logger.info("--> shard {}, recovered {}, reuse {}", response.getShardId(), recoveryState.getIndex().recoveredTotalSize(), recoveryState.getIndex().reusedByteCount()); + assertThat(recoveryState.getIndex().recoveredByteCount(), greaterThan(0l)); + assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(0l)); + assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(recoveryState.getIndex().numberOfRecoveredBytes())); } } + } @Test diff --git a/src/test/java/org/elasticsearch/indices/IndicesOptionsTests.java b/src/test/java/org/elasticsearch/indices/IndicesOptionsTests.java index 96057016df6..a4ce9bd8e32 100644 --- a/src/test/java/org/elasticsearch/indices/IndicesOptionsTests.java +++ b/src/test/java/org/elasticsearch/indices/IndicesOptionsTests.java @@ -36,7 +36,6 @@ import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequestBui import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequestBuilder; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder; -import org.elasticsearch.action.admin.indices.status.IndicesStatusRequestBuilder; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequestBuilder; import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersRequestBuilder; import org.elasticsearch.action.count.CountRequestBuilder; @@ -82,7 +81,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush("test1", "test2"),true); verify(segments("test1", "test2"), true); verify(stats("test1", "test2"), true); - verify(status("test1", "test2"), true); verify(optimize("test1", "test2"), true); verify(refresh("test1", "test2"), true); verify(validateQuery("test1", "test2"), true); @@ -106,7 +104,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush("test1", "test2").setIndicesOptions(options),true); verify(segments("test1", "test2").setIndicesOptions(options), true); verify(stats("test1", "test2").setIndicesOptions(options), true); - verify(status("test1", "test2").setIndicesOptions(options), true); verify(optimize("test1", "test2").setIndicesOptions(options), true); verify(refresh("test1", "test2").setIndicesOptions(options), true); verify(validateQuery("test1", "test2").setIndicesOptions(options), true); @@ -130,7 +127,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush("test1", "test2").setIndicesOptions(options), false); verify(segments("test1", "test2").setIndicesOptions(options), false); verify(stats("test1", "test2").setIndicesOptions(options), false); - verify(status("test1", "test2").setIndicesOptions(options), false); verify(optimize("test1", "test2").setIndicesOptions(options), false); verify(refresh("test1", "test2").setIndicesOptions(options), false); verify(validateQuery("test1", "test2").setIndicesOptions(options), false); @@ -156,7 +152,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush("test1", "test2").setIndicesOptions(options),false); verify(segments("test1", "test2").setIndicesOptions(options), false); verify(stats("test1", "test2").setIndicesOptions(options), false); - verify(status("test1", "test2").setIndicesOptions(options), false); verify(optimize("test1", "test2").setIndicesOptions(options), false); verify(refresh("test1", "test2").setIndicesOptions(options), false); verify(validateQuery("test1", "test2").setIndicesOptions(options), false); @@ -214,7 +209,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush(indices),false); verify(segments(indices), true); verify(stats(indices), false); - verify(status(indices), false); verify(optimize(indices), false); verify(refresh(indices), false); verify(validateQuery(indices), true); @@ -239,7 +233,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush(indices).setIndicesOptions(options),false); verify(segments(indices).setIndicesOptions(options), false); verify(stats(indices).setIndicesOptions(options), false); - verify(status(indices).setIndicesOptions(options), false); verify(optimize(indices).setIndicesOptions(options), false); verify(refresh(indices).setIndicesOptions(options), false); verify(validateQuery(indices).setIndicesOptions(options), false); @@ -267,7 +260,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush(indices),false); verify(segments(indices), false); verify(stats(indices), false); - verify(status(indices), false); verify(optimize(indices), false); verify(refresh(indices), false); verify(validateQuery(indices), false); @@ -292,7 +284,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush(indices),false); verify(segments(indices), true); verify(stats(indices), false); - verify(status(indices), false); verify(optimize(indices), false); verify(refresh(indices), false); verify(validateQuery(indices), true); @@ -317,7 +308,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { verify(_flush(indices).setIndicesOptions(options),false); verify(segments(indices).setIndicesOptions(options), false); verify(stats(indices).setIndicesOptions(options), false); - verify(status(indices).setIndicesOptions(options), false); verify(optimize(indices).setIndicesOptions(options), false); verify(refresh(indices).setIndicesOptions(options), false); verify(validateQuery(indices).setIndicesOptions(options), false); @@ -772,10 +762,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest { return client().admin().indices().prepareStats(indices); } - private static IndicesStatusRequestBuilder status(String... indices) { - return client().admin().indices().prepareStatus(indices); - } - private static OptimizeRequestBuilder optimize(String... indices) { return client().admin().indices().prepareOptimize(indices); } diff --git a/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java b/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java index afc14dbc01a..4d21de438df 100644 --- a/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java +++ b/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java @@ -25,7 +25,6 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.open.OpenIndexResponse; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.routing.ShardRoutingState; @@ -75,10 +74,6 @@ public class SimpleIndexStateTests extends ElasticsearchIntegrationTest { assertThat(stateResponse.getState().metaData().index("test").state(), equalTo(IndexMetaData.State.CLOSE)); assertThat(stateResponse.getState().routingTable().index("test"), nullValue()); - logger.info("--> testing indices status api..."); - IndicesStatusResponse indicesStatusResponse = client().admin().indices().prepareStatus().get(); - assertThat(indicesStatusResponse.getIndices().size(), equalTo(0)); - logger.info("--> trying to index into a closed index ..."); try { client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get(); diff --git a/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java b/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java index d7974656044..d30a2c93819 100644 --- a/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java +++ b/src/test/java/org/elasticsearch/nested/SimpleNestedTests.java @@ -21,7 +21,9 @@ package org.elasticsearch.nested; import org.apache.lucene.search.Explanation; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; +import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; +import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; +import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -98,9 +100,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { assertThat(getResponse.getSourceAsBytes(), notNullValue()); // check the numDocs - IndicesStatusResponse statusResponse = admin().indices().prepareStatus().get(); - assertNoFailures(statusResponse); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l)); + assertDocumentCount("test", 3); // check that _all is working on nested docs searchResponse = client().prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet(); @@ -141,8 +141,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { waitForRelocation(ClusterHealthStatus.GREEN); // flush, so we fetch it from the index (as see that we filter nested docs) flush(); - statusResponse = client().admin().indices().prepareStatus().get(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(6l)); + assertDocumentCount("test", 6); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet(); @@ -167,8 +166,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { // flush, so we fetch it from the index (as see that we filter nested docs) flush(); - statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l)); + assertDocumentCount("test", 3); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet(); assertNoFailures(searchResponse); @@ -220,14 +218,12 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { flush(); - IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(total * 3l)); + assertDocumentCount("test", total * 3); client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet(); flush(); refresh(); - statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo((total * 3l) - 3)); + assertDocumentCount("test", (total * 3l) - 3); for (int i = 0; i < total; i++) { assertThat(client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().isExists(), equalTo(i != docToDelete)); @@ -272,14 +268,12 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { flush(); refresh(); - IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(total)); + assertDocumentCount("test", total); client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet(); flush(); refresh(); - statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo((total) - 1)); + assertDocumentCount("test", total-1); for (int i = 0; i < total; i++) { assertThat(client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().isExists(), equalTo(i != docToDelete)); @@ -312,8 +306,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { assertThat(getResponse.isExists(), equalTo(true)); waitForRelocation(ClusterHealthStatus.GREEN); // check the numDocs - IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(7l)); + assertDocumentCount("test", 7); // do some multi nested queries SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", @@ -542,17 +535,15 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { flush(); refresh(); - IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(6l)); + assertDocumentCount("test", 6); client().prepareDeleteByQuery("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); flush(); refresh(); - statusResponse = client().admin().indices().prepareStatus().execute().actionGet(); // This must be 3, otherwise child docs aren't deleted. // If this is 5 then only the parent has been removed - assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l)); + assertDocumentCount("test", 3); assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); } @@ -1217,4 +1208,14 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest { assertThat(searchResponse.getHits().getHits()[2].sortValues()[0].toString(), equalTo("3")); } + /** + */ + private void assertDocumentCount(String index, long numdocs) { + IndicesStatsResponse stats = admin().indices().prepareStats(index).clear().setDocs(true).get(); + assertNoFailures(stats); + assertThat(stats.getIndex(index).getPrimaries().docs.getCount(), is(numdocs)); + + } + + } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/stresstest/rollingrestart/RollingRestartStressTest.java b/src/test/java/org/elasticsearch/stresstest/rollingrestart/RollingRestartStressTest.java index 3f24756f7f2..87bfb31cdfa 100644 --- a/src/test/java/org/elasticsearch/stresstest/rollingrestart/RollingRestartStressTest.java +++ b/src/test/java/org/elasticsearch/stresstest/rollingrestart/RollingRestartStressTest.java @@ -20,9 +20,6 @@ package org.elasticsearch.stresstest.rollingrestart; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.indices.status.IndexShardStatus; -import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse; -import org.elasticsearch.action.admin.indices.status.ShardStatus; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchResponse; @@ -230,18 +227,6 @@ public class RollingRestartStressTest { client.client().admin().indices().prepareRefresh().execute().actionGet(); - // check the status - IndicesStatusResponse status = client.client().admin().indices().prepareStatus("test").execute().actionGet(); - for (IndexShardStatus shardStatus : status.getIndex("test")) { - ShardStatus shard = shardStatus.getShards()[0]; - logger.info("shard [{}], docs [{}]", shard.getShardId(), shard.getDocs().getNumDocs()); - for (ShardStatus shardStatu : shardStatus) { - if (shard.getDocs().getNumDocs() != shardStatu.getDocs().getNumDocs()) { - logger.warn("shard doc number does not match!, got {} and {}", shard.getDocs().getNumDocs(), shardStatu.getDocs().getNumDocs()); - } - } - } - // check the count for (int i = 0; i < (nodes.length * 5); i++) { CountResponse count = client.client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();