Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into icu_analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
romseygeek committed Nov 13, 2018
2 parents 4f2fd4d + ca24d9a commit ba210cb
Show file tree
Hide file tree
Showing 678 changed files with 14,042 additions and 4,637 deletions.
1 change: 0 additions & 1 deletion .ci/java-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ ES_BUILD_JAVA=java11
ES_RUNTIME_JAVA=java8
GRADLE_TASK=build

GRADLE_EXTRA_ARGS=-Dtests.bwc.refspec=elastic/index-lifecycle-6.x
20 changes: 17 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,26 @@ the settings window and/or restart IntelliJ to see your changes take effect.

### Creating A Distribution

To create a distribution from the source, simply run:
Run all build commands from within the root directory:

```sh
cd elasticsearch/
./gradlew assemble
```

To build a tar distribution, run this command:

```sh
./gradlew -p distribution/archives/tar assemble --parallel
```

You will find the distribution under:
`./distribution/archives/tar/build/distributions/`

To create all build artifacts (e.g., plugins and Javadocs) as well as
distributions in all formats, run this command:

```sh
./gradlew assemble --parallel
```

The package distributions (Debian and RPM) can be found under:
Expand All @@ -209,7 +224,6 @@ The package distributions (Debian and RPM) can be found under:
The archive distributions (tar and zip) can be found under:
`./distribution/archives/(tar|zip)/build/distributions/`


### Running The Full Test Suite

Before submitting your changes, run the test suite to make sure that nothing is broken, with:
Expand Down
12 changes: 8 additions & 4 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ if (project == rootProject) {
// we update the version property to reflect if we are building a snapshot or a release build
// we write this back out below to load it in the Build.java which will be shown in rest main action
// to indicate this being a snapshot build or a release build.
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
File propsFile = project.file('version.properties')
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(propsFile)
version = props.getProperty("elasticsearch")
processResources {
inputs.file(propsFile)
// We need to be explicit with the version because we add snapshot and qualifier to it based on properties
inputs.property("dynamic_elasticsearch_version", props.getProperty("elasticsearch"))
doLast {
Writer writer = file("$destinationDir/version.properties").newWriter()
try {
Expand All @@ -61,8 +65,8 @@ processResources {
* Java version *
*****************************************************************************/

if (JavaVersion.current() < JavaVersion.VERSION_1_10) {
throw new GradleException('At least Java 10 is required to build elasticsearch gradle tools')
if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException('At least Java 11 is required to build elasticsearch gradle tools')
}
// Gradle 4.10 does not support setting this to 11 yet
targetCompatibility = "10"
Expand Down Expand Up @@ -241,7 +245,7 @@ class VersionPropertiesLoader {
elasticsearch
)
}
String qualifier = systemProperties.getProperty("build.version_qualifier", "alpha1");
String qualifier = systemProperties.getProperty("build.version_qualifier", "");
if (qualifier.isEmpty() == false) {
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
throw new IllegalStateException("Invalid qualifier: " + qualifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class BuildPlugin implements Plugin<Project> {
// this doFirst is added before the info plugin, therefore it will run
// after the doFirst added by the info plugin, and we can override attributes
jarTask.manifest.attributes(
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch.replace("-SNAPSHOT", ""),
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
'X-Compile-Lucene-Version': VersionProperties.lucene,
'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(),
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.gradle.doc

import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.test.RestTestPlugin
import org.gradle.api.Project
Expand All @@ -37,12 +38,12 @@ public class DocsTestPlugin extends RestTestPlugin {
// Docs are published separately so no need to assemble
project.tasks.assemble.enabled = false
Map<String, String> defaultSubstitutions = [
/* These match up with the asciidoc syntax for substitutions but
* the values may differ. In particular {version} needs to resolve
* to the version being built for testing but needs to resolve to
* the last released version for docs. */
'\\{version\\}':
VersionProperties.elasticsearch.replace('-SNAPSHOT', ''),
/* These match up with the asciidoc syntax for substitutions but
* the values may differ. In particular {version} needs to resolve
* to the version being built for testing but needs to resolve to
* the last released version for docs. */
'\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(),
'\\{version_qualified\\}': VersionProperties.elasticsearch,
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
'\\{build_flavor\\}' :
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.gradle.plugin

import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Task
Expand Down Expand Up @@ -66,17 +67,11 @@ class PluginPropertiesTask extends Copy {
}

Map<String, String> generateSubstitutions() {
def stringSnap = { version ->
if (version.endsWith("-SNAPSHOT")) {
return version.substring(0, version.length() - 9)
}
return version
}
return [
'name': extension.name,
'description': extension.description,
'version': stringSnap(extension.version),
'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch),
'version': extension.version,
'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(),
'javaVersion': project.targetCompatibility as String,
'classname': extension.classname,
'extendedPlugins': extension.extendedPlugins.join(','),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class ClusterConfiguration {
return seedNode.transportUri()
}

/**
* A closure to call which returns a manually supplied list of unicast seed hosts.
*/
@Input
Closure<List<String>> otherUnicastHostAddresses = {
Collections.emptyList()
}

/**
* A closure to call before the cluster is considered ready. The closure is passed the node info,
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,9 @@ class ClusterFormationTasks {
wait.doLast {

Collection<String> unicastHosts = new HashSet<>()
nodes.forEach { otherNode ->
String unicastHost = otherNode.config.unicastTransportUri(otherNode, null, project.ant)
nodes.forEach { node ->
unicastHosts.addAll(node.config.otherUnicastHostAddresses.call())
String unicastHost = node.config.unicastTransportUri(node, null, project.ant)
if (unicastHost != null) {
unicastHosts.addAll(Arrays.asList(unicastHost.split(",")))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,13 @@ class VagrantTestPlugin implements Plugin<Project> {
}

Task createUpgradeFromFile = project.tasks.create('createUpgradeFromFile', FileContentsTask) {
String version = project.extensions.esvagrant.upgradeFromVersion
if (project.bwcVersions.unreleased.contains(project.extensions.esvagrant.upgradeFromVersion)) {
version += "-SNAPSHOT"
}
dependsOn copyPackagingArchives
file "${archivesDir}/upgrade_from_version"
contents project.extensions.esvagrant.upgradeFromVersion.toString()
contents version
}

Task createUpgradeIsOssFile = project.tasks.create('createUpgradeIsOssFile', FileContentsTask) {
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
elasticsearch = 7.0.0
lucene = 8.0.0-snapshot-7d0a7782fa
lucene = 8.0.0-snapshot-31d7dfe6b1

# optional dependencies
spatial4j = 0.7
Expand All @@ -16,6 +16,7 @@ slf4j = 1.6.2
jna = 4.5.1

netty = 4.1.30.Final
joda = 2.10.1

# test dependencies
randomizedrunner = 2.7.0
Expand Down
6 changes: 3 additions & 3 deletions client/benchmark/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Steps to execute the benchmark

1. Build `client-benchmark-noop-api-plugin` with `gradle :client:client-benchmark-noop-api-plugin:assemble`
2. Install it on the target host with `bin/elasticsearch-plugin install file:///full/path/to/client-benchmark-noop-api-plugin.zip`
1. Build `client-benchmark-noop-api-plugin` with `./gradlew :client:client-benchmark-noop-api-plugin:assemble`
2. Install it on the target host with `bin/elasticsearch-plugin install file:///full/path/to/client-benchmark-noop-api-plugin.zip`.
3. Start Elasticsearch on the target host (ideally *not* on the machine
that runs the benchmarks)
4. Run the benchmark with
Expand Down Expand Up @@ -49,7 +49,7 @@ The parameters are all in the `'`s and are in order:
Example invocation:

```
gradlew -p client/benchmark run --args ' rest search localhost geonames {"query":{"match_phrase":{"name":"Sankt Georgen"}}} 500,1000,1100,1200'
./gradlew -p client/benchmark run --args ' rest search localhost geonames {"query":{"match_phrase":{"name":"Sankt Georgen"}}} 500,1000,1100,1200'
```

The parameters are in order:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.client;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.ccr.PauseFollowRequest;
import org.elasticsearch.client.core.AcknowledgedResponse;

import java.io.IOException;
import java.util.Collections;

/**
* A wrapper for the {@link RestHighLevelClient} that provides methods for
* accessing the Elastic ccr related methods
* <p>
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-apis.html">
* X-Pack Rollup APIs on elastic.co</a> for more information.
*/
public final class CcrClient {

private final RestHighLevelClient restHighLevelClient;

CcrClient(RestHighLevelClient restHighLevelClient) {
this.restHighLevelClient = restHighLevelClient;
}

/**
* Instructs a follower index the pause the following of a leader index.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse pauseFollow(PauseFollowRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(
request,
CcrRequestConverters::pauseFollow,
options,
AcknowledgedResponse::fromXContent,
Collections.emptySet()
);
}

/**
* Asynchronously instruct a follower index the pause the following of a leader index.
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
* the docs</a> for more.
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
*/
public void pauseFollowAsync(PauseFollowRequest request,
RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(
request,
CcrRequestConverters::pauseFollow,
options,
AcknowledgedResponse::fromXContent,
listener,
Collections.emptySet());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.client;

import org.apache.http.client.methods.HttpPost;
import org.elasticsearch.client.ccr.PauseFollowRequest;

final class CcrRequestConverters {

static Request pauseFollow(PauseFollowRequest pauseFollowRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPart(pauseFollowRequest.getFollowerIndex())
.addPathPartAsIs("_ccr", "pause_follow")
.build();
return new Request(HttpPost.METHOD_NAME, endpoint);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ static Request deleteLifecyclePolicy(DeleteLifecyclePolicyRequest deleteLifecycl
static Request removeIndexLifecyclePolicy(RemoveIndexLifecyclePolicyRequest removePolicyRequest) {
String[] indices = removePolicyRequest.indices() == null ?
Strings.EMPTY_ARRAY : removePolicyRequest.indices().toArray(new String[] {});
Request request = new Request(HttpDelete.METHOD_NAME,
Request request = new Request(HttpPost.METHOD_NAME,
new RequestConverters.EndpointBuilder()
.addCommaSeparatedPathParts(indices)
.addPathPartAsIs("_ilm")
.addPathPartAsIs("_ilm", "remove")
.build());
RequestConverters.Params params = new RequestConverters.Params(request);
params.withIndicesOptions(removePolicyRequest.indicesOptions());
Expand Down
Loading

0 comments on commit ba210cb

Please sign in to comment.