Skip to content

Commit

Permalink
Follow stats structure (#34301)
Browse files Browse the repository at this point in the history
This commit modifies the follow stats API response structure to more
clearly highlight meaning of the higher level fields. In particular,
previously the response had a top-level key for each index. Instead, we
nest the indices under an "indices" field which is now an array. The
values in this array are objects containing two fields: "index" which is
the name of the follower index, and "shards" which is an array where
each value in the array is the follower stats for that shard. That is,
we have gone from:

{
  "bar": [
    {
      "shard_id": 0...
    }...
  ]...
}

to

{
  "indices": [
    {
      "index": "bar",
      "shards": [
        {
          "shard_id": 0...
        }...
      ]
   }...
}
  • Loading branch information
jasontedor authored Oct 5, 2018
1 parent 7478167 commit 7d57bdb
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
"Test stats":
- do:
indices.create:
index: foo
body:
settings:
index:
soft_deletes:
enabled: true
mappings:
doc:
properties:
field:
type: keyword

- do:
ccr.follow:
index: bar
body:
leader_index: foo
- is_true: follow_index_created
- is_true: follow_index_shards_acked
- is_true: index_following_started

# we can not reliably wait for replication to occur so we test the endpoint without indexing any documents
- do:
ccr.stats:
index: bar
- match: { indices.0.index: "bar" }
- match: { indices.0.shards.0.leader_index: "foo" }
- match: { indices.0.shards.0.follower_index: "bar" }
- match: { indices.0.shards.0.shard_id: 0 }
- gte: { indices.0.shards.0.leader_global_checkpoint: -1 }
- gte: { indices.0.shards.0.leader_max_seq_no: -1 }
- gte: { indices.0.shards.0.follower_global_checkpoint: -1 }
- gte: { indices.0.shards.0.follower_max_seq_no: -1 }
- gte: { indices.0.shards.0.last_requested_seq_no: -1 }
- gte: { indices.0.shards.0.number_of_concurrent_reads: 0 }
- match: { indices.0.shards.0.number_of_concurrent_writes: 0 }
- match: { indices.0.shards.0.number_of_queued_writes: 0 }
- gte: { indices.0.shards.0.mapping_version: 0 }
- gte: { indices.0.shards.0.total_fetch_time_millis: 0 }
- gte: { indices.0.shards.0.number_of_successful_fetches: 0 }
- gte: { indices.0.shards.0.number_of_failed_fetches: 0 }
- match: { indices.0.shards.0.operations_received: 0 }
- match: { indices.0.shards.0.total_transferred_bytes: 0 }
- match: { indices.0.shards.0.total_index_time_millis: 0 }
- match: { indices.0.shards.0.number_of_successful_bulk_operations: 0 }
- match: { indices.0.shards.0.number_of_failed_bulk_operations: 0 }
- match: { indices.0.shards.0.number_of_operations_indexed: 0 }
- length: { indices.0.shards.0.fetch_exceptions: 0 }
- gte: { indices.0.shards.0.time_since_last_fetch_millis: -1 }

- do:
ccr.pause_follow:
index: bar
- is_true: acknowledged

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,24 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
}
builder.startObject();
{
for (final Map.Entry<String, Map<Integer, StatsResponse>> index : taskResponsesByIndex.entrySet()) {
builder.startArray(index.getKey());
{
for (final Map.Entry<Integer, StatsResponse> shard : index.getValue().entrySet()) {
shard.getValue().status().toXContent(builder, params);
builder.startArray("indices");
{
for (final Map.Entry<String, Map<Integer, StatsResponse>> index : taskResponsesByIndex.entrySet()) {
builder.startObject();
{
builder.field("index", index.getKey());
builder.startArray("shards");
{
for (final Map.Entry<Integer, StatsResponse> shard : index.getValue().entrySet()) {
shard.getValue().status().toXContent(builder, params);
}
}
builder.endArray();
}
builder.endObject();
}
builder.endArray();
}
builder.endArray();
}
builder.endObject();
return builder;
Expand Down

0 comments on commit 7d57bdb

Please sign in to comment.