Update for API changes in 5e2efcfe09

Original commit: elastic/x-pack-elasticsearch@5cf5f71ba6
This commit is contained in:
Jason Tedor 2015-08-30 11:54:14 -04:00
parent add8dd4cc4
commit 8cc9531bcb
3 changed files with 15 additions and 19 deletions

View File

@ -6,10 +6,10 @@
package org.elasticsearch.marvel.agent.renderer.indices;
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.XContentBuilder;
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.renderer.AbstractRenderer;
@ -30,13 +30,13 @@ public class IndexRecoveryRenderer extends AbstractRenderer<IndexRecoveryMarvelD
RecoveryResponse recovery = marvelDoc.getRecoveryResponse();
if (recovery != null) {
builder.startArray(Fields.SHARDS);
Map<String, List<ShardRecoveryResponse>> shards = recovery.shardResponses();
Map<String, List<RecoveryState>> shards = recovery.shardRecoveryStates();
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) {
for (ShardRecoveryResponse indexShard : indexShards) {
for (RecoveryState indexShard : indexShards) {
builder.startObject();
builder.field(Fields.INDEX_NAME, shard.getKey());
indexShard.toXContent(builder, params);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.marvel.agent.collector.indices;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
import org.elasticsearch.action.admin.indices.recovery.ShardRecoveryResponse;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
@ -102,17 +101,17 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
RecoveryResponse recovery = indexRecoveryMarvelDoc.getRecoveryResponse();
assertNotNull(recovery);
Map<String, List<ShardRecoveryResponse>> shards = recovery.shardResponses();
Map<String, List<RecoveryState>> shards = recovery.shardRecoveryStates();
assertThat(shards.size(), greaterThan(0));
for (Map.Entry<String, List<ShardRecoveryResponse>> shard : shards.entrySet()) {
List<ShardRecoveryResponse> shardRecoveries = shard.getValue();
for (Map.Entry<String, List<RecoveryState>> shard : shards.entrySet()) {
List<RecoveryState> shardRecoveries = shard.getValue();
assertNotNull(shardRecoveries);
assertThat(shardRecoveries.size(), greaterThan(0));
for (ShardRecoveryResponse shardRecovery : shardRecoveries) {
assertThat(shardRecovery.getIndex(), equalTo(indexName));
assertThat(shardRecovery.recoveryState().getType(), anyOf(equalTo(RecoveryState.Type.RELOCATION), equalTo(RecoveryState.Type.STORE), equalTo(RecoveryState.Type.REPLICA)));
for (RecoveryState shardRecovery : shardRecoveries) {
assertThat(shard.getKey(), equalTo(indexName));
assertThat(shardRecovery.getType(), anyOf(equalTo(RecoveryState.Type.RELOCATION), equalTo(RecoveryState.Type.STORE), equalTo(RecoveryState.Type.REPLICA)));
}
}
}

View File

@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.renderer.indices;
import org.elasticsearch.Version;
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.common.transport.DummyTransportAddress;
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 target = new DiscoveryNode("node-tgt", DummyTransportAddress.INSTANCE, Version.CURRENT);
List<ShardRecoveryResponse> shards = new ArrayList<>();
List<RecoveryState> shards = new ArrayList<>();
// Shard 0
ShardRecoveryResponse shard0 = new ShardRecoveryResponse();
shard0.recoveryState(new RecoveryState(new ShardId(indexName, 0), true, RecoveryState.Type.RELOCATION, source, target));
RecoveryState shard0 = new RecoveryState(new ShardId(indexName, 0), true, RecoveryState.Type.RELOCATION, source, target);
shards.add(shard0);
// Shard 1
ShardRecoveryResponse shard1 = new ShardRecoveryResponse();
shard1.recoveryState(new RecoveryState(new ShardId(indexName, 1), true, RecoveryState.Type.STORE, source, target));
RecoveryState shard1 = new RecoveryState(new ShardId(indexName, 1), true, RecoveryState.Type.STORE, source, target);
shards.add(shard1);
Map<String, List<ShardRecoveryResponse>> shardResponses = new HashMap<>(1);
Map<String, List<RecoveryState>> shardResponses = new HashMap<>(1);
shardResponses.put(indexName, shards);
RecoveryResponse recoveryResponse = new RecoveryResponse(2, 2, 2, false, shardResponses, null);