Update for API changes in 5e2efcfe09
Original commit: elastic/x-pack-elasticsearch@5cf5f71ba6
This commit is contained in:
parent
add8dd4cc4
commit
8cc9531bcb
|
@ -6,10 +6,10 @@
|
||||||
package org.elasticsearch.marvel.agent.renderer.indices;
|
package org.elasticsearch.marvel.agent.renderer.indices;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
|
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||||
import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryMarvelDoc;
|
import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryMarvelDoc;
|
||||||
import org.elasticsearch.marvel.agent.renderer.AbstractRenderer;
|
import org.elasticsearch.marvel.agent.renderer.AbstractRenderer;
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ public class IndexRecoveryRenderer extends AbstractRenderer<IndexRecoveryMarvelD
|
||||||
RecoveryResponse recovery = marvelDoc.getRecoveryResponse();
|
RecoveryResponse recovery = marvelDoc.getRecoveryResponse();
|
||||||
if (recovery != null) {
|
if (recovery != null) {
|
||||||
builder.startArray(Fields.SHARDS);
|
builder.startArray(Fields.SHARDS);
|
||||||
Map<String, List<ShardRecoveryResponse>> shards = recovery.shardResponses();
|
Map<String, List<RecoveryState>> shards = recovery.shardRecoveryStates();
|
||||||
if (shards != null) {
|
if (shards != null) {
|
||||||
for (Map.Entry<String, List<ShardRecoveryResponse>> shard : shards.entrySet()) {
|
for (Map.Entry<String, List<RecoveryState>> shard : shards.entrySet()) {
|
||||||
|
|
||||||
List<ShardRecoveryResponse> indexShards = shard.getValue();
|
List<RecoveryState> indexShards = shard.getValue();
|
||||||
if (indexShards != null) {
|
if (indexShards != null) {
|
||||||
for (ShardRecoveryResponse indexShard : indexShards) {
|
for (RecoveryState indexShard : indexShards) {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Fields.INDEX_NAME, shard.getKey());
|
builder.field(Fields.INDEX_NAME, shard.getKey());
|
||||||
indexShard.toXContent(builder, params);
|
indexShard.toXContent(builder, params);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.marvel.agent.collector.indices;
|
package org.elasticsearch.marvel.agent.collector.indices;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
|
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -102,17 +101,17 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
||||||
RecoveryResponse recovery = indexRecoveryMarvelDoc.getRecoveryResponse();
|
RecoveryResponse recovery = indexRecoveryMarvelDoc.getRecoveryResponse();
|
||||||
assertNotNull(recovery);
|
assertNotNull(recovery);
|
||||||
|
|
||||||
Map<String, List<ShardRecoveryResponse>> shards = recovery.shardResponses();
|
Map<String, List<RecoveryState>> shards = recovery.shardRecoveryStates();
|
||||||
assertThat(shards.size(), greaterThan(0));
|
assertThat(shards.size(), greaterThan(0));
|
||||||
|
|
||||||
for (Map.Entry<String, List<ShardRecoveryResponse>> shard : shards.entrySet()) {
|
for (Map.Entry<String, List<RecoveryState>> shard : shards.entrySet()) {
|
||||||
List<ShardRecoveryResponse> shardRecoveries = shard.getValue();
|
List<RecoveryState> shardRecoveries = shard.getValue();
|
||||||
assertNotNull(shardRecoveries);
|
assertNotNull(shardRecoveries);
|
||||||
assertThat(shardRecoveries.size(), greaterThan(0));
|
assertThat(shardRecoveries.size(), greaterThan(0));
|
||||||
|
|
||||||
for (ShardRecoveryResponse shardRecovery : shardRecoveries) {
|
for (RecoveryState shardRecovery : shardRecoveries) {
|
||||||
assertThat(shardRecovery.getIndex(), equalTo(indexName));
|
assertThat(shard.getKey(), equalTo(indexName));
|
||||||
assertThat(shardRecovery.recoveryState().getType(), anyOf(equalTo(RecoveryState.Type.RELOCATION), equalTo(RecoveryState.Type.STORE), equalTo(RecoveryState.Type.REPLICA)));
|
assertThat(shardRecovery.getType(), anyOf(equalTo(RecoveryState.Type.RELOCATION), equalTo(RecoveryState.Type.STORE), equalTo(RecoveryState.Type.REPLICA)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.renderer.indices;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
|
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.transport.DummyTransportAddress;
|
import org.elasticsearch.common.transport.DummyTransportAddress;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
|
@ -36,19 +35,17 @@ public class IndexRecoveryRendererTests extends ESTestCase {
|
||||||
DiscoveryNode source = new DiscoveryNode("node-src", DummyTransportAddress.INSTANCE, Version.CURRENT);
|
DiscoveryNode source = new DiscoveryNode("node-src", DummyTransportAddress.INSTANCE, Version.CURRENT);
|
||||||
DiscoveryNode target = new DiscoveryNode("node-tgt", DummyTransportAddress.INSTANCE, Version.CURRENT);
|
DiscoveryNode target = new DiscoveryNode("node-tgt", DummyTransportAddress.INSTANCE, Version.CURRENT);
|
||||||
|
|
||||||
List<ShardRecoveryResponse> shards = new ArrayList<>();
|
List<RecoveryState> shards = new ArrayList<>();
|
||||||
|
|
||||||
// Shard 0
|
// Shard 0
|
||||||
ShardRecoveryResponse shard0 = new ShardRecoveryResponse();
|
RecoveryState shard0 = new RecoveryState(new ShardId(indexName, 0), true, RecoveryState.Type.RELOCATION, source, target);
|
||||||
shard0.recoveryState(new RecoveryState(new ShardId(indexName, 0), true, RecoveryState.Type.RELOCATION, source, target));
|
|
||||||
shards.add(shard0);
|
shards.add(shard0);
|
||||||
|
|
||||||
// Shard 1
|
// Shard 1
|
||||||
ShardRecoveryResponse shard1 = new ShardRecoveryResponse();
|
RecoveryState shard1 = new RecoveryState(new ShardId(indexName, 1), true, RecoveryState.Type.STORE, source, target);
|
||||||
shard1.recoveryState(new RecoveryState(new ShardId(indexName, 1), true, RecoveryState.Type.STORE, source, target));
|
|
||||||
shards.add(shard1);
|
shards.add(shard1);
|
||||||
|
|
||||||
Map<String, List<ShardRecoveryResponse>> shardResponses = new HashMap<>(1);
|
Map<String, List<RecoveryState>> shardResponses = new HashMap<>(1);
|
||||||
shardResponses.put(indexName, shards);
|
shardResponses.put(indexName, shards);
|
||||||
|
|
||||||
RecoveryResponse recoveryResponse = new RecoveryResponse(2, 2, 2, false, shardResponses, null);
|
RecoveryResponse recoveryResponse = new RecoveryResponse(2, 2, 2, false, shardResponses, null);
|
||||||
|
|
Loading…
Reference in New Issue