Skip to content

Commit ae9786a

Browse files
committed
Merge branch 'upstream/master' into rollover-add-max_shard_docs
* upstream/master: [DOCS] Switch xrefs to external links (elastic#83590) [DOCS] 'features' flag added in elastic#83083 (elastic#83452) Rename ChangePolicyforIndexIT to ChangePolicyForIndexIT (elastic#83569) Fixing random_sampler tests (elastic#83549) Upgrade Checkstyle to 9.3 (elastic#83314) Make improvements to the release notes generator (elastic#83525) Cleanup DataTierAllocationDecider (elastic#83572) Upgrade jANSI dependency to 2.4.0 (elastic#83566) Speed up Name Collision Check in Metadata.Builder (elastic#83340) SQL: Add range checks to interval multiplication operation (elastic#83478) Remove DiscoveryNodes#getAllNodes (elastic#83538) Make RoutingNodes behave like a collection (elastic#83540) Remove Unused CS Listener from SecurityServerTransportInterceptor (elastic#83556)
2 parents 69ee711 + 02ea65a commit ae9786a

File tree

78 files changed

+893
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+893
-973
lines changed

.idea/checkstyle-idea.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public ClusterState measureAllocation() {
156156
while (clusterState.getRoutingNodes().hasUnassignedShards()) {
157157
clusterState = strategy.applyStartedShards(
158158
clusterState,
159-
StreamSupport.stream(clusterState.getRoutingNodes().spliterator(), false)
159+
clusterState.getRoutingNodes()
160+
.stream()
160161
.flatMap(shardRoutings -> StreamSupport.stream(shardRoutings.spliterator(), false))
161162
.filter(ShardRouting::initializing)
162163
.collect(Collectors.toList())

build-conventions/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ dependencies {
6565
api 'org.apache.maven:maven-model:3.6.2'
6666
api 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0'
6767
api 'org.apache.rat:apache-rat:0.11'
68-
compileOnly "com.puppycrawl.tools:checkstyle:8.45.1"
68+
compileOnly "com.puppycrawl.tools:checkstyle:9.3"
6969
api('com.diffplug.spotless:spotless-plugin-gradle:6.0.0') {
7070
exclude module: "groovy-xml"
7171
}

build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/HiddenFieldCheck.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* @notice
33
* checkstyle: Checks Java source code for adherence to a set of rules.
44
* Copyright (C) 2001-2021 the original author or authors.
5-
5+
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Lesser General Public
88
* License as published by the Free Software Foundation; either
99
* version 2.1 of the License, or (at your option) any later version.
10-
10+
*
1111
* This library is distributed in the hope that it will be useful,
1212
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1313
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1414
* Lesser General Public License for more details.
15-
15+
*
1616
* You should have received a copy of the GNU Lesser General Public
1717
* License along with this library; if not, write to the Free Software
1818
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

build-conventions/src/main/java/org/elasticsearch/gradle/internal/checkstyle/MissingJavadocTypeCheck.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public int[] getRequiredTokens() {
121121
return CommonUtil.EMPTY_INT_ARRAY;
122122
}
123123

124+
// suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166
125+
@SuppressWarnings("deprecation")
124126
@Override
125127
public void visitToken(DetailAST ast) {
126128
if (shouldCheck(ast)) {
@@ -140,24 +142,18 @@ public void visitToken(DetailAST ast) {
140142
* @return whether we should check a given node.
141143
*/
142144
private boolean shouldCheck(final DetailAST ast) {
143-
final Scope customScope;
144-
145-
if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) {
146-
customScope = Scope.PUBLIC;
147-
} else {
148-
final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS);
149-
customScope = ScopeUtil.getScopeFromMods(mods);
150-
}
145+
final Scope customScope = ScopeUtil.getScope(ast);
151146
final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast);
152147

153148
final String outerTypeName = ast.findFirstToken(TokenTypes.IDENT).getText();
154149

155150
return customScope.isIn(scope)
156151
&& (surroundingScope == null || surroundingScope.isIn(scope))
157152
&& (excludeScope == null
158-
|| customScope.isIn(excludeScope) == false
159-
|| surroundingScope != null && surroundingScope.isIn(excludeScope) == false)
160-
&& AnnotationUtil.containsAnnotation(ast, skipAnnotations) == false
153+
|| !customScope.isIn(excludeScope)
154+
|| surroundingScope != null
155+
&& !surroundingScope.isIn(excludeScope))
156+
&& !AnnotationUtil.containsAnnotation(ast, skipAnnotations)
161157
&& ignorePattern.matcher(outerTypeName).find() == false;
162158
}
163159

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ValidateJsonAgainstSchemaTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import java.util.stream.StreamSupport;
4343

4444
/**
45-
* Incremental task to validate a set of JSON files against against a schema.
45+
* Incremental task to validate a set of JSON files against a schema.
4646
*/
4747
public class ValidateJsonAgainstSchemaTask extends DefaultTask {
4848
private File jsonSchema;

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ValidateYamlAgainstSchemaTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
1313

1414
/**
15-
* Incremental task to validate a set of YAML files against against a schema.
15+
* Incremental task to validate a set of YAML files against a schema.
1616
*/
1717
public class ValidateYamlAgainstSchemaTask extends ValidateJsonAgainstSchemaTask {
1818
@Override

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/BreakingChangesGenerator.java

Lines changed: 27 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -11,148 +11,72 @@
1111
import com.google.common.annotations.VisibleForTesting;
1212

1313
import org.elasticsearch.gradle.VersionProperties;
14-
import org.gradle.api.GradleException;
1514

1615
import java.io.File;
1716
import java.io.FileWriter;
1817
import java.io.IOException;
1918
import java.nio.file.Files;
2019
import java.util.HashMap;
2120
import java.util.List;
22-
import java.util.Locale;
2321
import java.util.Map;
2422
import java.util.Objects;
25-
import java.util.Set;
2623
import java.util.TreeMap;
27-
import java.util.TreeSet;
28-
import java.util.stream.Collectors;
2924

3025
import static java.util.Comparator.comparing;
3126
import static java.util.stream.Collectors.groupingBy;
32-
import static java.util.stream.Collectors.toCollection;
27+
import static java.util.stream.Collectors.toList;
3328

3429
/**
35-
* Generates the page that contains an index into the breaking changes and lists deprecations for a minor version release,
36-
* and the individual pages for each breaking area.
30+
* Generates the page that contains breaking changes deprecations for a minor release series.
3731
*/
3832
public class BreakingChangesGenerator {
3933

40-
// Needs to match `changelog-schema.json`
41-
private static final List<String> BREAKING_AREAS = List.of(
42-
"Cluster and node setting",
43-
"Command line tool",
44-
"Index setting",
45-
"JVM option",
46-
"Java API",
47-
"Logging",
48-
"Mapping",
49-
"Packaging",
50-
"Painless",
51-
"REST API",
52-
"System requirement",
53-
"Transform"
54-
);
55-
56-
static void update(
57-
File indexTemplateFile,
58-
File indexOutputFile,
59-
File outputDirectory,
60-
File areaTemplateFile,
61-
List<ChangelogEntry> entries
62-
) throws IOException {
63-
if (outputDirectory.exists()) {
64-
if (outputDirectory.isDirectory() == false) {
65-
throw new GradleException("Path [" + outputDirectory + "] exists but isn't a directory!");
66-
}
67-
} else {
68-
Files.createDirectory(outputDirectory.toPath());
69-
}
70-
71-
try (FileWriter output = new FileWriter(indexOutputFile)) {
34+
static void update(File migrationTemplateFile, File migrationOutputFile, List<ChangelogEntry> entries) throws IOException {
35+
try (FileWriter output = new FileWriter(migrationOutputFile)) {
7236
output.write(
73-
generateIndexFile(
37+
generateMigrationFile(
7438
QualifiedVersion.of(VersionProperties.getElasticsearch()),
75-
Files.readString(indexTemplateFile.toPath()),
39+
Files.readString(migrationTemplateFile.toPath()),
7640
entries
7741
)
7842
);
7943
}
80-
81-
String areaTemplate = Files.readString(areaTemplateFile.toPath());
82-
83-
for (String breakingArea : BREAKING_AREAS) {
84-
final List<ChangelogEntry.Breaking> entriesForArea = entries.stream()
85-
.map(ChangelogEntry::getBreaking)
86-
.filter(entry -> entry != null && breakingArea.equals(entry.getArea()))
87-
.collect(Collectors.toList());
88-
89-
if (entriesForArea.isEmpty()) {
90-
continue;
91-
}
92-
93-
final String outputFilename = breakingArea.toLowerCase(Locale.ROOT).replaceFirst(" and", "").replaceAll(" ", "-")
94-
+ "-changes.asciidoc";
95-
96-
try (FileWriter output = new FileWriter(outputDirectory.toPath().resolve(outputFilename).toFile())) {
97-
output.write(
98-
generateBreakingAreaFile(
99-
QualifiedVersion.of(VersionProperties.getElasticsearch()),
100-
areaTemplate,
101-
breakingArea,
102-
entriesForArea
103-
)
104-
);
105-
}
106-
}
10744
}
10845

10946
@VisibleForTesting
110-
static String generateIndexFile(QualifiedVersion version, String template, List<ChangelogEntry> entries) throws IOException {
111-
final Map<String, List<ChangelogEntry.Deprecation>> deprecationsByArea = entries.stream()
47+
static String generateMigrationFile(QualifiedVersion version, String template, List<ChangelogEntry> entries) throws IOException {
48+
final Map<Boolean, Map<String, List<ChangelogEntry.Deprecation>>> deprecationsByNotabilityByArea = entries.stream()
11249
.map(ChangelogEntry::getDeprecation)
11350
.filter(Objects::nonNull)
11451
.sorted(comparing(ChangelogEntry.Deprecation::getTitle))
115-
.collect(groupingBy(ChangelogEntry.Deprecation::getArea, TreeMap::new, Collectors.toList()));
116-
117-
final List<String> breakingIncludeList = entries.stream()
118-
.filter(each -> each.getBreaking() != null)
119-
.map(each -> each.getBreaking().getArea().toLowerCase(Locale.ROOT).replaceFirst(" and", "").replaceAll(" ", "-"))
120-
.distinct()
121-
.sorted()
122-
.toList();
123-
124-
final Map<String, Object> bindings = new HashMap<>();
125-
bindings.put("breakingIncludeList", breakingIncludeList);
126-
bindings.put("deprecationsByArea", deprecationsByArea);
127-
bindings.put("isElasticsearchSnapshot", version.isSnapshot());
128-
bindings.put("majorDotMinor", version.major() + "." + version.minor());
129-
bindings.put("majorMinor", String.valueOf(version.major()) + version.minor());
130-
bindings.put("nextMajor", (version.major() + 1) + ".0");
131-
bindings.put("version", version);
132-
133-
return TemplateUtils.render(template, bindings);
134-
}
52+
.collect(
53+
groupingBy(
54+
ChangelogEntry.Deprecation::isNotable,
55+
TreeMap::new,
56+
groupingBy(ChangelogEntry.Deprecation::getArea, TreeMap::new, toList())
57+
)
58+
);
13559

136-
@VisibleForTesting
137-
static String generateBreakingAreaFile(
138-
QualifiedVersion version,
139-
String template,
140-
String breakingArea,
141-
List<ChangelogEntry.Breaking> entriesForArea
142-
) throws IOException {
143-
final Map<Boolean, Set<ChangelogEntry.Breaking>> breakingEntriesByNotability = entriesForArea.stream()
60+
final Map<Boolean, Map<String, List<ChangelogEntry.Breaking>>> breakingByNotabilityByArea = entries.stream()
61+
.map(ChangelogEntry::getBreaking)
62+
.filter(Objects::nonNull)
63+
.sorted(comparing(ChangelogEntry.Breaking::getTitle))
14464
.collect(
14565
groupingBy(
14666
ChangelogEntry.Breaking::isNotable,
147-
toCollection(() -> new TreeSet<>(comparing(ChangelogEntry.Breaking::getTitle)))
67+
TreeMap::new,
68+
groupingBy(ChangelogEntry.Breaking::getArea, TreeMap::new, toList())
14869
)
14970
);
15071

15172
final Map<String, Object> bindings = new HashMap<>();
152-
bindings.put("breakingArea", breakingArea);
153-
bindings.put("breakingEntriesByNotability", breakingEntriesByNotability);
154-
bindings.put("breakingAreaAnchor", breakingArea.toLowerCase(Locale.ROOT).replaceFirst(" and", "").replaceAll(" ", "_"));
73+
bindings.put("breakingByNotabilityByArea", breakingByNotabilityByArea);
74+
bindings.put("deprecationsByNotabilityByArea", deprecationsByNotabilityByArea);
75+
bindings.put("isElasticsearchSnapshot", version.isSnapshot());
76+
bindings.put("majorDotMinor", version.major() + "." + version.minor());
15577
bindings.put("majorMinor", String.valueOf(version.major()) + version.minor());
78+
bindings.put("nextMajor", (version.major() + 1) + ".0");
79+
bindings.put("version", version);
15680

15781
return TemplateUtils.render(template, bindings);
15882
}

0 commit comments

Comments
 (0)