Skip to content

Commit e7b9b0d

Browse files
committed
SNAPSHOT
1 parent 5e859d9 commit e7b9b0d

File tree

1 file changed

+15
-39
lines changed

1 file changed

+15
-39
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DataStreamDeprecationChecks.java

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,37 @@
1414
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1515

1616
import java.util.List;
17+
import java.util.Set;
18+
import java.util.stream.Collectors;
1719

1820
import static java.util.Map.entry;
1921
import static java.util.Map.ofEntries;
2022

2123
public class DataStreamDeprecationChecks {
2224
static DeprecationIssue oldIndicesCheck(DataStream dataStream, ClusterState clusterState) {
2325
List<Index> backingIndices = dataStream.getIndices();
24-
boolean hasOldIndices = backingIndices.stream()
25-
.anyMatch(index -> clusterState.metadata().index(index).getCompatibilityVersion().before(IndexVersions.V_8_0_0));
26-
if (hasOldIndices) {
27-
long totalIndices = backingIndices.size();
28-
List<Index> oldIndices = backingIndices.stream()
29-
.filter(index -> clusterState.metadata().index(index).getCompatibilityVersion().before(IndexVersions.V_8_0_0))
30-
.toList();
31-
long totalOldIndices = oldIndices.size();
32-
long totalOldSearchableSnapshots = oldIndices.stream()
33-
.filter(index -> clusterState.metadata().index(index).isSearchableSnapshot())
34-
.count();
35-
long totalOldPartiallyMountedSearchableSnapshots = oldIndices.stream()
36-
.filter(index -> clusterState.metadata().index(index).isPartialSearchableSnapshot())
37-
.count();
38-
long totalOldFullyMountedSearchableSnapshots = totalOldSearchableSnapshots - totalOldPartiallyMountedSearchableSnapshots;
39-
return new DeprecationIssue(
26+
27+
Set<String> indiciesNeedingUpgrade = backingIndices.stream()
28+
.filter(index -> clusterState.metadata().index(index).getCompatibilityVersion().before(IndexVersions.V_8_0_0))
29+
.map(Index::getName)
30+
.collect(Collectors.toUnmodifiableSet());
31+
32+
if (indiciesNeedingUpgrade.isEmpty() == false) {
33+
return new DeprecationIssue(
4034
DeprecationIssue.Level.CRITICAL,
4135
"Old data stream with a compatibility version < 8.0",
4236
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-9.0.html",
4337
"This data stream has backing indices that were created before Elasticsearch 8.0.0",
4438
false,
4539
ofEntries(
46-
entry(
47-
"backing_indices",
48-
ofEntries(
49-
entry("count", totalIndices),
50-
entry(
51-
"need_upgrading",
52-
ofEntries(
53-
entry("count", totalOldIndices),
54-
entry(
55-
"searchable_snapshots",
56-
ofEntries(
57-
entry("count", totalOldSearchableSnapshots),
58-
entry("fully_mounted", ofEntries(entry("count", totalOldFullyMountedSearchableSnapshots))),
59-
entry(
60-
"partially_mounted",
61-
ofEntries(entry("count", totalOldPartiallyMountedSearchableSnapshots))
62-
)
63-
)
64-
)
65-
)
66-
)
67-
)
68-
)
40+
entry("reindex_required",true),
41+
entry("total_backing_indicies", backingIndices.size()),
42+
entry("indicies_requiring_upgrade_count", indiciesNeedingUpgrade.size()),
43+
entry("indicies_requiring_upgrade", indiciesNeedingUpgrade)
6944
)
7045
);
7146
}
47+
7248
return null;
7349
}
7450
}

0 commit comments

Comments
 (0)