Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ protected IndicesSegmentResponse fromXContent(final XContentParser parser) throw
// BroadcastResponse wire format: totalShards(int), successfulShards(int), failedShards(int), shardFailures(vint size)
// Then IndicesSegmentResponse reads: ShardSegments array(vint size)
try (final ByteArrayStreamOutput out = new ByteArrayStreamOutput()) {
out.writeInt(totalShards);
out.writeInt(successfulShards);
out.writeInt(failedShards);
out.writeVInt(totalShards);
out.writeVInt(successfulShards);
out.writeVInt(failedShards);
out.writeVInt(0); // no shard failures
out.writeVInt(0); // no ShardSegments
return action.getResponseReader().read(out.toStreamInput());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ protected CurlRequest getCurlRequest(final PutIndexTemplateRequest request) {
if (request.cause() != null) {
curlRequest.param("cause", "");
}
if (request.patterns() != null) {
curlRequest.param("index_pattern", String.join(",", request.patterns()));
}
// patterns are included in the request body via toXContent()
return curlRequest;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,38 @@ protected RecoveryResponse fromXContent(final XContentParser parser) throws IOEx
}

// The recovery response JSON is {"indexName":{"shards":[{...}]}} with no _shards header.
// RecoveryState is complex to parse, so we consume the entire JSON and return an empty response.
// RecoveryState is complex to parse, so we count shards and consume the rest.
int totalShards = 0;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
// index name
} else if (token == XContentParser.Token.START_OBJECT) {
consumeObject(parser);
totalShards += countShardsAndConsume(parser);
}
}

return new RecoveryResponse(0, 0, 0, Collections.emptyMap(), new ArrayList<>());
return new RecoveryResponse(totalShards, totalShards, 0, Collections.emptyMap(), new ArrayList<>());
}

protected int countShardsAndConsume(final XContentParser parser) throws IOException {
int shardCount = 0;
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME && "shards".equals(parser.currentName())) {
token = parser.nextToken(); // START_ARRAY
if (token == XContentParser.Token.START_ARRAY) {
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
shardCount++;
consumeObject(parser);
}
}
} else if (token == XContentParser.Token.START_OBJECT) {
consumeObject(parser);
} else if (token == XContentParser.Token.START_ARRAY) {
consumeObject(parser);
}
}
return shardCount;
}

protected void consumeObject(final XContentParser parser) throws IOException {
Expand Down
Loading
Loading