mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
Removed Index Status API
The functionality of the index status API has been replaced by the recovery API. Relates #4854
This commit is contained in:
parent
fdb5eb6555
commit
0c0f717aba
@ -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.settings.put.UpdateSettingsAction;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction;
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction;
|
||||||
import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction;
|
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.DeleteIndexTemplateAction;
|
||||||
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateAction;
|
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateAction;
|
||||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction;
|
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction;
|
||||||
@ -220,7 +218,6 @@ public class ActionModule extends AbstractModule {
|
|||||||
registerAction(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class);
|
registerAction(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class);
|
||||||
|
|
||||||
registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
|
registerAction(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
|
||||||
registerAction(IndicesStatusAction.INSTANCE, TransportIndicesStatusAction.class);
|
|
||||||
registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class);
|
registerAction(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class);
|
||||||
registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
|
registerAction(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
|
||||||
registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
|
registerAction(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<ShardStatus> {
|
|
||||||
|
|
||||||
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<ShardStatus> iterator() {
|
|
||||||
return Iterators.forArray(shards);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<IndexShardStatus> {
|
|
||||||
|
|
||||||
private final String index;
|
|
||||||
|
|
||||||
private final Map<Integer, IndexShardStatus> indexShards;
|
|
||||||
|
|
||||||
IndexStatus(String index, ShardStatus[] shards) {
|
|
||||||
this.index = index;
|
|
||||||
|
|
||||||
Map<Integer, List<ShardStatus>> tmpIndexShards = Maps.newHashMap();
|
|
||||||
for (ShardStatus shard : shards) {
|
|
||||||
List<ShardStatus> 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<Integer, List<ShardStatus>> 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<Integer, IndexShardStatus> 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<IndexShardStatus> iterator() {
|
|
||||||
return indexShards.values().iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<IndicesStatusRequest, IndicesStatusResponse, IndicesStatusRequestBuilder> {
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<IndicesStatusRequest> {
|
|
||||||
|
|
||||||
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 <tt>false</tt>.
|
|
||||||
*/
|
|
||||||
public IndicesStatusRequest recovery(boolean recovery) {
|
|
||||||
this.recovery = recovery;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean recovery() {
|
|
||||||
return this.recovery;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should the status include recovery information. Defaults to <tt>false</tt>.
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<IndicesStatusRequest, IndicesStatusResponse, IndicesStatusRequestBuilder> {
|
|
||||||
|
|
||||||
public IndicesStatusRequestBuilder(IndicesAdminClient indicesClient) {
|
|
||||||
super((InternalIndicesAdminClient) indicesClient, new IndicesStatusRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should the status include recovery information. Defaults to <tt>false</tt>.
|
|
||||||
*/
|
|
||||||
public IndicesStatusRequestBuilder setRecovery(boolean recovery) {
|
|
||||||
request.recovery(recovery);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should the status include recovery information. Defaults to <tt>false</tt>.
|
|
||||||
*/
|
|
||||||
public IndicesStatusRequestBuilder setSnapshot(boolean snapshot) {
|
|
||||||
request.snapshot(snapshot);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doExecute(ActionListener<IndicesStatusResponse> listener) {
|
|
||||||
((IndicesAdminClient) client).status(request, listener);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String, IndexStatus> indicesStatus;
|
|
||||||
|
|
||||||
IndicesStatusResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
IndicesStatusResponse(ShardStatus[] shards, ClusterState clusterState, int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> 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<String, IndexStatus> getIndices() {
|
|
||||||
if (indicesStatus != null) {
|
|
||||||
return indicesStatus;
|
|
||||||
}
|
|
||||||
Map<String, IndexStatus> indicesStatus = newHashMap();
|
|
||||||
|
|
||||||
Set<String> indices = Sets.newHashSet();
|
|
||||||
for (ShardStatus shard : shards) {
|
|
||||||
indices.add(shard.getIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String index : indices) {
|
|
||||||
List<ShardStatus> 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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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, <tt>null</tt> 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 (<tt>null</tt> 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 (<tt>null</tt> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<IndicesStatusRequest, IndicesStatusResponse, TransportIndicesStatusAction.IndexShardStatusRequest, ShardStatus> {
|
|
||||||
|
|
||||||
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<ShardOperationFailedException> shardFailures = null;
|
|
||||||
final List<ShardStatus> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.IndicesStatsRequest;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
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.RecoveryRequest;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryRequestBuilder;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryRequestBuilder;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
@ -199,29 +196,6 @@ public interface IndicesAdminClient {
|
|||||||
*/
|
*/
|
||||||
RecoveryRequestBuilder prepareRecoveries(String... indices);
|
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<IndicesStatusResponse> 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<IndicesStatusResponse> listener);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The status of one or more indices.
|
|
||||||
*/
|
|
||||||
IndicesStatusRequestBuilder prepareStatus(String... indices);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The segments of one or more indices.
|
* The segments of one or more indices.
|
||||||
*
|
*
|
||||||
|
@ -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.refresh.RefreshRequest;
|
||||||
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest;
|
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest;
|
||||||
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
|
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.bulk.BulkRequest;
|
||||||
import org.elasticsearch.action.count.CountRequest;
|
import org.elasticsearch.action.count.CountRequest;
|
||||||
import org.elasticsearch.action.delete.DeleteRequest;
|
import org.elasticsearch.action.delete.DeleteRequest;
|
||||||
@ -184,17 +183,6 @@ public class Requests {
|
|||||||
return new SearchScrollRequest(scrollId);
|
return new SearchScrollRequest(scrollId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an indices status request.
|
|
||||||
*
|
|
||||||
* @param indices The indices to query status about. Use <tt>null</tt> or <tt>_all</tt> 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) {
|
public static IndicesSegmentsRequest indicesSegmentsRequest(String... indices) {
|
||||||
return new IndicesSegmentsRequest(indices);
|
return new IndicesSegmentsRequest(indices);
|
||||||
}
|
}
|
||||||
|
@ -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.IndicesStatsRequest;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
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.DeleteIndexTemplateAction;
|
||||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
|
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
|
||||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequestBuilder;
|
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);
|
return new IndicesStatsRequestBuilder(this).setIndices(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionFuture<IndicesStatusResponse> status(final IndicesStatusRequest request) {
|
|
||||||
return execute(IndicesStatusAction.INSTANCE, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void status(final IndicesStatusRequest request, final ActionListener<IndicesStatusResponse> listener) {
|
|
||||||
execute(IndicesStatusAction.INSTANCE, request, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IndicesStatusRequestBuilder prepareStatus(String... indices) {
|
|
||||||
return new IndicesStatusRequestBuilder(this).setIndices(indices);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionFuture<RecoveryResponse> recoveries(final RecoveryRequest request) {
|
public ActionFuture<RecoveryResponse> recoveries(final RecoveryRequest request) {
|
||||||
return execute(RecoveryAction.INSTANCE, request);
|
return execute(RecoveryAction.INSTANCE, request);
|
||||||
|
@ -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.RestGetSettingsAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.settings.RestUpdateSettingsAction;
|
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.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.delete.RestDeleteIndexTemplateAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction;
|
import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.template.head.RestHeadIndexTemplateAction;
|
import org.elasticsearch.rest.action.admin.indices.template.head.RestHeadIndexTemplateAction;
|
||||||
@ -148,7 +147,6 @@ public class RestActionModule extends AbstractModule {
|
|||||||
bind(RestIndicesExistsAction.class).asEagerSingleton();
|
bind(RestIndicesExistsAction.class).asEagerSingleton();
|
||||||
bind(RestTypesExistsAction.class).asEagerSingleton();
|
bind(RestTypesExistsAction.class).asEagerSingleton();
|
||||||
bind(RestIndicesStatsAction.class).asEagerSingleton();
|
bind(RestIndicesStatsAction.class).asEagerSingleton();
|
||||||
bind(RestIndicesStatusAction.class).asEagerSingleton();
|
|
||||||
bind(RestIndicesSegmentsAction.class).asEagerSingleton();
|
bind(RestIndicesSegmentsAction.class).asEagerSingleton();
|
||||||
bind(RestGetAliasesAction.class).asEagerSingleton();
|
bind(RestGetAliasesAction.class).asEagerSingleton();
|
||||||
bind(RestAliasesExistAction.class).asEagerSingleton();
|
bind(RestAliasesExistAction.class).asEagerSingleton();
|
||||||
|
@ -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<IndicesStatusResponse>(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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,9 +20,8 @@
|
|||||||
package org.elasticsearch.gateway.local;
|
package org.elasticsearch.gateway.local;
|
||||||
|
|
||||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||||
import org.elasticsearch.action.admin.indices.status.IndexShardStatus;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;
|
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
|
||||||
import org.elasticsearch.action.admin.indices.status.ShardStatus;
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
|
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.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.query.FilterBuilders;
|
import org.elasticsearch.index.query.FilterBuilders;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||||
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
||||||
import org.elasticsearch.test.TestCluster.RestartCallback;
|
import org.elasticsearch.test.TestCluster.RestartCallback;
|
||||||
@ -375,17 +375,17 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
|
|||||||
logger.info("Running Cluster Health");
|
logger.info("Running Cluster Health");
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus("test").setRecovery(true).execute().actionGet();
|
RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").get();
|
||||||
for (IndexShardStatus indexShardStatus : statusResponse.getIndex("test")) {
|
for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
|
||||||
for (ShardStatus shardStatus : indexShardStatus) {
|
RecoveryState recoveryState = response.recoveryState();
|
||||||
if (!shardStatus.getShardRouting().primary()) {
|
if (!recoveryState.getPrimary()) {
|
||||||
logger.info("--> shard {}, recovered {}, reuse {}", shardStatus.getShardId(), shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize(), shardStatus.getPeerRecoveryStatus().getReusedIndexSize());
|
logger.info("--> shard {}, recovered {}, reuse {}", response.getShardId(), recoveryState.getIndex().recoveredTotalSize(), recoveryState.getIndex().reusedByteCount());
|
||||||
assertThat(shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize().bytes(), greaterThan(0l));
|
assertThat(recoveryState.getIndex().recoveredByteCount(), greaterThan(0l));
|
||||||
assertThat(shardStatus.getPeerRecoveryStatus().getReusedIndexSize().bytes(), greaterThan(0l));
|
assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(0l));
|
||||||
assertThat(shardStatus.getPeerRecoveryStatus().getReusedIndexSize().bytes(), greaterThan(shardStatus.getPeerRecoveryStatus().getRecoveredIndexSize().bytes()));
|
assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(recoveryState.getIndex().numberOfRecoveredBytes()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -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.GetSettingsRequestBuilder;
|
||||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequestBuilder;
|
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.validate.query.ValidateQueryRequestBuilder;
|
||||||
import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersRequestBuilder;
|
import org.elasticsearch.action.admin.indices.warmer.get.GetWarmersRequestBuilder;
|
||||||
import org.elasticsearch.action.count.CountRequestBuilder;
|
import org.elasticsearch.action.count.CountRequestBuilder;
|
||||||
@ -82,7 +81,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
|||||||
verify(_flush("test1", "test2"),true);
|
verify(_flush("test1", "test2"),true);
|
||||||
verify(segments("test1", "test2"), true);
|
verify(segments("test1", "test2"), true);
|
||||||
verify(stats("test1", "test2"), true);
|
verify(stats("test1", "test2"), true);
|
||||||
verify(status("test1", "test2"), true);
|
|
||||||
verify(optimize("test1", "test2"), true);
|
verify(optimize("test1", "test2"), true);
|
||||||
verify(refresh("test1", "test2"), true);
|
verify(refresh("test1", "test2"), true);
|
||||||
verify(validateQuery("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(_flush("test1", "test2").setIndicesOptions(options),true);
|
||||||
verify(segments("test1", "test2").setIndicesOptions(options), true);
|
verify(segments("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(stats("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(optimize("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(refresh("test1", "test2").setIndicesOptions(options), true);
|
verify(refresh("test1", "test2").setIndicesOptions(options), true);
|
||||||
verify(validateQuery("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(_flush("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(segments("test1", "test2").setIndicesOptions(options), false);
|
verify(segments("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(stats("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(optimize("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(refresh("test1", "test2").setIndicesOptions(options), false);
|
verify(refresh("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(validateQuery("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(_flush("test1", "test2").setIndicesOptions(options),false);
|
||||||
verify(segments("test1", "test2").setIndicesOptions(options), false);
|
verify(segments("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(stats("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(optimize("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(refresh("test1", "test2").setIndicesOptions(options), false);
|
verify(refresh("test1", "test2").setIndicesOptions(options), false);
|
||||||
verify(validateQuery("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(_flush(indices),false);
|
||||||
verify(segments(indices), true);
|
verify(segments(indices), true);
|
||||||
verify(stats(indices), false);
|
verify(stats(indices), false);
|
||||||
verify(status(indices), false);
|
|
||||||
verify(optimize(indices), false);
|
verify(optimize(indices), false);
|
||||||
verify(refresh(indices), false);
|
verify(refresh(indices), false);
|
||||||
verify(validateQuery(indices), true);
|
verify(validateQuery(indices), true);
|
||||||
@ -239,7 +233,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
|||||||
verify(_flush(indices).setIndicesOptions(options),false);
|
verify(_flush(indices).setIndicesOptions(options),false);
|
||||||
verify(segments(indices).setIndicesOptions(options), false);
|
verify(segments(indices).setIndicesOptions(options), false);
|
||||||
verify(stats(indices).setIndicesOptions(options), false);
|
verify(stats(indices).setIndicesOptions(options), false);
|
||||||
verify(status(indices).setIndicesOptions(options), false);
|
|
||||||
verify(optimize(indices).setIndicesOptions(options), false);
|
verify(optimize(indices).setIndicesOptions(options), false);
|
||||||
verify(refresh(indices).setIndicesOptions(options), false);
|
verify(refresh(indices).setIndicesOptions(options), false);
|
||||||
verify(validateQuery(indices).setIndicesOptions(options), false);
|
verify(validateQuery(indices).setIndicesOptions(options), false);
|
||||||
@ -267,7 +260,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
|||||||
verify(_flush(indices),false);
|
verify(_flush(indices),false);
|
||||||
verify(segments(indices), false);
|
verify(segments(indices), false);
|
||||||
verify(stats(indices), false);
|
verify(stats(indices), false);
|
||||||
verify(status(indices), false);
|
|
||||||
verify(optimize(indices), false);
|
verify(optimize(indices), false);
|
||||||
verify(refresh(indices), false);
|
verify(refresh(indices), false);
|
||||||
verify(validateQuery(indices), false);
|
verify(validateQuery(indices), false);
|
||||||
@ -292,7 +284,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
|||||||
verify(_flush(indices),false);
|
verify(_flush(indices),false);
|
||||||
verify(segments(indices), true);
|
verify(segments(indices), true);
|
||||||
verify(stats(indices), false);
|
verify(stats(indices), false);
|
||||||
verify(status(indices), false);
|
|
||||||
verify(optimize(indices), false);
|
verify(optimize(indices), false);
|
||||||
verify(refresh(indices), false);
|
verify(refresh(indices), false);
|
||||||
verify(validateQuery(indices), true);
|
verify(validateQuery(indices), true);
|
||||||
@ -317,7 +308,6 @@ public class IndicesOptionsTests extends ElasticsearchIntegrationTest {
|
|||||||
verify(_flush(indices).setIndicesOptions(options),false);
|
verify(_flush(indices).setIndicesOptions(options),false);
|
||||||
verify(segments(indices).setIndicesOptions(options), false);
|
verify(segments(indices).setIndicesOptions(options), false);
|
||||||
verify(stats(indices).setIndicesOptions(options), false);
|
verify(stats(indices).setIndicesOptions(options), false);
|
||||||
verify(status(indices).setIndicesOptions(options), false);
|
|
||||||
verify(optimize(indices).setIndicesOptions(options), false);
|
verify(optimize(indices).setIndicesOptions(options), false);
|
||||||
verify(refresh(indices).setIndicesOptions(options), false);
|
verify(refresh(indices).setIndicesOptions(options), false);
|
||||||
verify(validateQuery(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);
|
return client().admin().indices().prepareStats(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IndicesStatusRequestBuilder status(String... indices) {
|
|
||||||
return client().admin().indices().prepareStatus(indices);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OptimizeRequestBuilder optimize(String... indices) {
|
private static OptimizeRequestBuilder optimize(String... indices) {
|
||||||
return client().admin().indices().prepareOptimize(indices);
|
return client().admin().indices().prepareOptimize(indices);
|
||||||
}
|
}
|
||||||
|
@ -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.close.CloseIndexResponse;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||||
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
|
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.block.ClusterBlockException;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
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().metaData().index("test").state(), equalTo(IndexMetaData.State.CLOSE));
|
||||||
assertThat(stateResponse.getState().routingTable().index("test"), nullValue());
|
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 ...");
|
logger.info("--> trying to index into a closed index ...");
|
||||||
try {
|
try {
|
||||||
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
|
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
|
||||||
|
@ -21,7 +21,9 @@ package org.elasticsearch.nested;
|
|||||||
|
|
||||||
import org.apache.lucene.search.Explanation;
|
import org.apache.lucene.search.Explanation;
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
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.delete.DeleteResponse;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||||
@ -98,9 +100,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
|
|||||||
assertThat(getResponse.getSourceAsBytes(), notNullValue());
|
assertThat(getResponse.getSourceAsBytes(), notNullValue());
|
||||||
|
|
||||||
// check the numDocs
|
// check the numDocs
|
||||||
IndicesStatusResponse statusResponse = admin().indices().prepareStatus().get();
|
assertDocumentCount("test", 3);
|
||||||
assertNoFailures(statusResponse);
|
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l));
|
|
||||||
|
|
||||||
// check that _all is working on nested docs
|
// check that _all is working on nested docs
|
||||||
searchResponse = client().prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
|
searchResponse = client().prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
|
||||||
@ -141,8 +141,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
|
|||||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||||
// flush, so we fetch it from the index (as see that we filter nested docs)
|
// flush, so we fetch it from the index (as see that we filter nested docs)
|
||||||
flush();
|
flush();
|
||||||
statusResponse = client().admin().indices().prepareStatus().get();
|
assertDocumentCount("test", 6);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(6l));
|
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
|
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();
|
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, so we fetch it from the index (as see that we filter nested docs)
|
||||||
flush();
|
flush();
|
||||||
statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", 3);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(3l));
|
|
||||||
|
|
||||||
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet();
|
searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
@ -220,14 +218,12 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
|
|||||||
|
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", total * 3);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(total * 3l));
|
|
||||||
|
|
||||||
client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
|
client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
|
||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", (total * 3l) - 3);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo((total * 3l) - 3));
|
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
for (int i = 0; i < total; i++) {
|
||||||
assertThat(client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().isExists(), equalTo(i != docToDelete));
|
assertThat(client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().isExists(), equalTo(i != docToDelete));
|
||||||
@ -272,14 +268,12 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
|
|||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", total);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(total));
|
|
||||||
|
|
||||||
client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
|
client().prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
|
||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", total-1);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo((total) - 1));
|
|
||||||
|
|
||||||
for (int i = 0; i < total; i++) {
|
for (int i = 0; i < total; i++) {
|
||||||
assertThat(client().prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().isExists(), equalTo(i != docToDelete));
|
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));
|
assertThat(getResponse.isExists(), equalTo(true));
|
||||||
waitForRelocation(ClusterHealthStatus.GREEN);
|
waitForRelocation(ClusterHealthStatus.GREEN);
|
||||||
// check the numDocs
|
// check the numDocs
|
||||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", 7);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(7l));
|
|
||||||
|
|
||||||
// do some multi nested queries
|
// do some multi nested queries
|
||||||
SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
|
SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1",
|
||||||
@ -542,17 +535,15 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
|
|||||||
|
|
||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
IndicesStatusResponse statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
assertDocumentCount("test", 6);
|
||||||
assertThat(statusResponse.getIndex("test").getDocs().getNumDocs(), equalTo(6l));
|
|
||||||
|
|
||||||
client().prepareDeleteByQuery("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
client().prepareDeleteByQuery("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
|
||||||
flush();
|
flush();
|
||||||
refresh();
|
refresh();
|
||||||
statusResponse = client().admin().indices().prepareStatus().execute().actionGet();
|
|
||||||
|
|
||||||
// This must be 3, otherwise child docs aren't deleted.
|
// This must be 3, otherwise child docs aren't deleted.
|
||||||
// If this is 5 then only the parent has been removed
|
// 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));
|
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"));
|
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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -20,9 +20,6 @@
|
|||||||
package org.elasticsearch.stresstest.rollingrestart;
|
package org.elasticsearch.stresstest.rollingrestart;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
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.count.CountResponse;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
@ -230,18 +227,6 @@ public class RollingRestartStressTest {
|
|||||||
|
|
||||||
client.client().admin().indices().prepareRefresh().execute().actionGet();
|
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
|
// check the count
|
||||||
for (int i = 0; i < (nodes.length * 5); i++) {
|
for (int i = 0; i < (nodes.length * 5); i++) {
|
||||||
CountResponse count = client.client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
|
CountResponse count = client.client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user