Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index set overview with closed indices #3930

Merged
merged 1 commit into from Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -123,29 +123,28 @@ private IndexerOverview getIndexerOverview(IndexSet indexSet) throws TooManyAlia
final List<String> indexNames = new ArrayList<>();
indexStats.fieldNames().forEachRemaining(indexNames::add);
final Map<String, Boolean> areReopened = indices.areReopened(indexNames);
final Map<String, IndexSummary> indicesSummaries = buildIndexSummaries(deflectorSummary, indexRanges, indexStats, areReopened);

indices.getClosedIndices(indexSet).forEach(indexName -> indicesSummaries.put(indexName, IndexSummary.create(
null,
indexRanges.stream().filter((indexRangeSummary) -> indexRangeSummary.indexName().equals(indexName)).findFirst().orElse(null),
indexName.equals(deflectorSummary.currentTarget()),
true,
false
)));
final Map<String, IndexSummary> indicesSummaries = buildIndexSummaries(deflectorSummary, indexSet, indexRanges, indexStats, areReopened);

return IndexerOverview.create(deflectorSummary,
IndexerClusterOverview.create(indexerClusterResource.clusterHealth(), indexerClusterResource.clusterName().name()),
countResource.total(indexSetId), indicesSummaries);
}

private Map<String, IndexSummary> buildIndexSummaries(DeflectorSummary deflectorSummary, List<IndexRangeSummary> indexRanges, JsonNode indexStats, Map<String, Boolean> areReopened) {
private Map<String, IndexSummary> buildIndexSummaries(DeflectorSummary deflectorSummary, IndexSet indexSet, List<IndexRangeSummary> indexRanges, JsonNode indexStats, Map<String, Boolean> areReopened) {
final Iterator<Map.Entry<String, JsonNode>> fields = indexStats.fields();
final ImmutableMap.Builder<String, IndexSummary> indexSummaries = ImmutableMap.builder();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> entry = fields.next();
indexSummaries.put(entry.getKey(), buildIndexSummary(entry, indexRanges, deflectorSummary, areReopened));

}
indices.getClosedIndices(indexSet).forEach(indexName -> indexSummaries.put(indexName, IndexSummary.create(
null,
indexRanges.stream().filter((indexRangeSummary) -> indexRangeSummary.indexName().equals(indexName)).findFirst().orElse(null),
indexName.equals(deflectorSummary.currentTarget()),
true,
false
)));
return indexSummaries.build();
}

Expand Down