Skip to content

Commit 69bc97d

Browse files
committed
Merge remote-tracking branch 'es/master' into ccr
* es/master: (38 commits) Backport wait_for_initialiazing_shards to cluster health API Carry over version map size to prevent excessive resizing (#27516) Fix scroll query with a sort that is a prefix of the index sort (#27498) Delete shard store files before restoring a snapshot (#27476) Replace `delimited_payload_filter` by `delimited_payload` (#26625) CURRENT should not be a -SNAPSHOT version if build.snapshot is false (#27512) Fix merging of _meta field (#27352) Remove unused method (#27508) unmuted test, this has been fixed by #27397 Consolidate version numbering semantics (#27397) Add wait_for_no_initializing_shards to cluster health API (#27489) [TEST] use routing partition size based on the max routing shards of the second split Adjust CombinedDeletionPolicy for multiple commits (#27456) Update composite-aggregation.asciidoc Deprecate `levenstein` in favor of `levenshtein` (#27409) Automatically prepare indices for splitting (#27451) Validate `op_type` for `_create` (#27483) Minor ShapeBuilder cleanup muted test Decouple nio constructs from the tcp transport (#27484) ...
2 parents f2eaacb + 06d35f4 commit 69bc97d

File tree

228 files changed

+4046
-1264
lines changed

Some content is hidden

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

228 files changed

+4046
-1264
lines changed

build.gradle

+26-95
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
import java.nio.file.Path
21-
import java.util.regex.Matcher
22-
import org.eclipse.jgit.lib.Repository
23-
import org.eclipse.jgit.lib.RepositoryBuilder
24-
import org.gradle.plugins.ide.eclipse.model.SourceFolder
20+
2521
import org.apache.tools.ant.taskdefs.condition.Os
2622
import org.elasticsearch.gradle.BuildPlugin
27-
import org.elasticsearch.gradle.VersionProperties
2823
import org.elasticsearch.gradle.Version
24+
import org.elasticsearch.gradle.VersionCollection
25+
import org.elasticsearch.gradle.VersionProperties
26+
import org.gradle.plugins.ide.eclipse.model.SourceFolder
27+
28+
import java.nio.file.Path
2929

3030
// common maven publishing configuration
3131
subprojects {
@@ -67,72 +67,16 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {
6767
}
6868
}
6969

70-
/* Introspect all versions of ES that may be tested agains for backwards
70+
/* Introspect all versions of ES that may be tested against for backwards
7171
* compatibility. It is *super* important that this logic is the same as the
7272
* logic in VersionUtils.java, throwing out alphas because they don't have any
7373
* backwards compatibility guarantees and only keeping the latest beta or rc
7474
* in a branch if there are only betas and rcs in the branch so we have
7575
* *something* to test against. */
76-
Version currentVersion = Version.fromString(VersionProperties.elasticsearch.minus('-SNAPSHOT'))
77-
int prevMajor = currentVersion.major - 1
78-
File versionFile = file('core/src/main/java/org/elasticsearch/Version.java')
79-
List<String> versionLines = versionFile.readLines('UTF-8')
80-
List<Version> versions = []
81-
// keep track of the previous major version's last minor, so we know where wire compat begins
82-
int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major
83-
int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen
84-
int prevBugfixIndex = -1 // index in the versions list of the last bugfix release from the prev major
85-
for (String line : versionLines) {
86-
/* Note that this skips alphas and betas which is fine because they aren't
87-
* compatible with anything. */
88-
Matcher match = line =~ /\W+public static final Version V_(\d+)_(\d+)_(\d+)(_beta\d+|_rc\d+)? .*/
89-
if (match.matches()) {
90-
int major = Integer.parseInt(match.group(1))
91-
int minor = Integer.parseInt(match.group(2))
92-
int bugfix = Integer.parseInt(match.group(3))
93-
String suffix = (match.group(4) ?: '').replace('_', '-')
94-
Version foundVersion = new Version(major, minor, bugfix, suffix, false)
95-
if (currentVersion != foundVersion
96-
&& (major == prevMajor || major == currentVersion.major)) {
97-
if (versions.isEmpty() || versions.last() != foundVersion) {
98-
versions.add(foundVersion)
99-
} else {
100-
// Replace the earlier betas with later ones
101-
Version last = versions.set(versions.size() - 1, foundVersion)
102-
if (last.suffix == '') {
103-
throw new InvalidUserDataException("Found two equal versions but"
104-
+ " the first one [$last] wasn't a beta.")
105-
}
106-
}
107-
if (major == prevMajor && minor > lastPrevMinor) {
108-
prevMinorIndex = versions.size() - 1
109-
lastPrevMinor = minor
110-
}
111-
}
112-
if (major == prevMajor) {
113-
prevBugfixIndex = versions.size() - 1
114-
}
115-
}
116-
}
117-
if (versions.toSorted { it.id } != versions) {
118-
println "Versions: ${versions}"
119-
throw new GradleException("Versions.java contains out of order version constants")
120-
}
121-
if (prevBugfixIndex != -1) {
122-
versions[prevBugfixIndex] = new Version(versions[prevBugfixIndex].major, versions[prevBugfixIndex].minor,
123-
versions[prevBugfixIndex].bugfix, versions[prevBugfixIndex].suffix, true)
124-
}
125-
if (currentVersion.bugfix == 0) {
126-
// If on a release branch, after the initial release of that branch, the bugfix version will
127-
// be bumped, and will be != 0. On master and N.x branches, we want to test against the
128-
// unreleased version of closest branch. So for those cases, the version includes -SNAPSHOT,
129-
// and the bwc distribution will checkout and build that version.
130-
Version last = versions[-1]
131-
versions[-1] = new Version(last.major, last.minor, last.bugfix, last.suffix, true)
132-
if (last.bugfix == 0) {
133-
versions[-2] = new Version(
134-
versions[-2].major, versions[-2].minor, versions[-2].bugfix, versions[-2].suffix, true)
135-
}
76+
VersionCollection versions = new VersionCollection(file('core/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
77+
if (versions.currentVersion.toString() != VersionProperties.elasticsearch) {
78+
throw new GradleException("The last version in Versions.java [${versions.currentVersion}] does not match " +
79+
"VersionProperties.elasticsearch [${VersionProperties.elasticsearch}]")
13680
}
13781

13882
// build metadata from previous build, contains eg hashes for bwc builds
@@ -151,9 +95,10 @@ allprojects {
15195
// for ide hacks...
15296
isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || gradle.startParameter.taskNames.contains('cleanEclipse')
15397
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea')
154-
// for backcompat testing
155-
indexCompatVersions = versions
156-
wireCompatVersions = versions.subList(prevMinorIndex, versions.size())
98+
99+
// for BWC testing
100+
versionCollection = versions
101+
157102
buildMetadata = buildMetadataMap
158103
}
159104
}
@@ -171,13 +116,13 @@ task verifyVersions {
171116
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) })
172117

173118
// Limit the known versions to those that should be index compatible, and are not future versions
174-
knownVersions = knownVersions.findAll { it.major >= prevMajor && it.before(VersionProperties.elasticsearch) }
119+
knownVersions = knownVersions.findAll { it.major >= versions.currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) }
175120

176121
/* Limit the listed versions to those that have been marked as released.
177122
* Versions not marked as released don't get the same testing and we want
178123
* to make sure that we flip all unreleased versions to released as soon
179124
* as possible after release. */
180-
Set<Version> actualVersions = new TreeSet<>(indexCompatVersions.findAll { false == it.snapshot })
125+
Set<Version> actualVersions = new TreeSet<>(versions.versionsIndexCompatibleWithCurrent.findAll { false == it.snapshot })
181126

182127
// Finally, compare!
183128
if (knownVersions.equals(actualVersions) == false) {
@@ -251,32 +196,18 @@ subprojects {
251196
"org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
252197
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
253198
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
254-
"org.elasticsearch.plugin:aggs-composite-client:${version}": ':modules:aggs-composite',
255199
]
256-
if (indexCompatVersions[-1].snapshot) {
257-
/* The last and second to last versions can be snapshots. Rather than use
258-
* snapshots built by CI we connect these versions to projects that build
259-
* those those versions from the HEAD of the appropriate branch. */
260-
if (indexCompatVersions[-1].bugfix == 0) {
261-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
262-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
263-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
264-
if (indexCompatVersions.size() > 1) {
265-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
266-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
267-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
268-
}
269-
} else {
270-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
271-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
272-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
200+
201+
for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) {
202+
if (version.branch != null) {
203+
final String snapshotProject = ":distribution:bwc-snapshot-${version.branch}"
204+
project(snapshotProject).ext.bwcVersion = version
205+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${version}"] = snapshotProject
206+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${version}"] = snapshotProject
207+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${version}"] = snapshotProject
273208
}
274-
} else if (indexCompatVersions[-2].snapshot) {
275-
/* This is a terrible hack for the bump to 6.0.1 which will be fixed by #27397 */
276-
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
277-
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
278-
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
279209
}
210+
280211
project.afterEvaluate {
281212
configurations.all {
282213
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->

buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy

+48-7
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,26 @@ public class Version {
3131

3232
final int major
3333
final int minor
34-
final int bugfix
34+
final int revision
3535
final int id
3636
final boolean snapshot
37+
final String branch
3738
/**
3839
* Suffix on the version name. Unlike Version.java the build does not
3940
* consider alphas and betas different versions, it just preserves the
4041
* suffix that the version was declared with in Version.java.
4142
*/
4243
final String suffix
4344

44-
public Version(int major, int minor, int bugfix,
45-
String suffix, boolean snapshot) {
45+
public Version(int major, int minor, int revision,
46+
String suffix, boolean snapshot, String branch) {
4647
this.major = major
4748
this.minor = minor
48-
this.bugfix = bugfix
49+
this.revision = revision
4950
this.snapshot = snapshot
5051
this.suffix = suffix
51-
this.id = major * 100000 + minor * 1000 + bugfix * 10 +
52+
this.branch = branch
53+
this.id = major * 100000 + minor * 1000 + revision * 10 +
5254
(snapshot ? 1 : 0)
5355
}
5456

@@ -58,13 +60,13 @@ public class Version {
5860
throw new InvalidUserDataException("Invalid version [${s}]")
5961
}
6062
return new Version(m.group(1) as int, m.group(2) as int,
61-
m.group(3) as int, m.group(4) ?: '', m.group(5) != null)
63+
m.group(3) as int, m.group(4) ?: '', m.group(5) != null, null)
6264
}
6365

6466
@Override
6567
public String toString() {
6668
String snapshotStr = snapshot ? '-SNAPSHOT' : ''
67-
return "${major}.${minor}.${bugfix}${suffix}${snapshotStr}"
69+
return "${major}.${minor}.${revision}${suffix}${snapshotStr}"
6870
}
6971

7072
public boolean before(String compareTo) {
@@ -82,4 +84,43 @@ public class Version {
8284
public boolean after(String compareTo) {
8385
return id > fromString(compareTo).id
8486
}
87+
88+
public boolean onOrBeforeIncludingSuffix(Version otherVersion) {
89+
if (id != otherVersion.id) {
90+
return id < otherVersion.id
91+
}
92+
93+
if (suffix == '') {
94+
return otherVersion.suffix == ''
95+
}
96+
97+
return otherVersion.suffix == '' || suffix < otherVersion.suffix
98+
}
99+
100+
boolean equals(o) {
101+
if (this.is(o)) return true
102+
if (getClass() != o.class) return false
103+
104+
Version version = (Version) o
105+
106+
if (id != version.id) return false
107+
if (major != version.major) return false
108+
if (minor != version.minor) return false
109+
if (revision != version.revision) return false
110+
if (snapshot != version.snapshot) return false
111+
if (suffix != version.suffix) return false
112+
113+
return true
114+
}
115+
116+
int hashCode() {
117+
int result
118+
result = major
119+
result = 31 * result + minor
120+
result = 31 * result + revision
121+
result = 31 * result + id
122+
result = 31 * result + (snapshot ? 1 : 0)
123+
result = 31 * result + (suffix != null ? suffix.hashCode() : 0)
124+
return result
125+
}
85126
}

0 commit comments

Comments
 (0)