Skip to content

Commit ee69c4b

Browse files
committed
Merge branch 'master' of github.com:elastic/elasticsearch into zendisco2
2 parents 4380c3d + c93cc1b commit ee69c4b

File tree

313 files changed

+9506
-2024
lines changed

Some content is hidden

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

313 files changed

+9506
-2024
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ subprojects {
196196
"org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
197197
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
198198
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
199+
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
199200
]
200201

201202
for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import java.util.regex.Matcher
2929
class VersionCollection {
3030

3131
private final List<Version> versions
32+
private final boolean buildSnapshot = System.getProperty("build.snapshot", "true") == "true"
3233

3334
/**
3435
* Construct a VersionCollection from the lines of the Version.java file.
@@ -63,7 +64,10 @@ class VersionCollection {
6364
throw new GradleException("Unexpectedly found no version constants in Versions.java");
6465
}
6566

66-
// The tip of each minor series (>= 5.6) is unreleased, so set their 'snapshot' flags
67+
/*
68+
* The tip of each minor series (>= 5.6) is unreleased, so they must be built from source (we set branch to non-null), and we set
69+
* the snapshot flag if and only if build.snapshot is true.
70+
*/
6771
Version prevConsideredVersion = null
6872
boolean found6xSnapshot = false
6973
for (final int versionIndex = versions.size() - 1; versionIndex >= 0; versionIndex--) {
@@ -85,7 +89,7 @@ class VersionCollection {
8589

8690
versions[versionIndex] = new Version(
8791
currConsideredVersion.major, currConsideredVersion.minor,
88-
currConsideredVersion.revision, currConsideredVersion.suffix, true, branch)
92+
currConsideredVersion.revision, currConsideredVersion.suffix, buildSnapshot, branch)
8993
}
9094

9195
if (currConsideredVersion.onOrBefore("5.6.0")) {
@@ -95,12 +99,6 @@ class VersionCollection {
9599
prevConsideredVersion = currConsideredVersion
96100
}
97101

98-
// If we're making a release build then the current should not be a snapshot after all.
99-
final boolean currentIsSnapshot = "true" == System.getProperty("build.snapshot", "true")
100-
if (false == currentIsSnapshot) {
101-
versions[-1] = new Version(versions[-1].major, versions[-1].minor, versions[-1].revision, versions[-1].suffix, false, null)
102-
}
103-
104102
this.versions = Collections.unmodifiableList(versions)
105103
}
106104

@@ -137,7 +135,7 @@ class VersionCollection {
137135
private Version getLastSnapshotWithMajor(int targetMajor) {
138136
final String currentVersion = currentVersion.toString()
139137
final int snapshotIndex = versions.findLastIndexOf {
140-
it.major == targetMajor && it.before(currentVersion) && it.snapshot
138+
it.major == targetMajor && it.before(currentVersion) && it.snapshot == buildSnapshot
141139
}
142140
return snapshotIndex == -1 ? null : versions[snapshotIndex]
143141
}

client/rest-high-level/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies {
3939
compile "org.elasticsearch.client:elasticsearch-rest-client:${version}"
4040
compile "org.elasticsearch.plugin:parent-join-client:${version}"
4141
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
42+
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
4243

4344
testCompile "org.elasticsearch.client:test:${version}"
4445
testCompile "org.elasticsearch.test:framework:${version}"
@@ -60,4 +61,4 @@ forbiddenApisMain {
6061
// specified
6162
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
6263
signaturesURLs += [file('src/main/resources/forbidden/rest-high-level-signatures.txt').toURI().toURL()]
63-
}
64+
}

client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@
2121

2222
import com.fasterxml.jackson.core.JsonParseException;
2323

24-
import org.elasticsearch.Build;
25-
import org.elasticsearch.ElasticsearchException;
26-
import org.elasticsearch.Version;
27-
import org.elasticsearch.action.ActionListener;
28-
import org.elasticsearch.action.ActionRequest;
29-
import org.elasticsearch.action.ActionRequestValidationException;
30-
import org.elasticsearch.action.main.MainRequest;
31-
import org.elasticsearch.action.main.MainResponse;
32-
import org.elasticsearch.action.search.ClearScrollRequest;
33-
import org.elasticsearch.action.search.ClearScrollResponse;
34-
import org.elasticsearch.action.search.SearchResponse;
35-
import org.elasticsearch.action.search.SearchResponseSections;
36-
import org.elasticsearch.action.search.SearchScrollRequest;
37-
import org.elasticsearch.action.search.ShardSearchFailure;
3824
import org.apache.http.Header;
3925
import org.apache.http.HttpEntity;
4026
import org.apache.http.HttpHost;
@@ -49,6 +35,20 @@
4935
import org.apache.http.message.BasicRequestLine;
5036
import org.apache.http.message.BasicStatusLine;
5137
import org.apache.http.nio.entity.NStringEntity;
38+
import org.elasticsearch.Build;
39+
import org.elasticsearch.ElasticsearchException;
40+
import org.elasticsearch.Version;
41+
import org.elasticsearch.action.ActionListener;
42+
import org.elasticsearch.action.ActionRequest;
43+
import org.elasticsearch.action.ActionRequestValidationException;
44+
import org.elasticsearch.action.main.MainRequest;
45+
import org.elasticsearch.action.main.MainResponse;
46+
import org.elasticsearch.action.search.ClearScrollRequest;
47+
import org.elasticsearch.action.search.ClearScrollResponse;
48+
import org.elasticsearch.action.search.SearchResponse;
49+
import org.elasticsearch.action.search.SearchResponseSections;
50+
import org.elasticsearch.action.search.SearchScrollRequest;
51+
import org.elasticsearch.action.search.ShardSearchFailure;
5252
import org.elasticsearch.cluster.ClusterName;
5353
import org.elasticsearch.common.CheckedFunction;
5454
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
@@ -57,6 +57,10 @@
5757
import org.elasticsearch.common.xcontent.XContentParser;
5858
import org.elasticsearch.common.xcontent.cbor.CborXContent;
5959
import org.elasticsearch.common.xcontent.smile.SmileXContent;
60+
import org.elasticsearch.index.rankeval.DiscountedCumulativeGain;
61+
import org.elasticsearch.index.rankeval.EvaluationMetric;
62+
import org.elasticsearch.index.rankeval.MeanReciprocalRank;
63+
import org.elasticsearch.index.rankeval.PrecisionAtK;
6064
import org.elasticsearch.join.aggregations.ChildrenAggregationBuilder;
6165
import org.elasticsearch.rest.RestStatus;
6266
import org.elasticsearch.search.SearchHits;
@@ -648,7 +652,7 @@ public void testDefaultNamedXContents() {
648652

649653
public void testProvidedNamedXContents() {
650654
List<NamedXContentRegistry.Entry> namedXContents = RestHighLevelClient.getProvidedNamedXContents();
651-
assertEquals(2, namedXContents.size());
655+
assertEquals(5, namedXContents.size());
652656
Map<Class<?>, Integer> categories = new HashMap<>();
653657
List<String> names = new ArrayList<>();
654658
for (NamedXContentRegistry.Entry namedXContent : namedXContents) {
@@ -658,10 +662,14 @@ public void testProvidedNamedXContents() {
658662
categories.put(namedXContent.categoryClass, counter + 1);
659663
}
660664
}
661-
assertEquals(1, categories.size());
665+
assertEquals(2, categories.size());
662666
assertEquals(Integer.valueOf(2), categories.get(Aggregation.class));
663667
assertTrue(names.contains(ChildrenAggregationBuilder.NAME));
664668
assertTrue(names.contains(MatrixStatsAggregationBuilder.NAME));
669+
assertEquals(Integer.valueOf(3), categories.get(EvaluationMetric.class));
670+
assertTrue(names.contains(PrecisionAtK.NAME));
671+
assertTrue(names.contains(DiscountedCumulativeGain.NAME));
672+
assertTrue(names.contains(MeanReciprocalRank.NAME));
665673
}
666674

667675
private static class TrackingActionListener implements ActionListener<Integer> {

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MigrationDocumentationIT.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.action.ActionListener;
2727
import org.elasticsearch.action.delete.DeleteRequest;
2828
import org.elasticsearch.action.delete.DeleteResponse;
29+
import org.elasticsearch.action.get.GetRequest;
2930
import org.elasticsearch.action.index.IndexRequest;
3031
import org.elasticsearch.action.index.IndexResponse;
3132
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
@@ -43,6 +44,7 @@
4344
import java.util.Map;
4445

4546
import static java.util.Collections.emptyMap;
47+
import static java.util.Collections.singletonMap;
4648
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
4749
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
4850

@@ -67,7 +69,7 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
6769
public void testCreateIndex() throws IOException {
6870
RestHighLevelClient client = highLevelClient();
6971
{
70-
//tag::migration-create-inded
72+
//tag::migration-create-index
7173
Settings indexSettings = Settings.builder() // <1>
7274
.put(SETTING_NUMBER_OF_SHARDS, 1)
7375
.put(SETTING_NUMBER_OF_REPLICAS, 0)
@@ -95,7 +97,7 @@ public void testCreateIndex() throws IOException {
9597
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
9698
// <7>
9799
}
98-
//end::migration-create-inded
100+
//end::migration-create-index
99101
assertEquals(200, response.getStatusLine().getStatusCode());
100102
}
101103
}
@@ -104,7 +106,8 @@ public void testClusterHealth() throws IOException {
104106
RestHighLevelClient client = highLevelClient();
105107
{
106108
//tag::migration-cluster-health
107-
Response response = client.getLowLevelClient().performRequest("GET", "/_cluster/health"); // <1>
109+
Map<String, String> parameters = singletonMap("wait_for_status", "green");
110+
Response response = client.getLowLevelClient().performRequest("GET", "/_cluster/health", parameters); // <1>
108111

109112
ClusterHealthStatus healthStatus;
110113
try (InputStream is = response.getEntity().getContent()) { // <2>
@@ -120,7 +123,7 @@ public void testClusterHealth() throws IOException {
120123
}
121124
}
122125

123-
public void testRequests() throws IOException {
126+
public void testRequests() throws Exception {
124127
RestHighLevelClient client = highLevelClient();
125128
{
126129
//tag::migration-request-ctor
@@ -133,13 +136,6 @@ public void testRequests() throws IOException {
133136
//end::migration-request-ctor-execution
134137
assertEquals(RestStatus.CREATED, response.status());
135138
}
136-
{
137-
//tag::migration-request-sync-execution
138-
DeleteRequest request = new DeleteRequest("index", "doc", "id");
139-
DeleteResponse response = client.delete(request); // <1>
140-
//end::migration-request-sync-execution
141-
assertEquals(RestStatus.OK, response.status());
142-
}
143139
{
144140
//tag::migration-request-async-execution
145141
DeleteRequest request = new DeleteRequest("index", "doc", "id"); // <1>
@@ -155,6 +151,14 @@ public void onFailure(Exception e) {
155151
}
156152
});
157153
//end::migration-request-async-execution
154+
assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "doc", "id"))));
155+
}
156+
{
157+
//tag::migration-request-sync-execution
158+
DeleteRequest request = new DeleteRequest("index", "doc", "id");
159+
DeleteResponse response = client.delete(request); // <1>
160+
//end::migration-request-sync-execution
161+
assertEquals(RestStatus.NOT_FOUND, response.status());
158162
}
159163
}
160164
}

client/rest/src/test/java/org/elasticsearch/client/FailureTrackingResponseListenerTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public void testOnSuccess() {
4141
MockResponseListener responseListener = new MockResponseListener();
4242
RestClient.FailureTrackingResponseListener listener = new RestClient.FailureTrackingResponseListener(responseListener);
4343

44+
final Response response = mockResponse();
45+
listener.onSuccess(response);
46+
assertSame(response, responseListener.response.get());
47+
assertNull(responseListener.exception.get());
4448
}
4549

4650
public void testOnFailure() {

client/transport/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
3333
compile "org.elasticsearch.plugin:percolator-client:${version}"
3434
compile "org.elasticsearch.plugin:parent-join-client:${version}"
35+
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
3536
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
3637
testCompile "junit:junit:${versions.junit}"
3738
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
@@ -54,4 +55,4 @@ namingConventions {
5455
testClass = 'com.carrotsearch.randomizedtesting.RandomizedTest'
5556
//we don't have integration tests
5657
skipIntegTestInDisguise = true
57-
}
58+
}

core/src/main/java/org/elasticsearch/Version.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ public class Version implements Comparable<Version> {
138138
new Version(V_6_0_2_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
139139
public static final int V_6_1_0_ID = 6010099;
140140
public static final Version V_6_1_0 = new Version(V_6_1_0_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
141+
public static final int V_6_1_1_ID = 6010199;
142+
public static final Version V_6_1_1 = new Version(V_6_1_1_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
141143
public static final int V_6_2_0_ID = 6020099;
142144
public static final Version V_6_2_0 = new Version(V_6_2_0_ID, org.apache.lucene.util.Version.LUCENE_7_2_0);
143145
public static final int V_7_0_0_alpha1_ID = 7000001;
@@ -158,10 +160,12 @@ public static Version fromId(int id) {
158160
switch (id) {
159161
case V_7_0_0_alpha1_ID:
160162
return V_7_0_0_alpha1;
161-
case V_6_1_0_ID:
162-
return V_6_1_0;
163163
case V_6_2_0_ID:
164164
return V_6_2_0;
165+
case V_6_1_1_ID:
166+
return V_6_1_1;
167+
case V_6_1_0_ID:
168+
return V_6_1_0;
165169
case V_6_0_2_ID:
166170
return V_6_0_2;
167171
case V_6_0_1_ID:

core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public static Builder builder(BiConsumer<BulkRequest, ActionListener<BulkRespons
185185

186186
private BulkRequest bulkRequest;
187187
private final BulkRequestHandler bulkRequestHandler;
188-
private final Scheduler scheduler;
189188
private final Runnable onClose;
190189

191190
private volatile boolean closed = false;
@@ -196,7 +195,6 @@ public static Builder builder(BiConsumer<BulkRequest, ActionListener<BulkRespons
196195
this.bulkActions = bulkActions;
197196
this.bulkSize = bulkSize.getBytes();
198197
this.bulkRequest = new BulkRequest();
199-
this.scheduler = scheduler;
200198
this.bulkRequestHandler = new BulkRequestHandler(consumer, backoffPolicy, listener, scheduler, concurrentRequests);
201199
// Start period flushing task after everything is setup
202200
this.cancellableFlushTask = startFlushTask(flushInterval, scheduler);

core/src/main/java/org/elasticsearch/action/get/TransportGetAction.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.elasticsearch.action.support.ActionFilters;
2525
import org.elasticsearch.action.support.single.shard.TransportSingleShardAction;
2626
import org.elasticsearch.cluster.ClusterState;
27-
import org.elasticsearch.cluster.metadata.IndexMetaData;
2827
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
2928
import org.elasticsearch.cluster.routing.ShardIterator;
3029
import org.elasticsearch.cluster.service.ClusterService;
@@ -69,7 +68,6 @@ protected ShardIterator shards(ClusterState state, InternalRequest request) {
6968

7069
@Override
7170
protected void resolveRequest(ClusterState state, InternalRequest request) {
72-
IndexMetaData indexMeta = state.getMetaData().index(request.concreteIndex());
7371
// update the routing (request#index here is possibly an alias)
7472
request.request().routing(state.metaData().resolveIndexRouting(request.request().parent(), request.request().routing(), request.request().index()));
7573
// Fail fast on the node that received the request.

core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
import org.elasticsearch.monitor.jvm.JvmInfo;
4747
import org.elasticsearch.monitor.os.OsProbe;
4848
import org.elasticsearch.monitor.process.ProcessProbe;
49+
import org.elasticsearch.node.InternalSettingsPreparer;
4950
import org.elasticsearch.node.Node;
5051
import org.elasticsearch.node.NodeValidationException;
51-
import org.elasticsearch.node.InternalSettingsPreparer;
5252

5353
import java.io.ByteArrayOutputStream;
5454
import java.io.IOException;
@@ -57,8 +57,8 @@
5757
import java.net.URISyntaxException;
5858
import java.nio.file.Path;
5959
import java.security.NoSuchAlgorithmException;
60-
import java.util.List;
6160
import java.util.Collections;
61+
import java.util.List;
6262
import java.util.concurrent.CountDownLatch;
6363

6464
/**
@@ -239,7 +239,6 @@ static SecureSettings loadSecureSettings(Environment initialEnv) throws Bootstra
239239
}
240240

241241
private static Environment createEnvironment(
242-
final boolean foreground,
243242
final Path pidFile,
244243
final SecureSettings secureSettings,
245244
final Settings initialSettings,
@@ -283,7 +282,7 @@ static void init(
283282
INSTANCE = new Bootstrap();
284283

285284
final SecureSettings keystore = loadSecureSettings(initialEnv);
286-
final Environment environment = createEnvironment(foreground, pidFile, keystore, initialEnv.settings(), initialEnv.configFile());
285+
final Environment environment = createEnvironment(pidFile, keystore, initialEnv.settings(), initialEnv.configFile());
287286
try {
288287
LogConfigurator.configure(environment);
289288
} catch (IOException e) {

core/src/main/java/org/elasticsearch/cluster/ClusterModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider;
5555
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
5656
import org.elasticsearch.cluster.routing.allocation.decider.SnapshotInProgressAllocationDecider;
57+
import org.elasticsearch.cluster.routing.allocation.decider.RestoreInProgressAllocationDecider;
5758
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
5859
import org.elasticsearch.cluster.service.ClusterService;
5960
import org.elasticsearch.common.ParseField;
@@ -191,6 +192,7 @@ public static Collection<AllocationDecider> createAllocationDeciders(Settings se
191192
addAllocationDecider(deciders, new EnableAllocationDecider(settings, clusterSettings));
192193
addAllocationDecider(deciders, new NodeVersionAllocationDecider(settings));
193194
addAllocationDecider(deciders, new SnapshotInProgressAllocationDecider(settings));
195+
addAllocationDecider(deciders, new RestoreInProgressAllocationDecider(settings));
194196
addAllocationDecider(deciders, new FilterAllocationDecider(settings, clusterSettings));
195197
addAllocationDecider(deciders, new SameShardAllocationDecider(settings, clusterSettings));
196198
addAllocationDecider(deciders, new DiskThresholdDecider(settings, clusterSettings));

core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ private ClusterState applyRequest(ClusterState currentState, PutMappingClusterSt
293293
}
294294
assert mappingType != null;
295295

296-
if (!MapperService.DEFAULT_MAPPING.equals(mappingType) && mappingType.charAt(0) == '_') {
296+
if (MapperService.DEFAULT_MAPPING.equals(mappingType) == false
297+
&& MapperService.SINGLE_MAPPING_NAME.equals(mappingType) == false
298+
&& mappingType.charAt(0) == '_') {
297299
throw new InvalidTypeNameException("Document mapping type name can't start with '_', found: [" + mappingType + "]");
298300
}
299301
MetaData.Builder builder = MetaData.builder(metaData);

0 commit comments

Comments
 (0)