Skip to content

Commit

Permalink
Merge branch 'master' into compile-with-jdk-9
Browse files Browse the repository at this point in the history
* master:
  Use Gradle wrapper when building BWC
  Painless: Add a simple cache for whitelist methods and fields. (elastic#28142)
  Fix upgrading indices which use a custom similarity plugin. (elastic#26985)
  Fix Licenses values for CDDL and Custom URL (elastic#27999)
  Cleanup TcpChannelFactory and remove classes (elastic#28102)
  Fix expected plugins test for transport-nio
  [Docs] Fix Date Math example descriptions (elastic#28125)
  Fail rollover if duplicated alias found in template (elastic#28110)
  Avoid concurrent snapshot finalizations when deleting an INIT snapshot (elastic#28078)
  Deprecate `isShardsAcked()` in favour of `isShardsAcknowledged()` (elastic#27819)
  [TEST] Wait for replicas to be allocated before shrinking
  Use the underlying connection version for CCS connections  (elastic#28093)
  test: do not use asn fields
  Test: Add assumeFalse for test that cannot pass on windows
  Clarify reproduce info on Windows
  Remove out-of-date projectile file
  • Loading branch information
jasontedor committed Jan 9, 2018
2 parents c295dfa + a85772c commit 4af4f89
Show file tree
Hide file tree
Showing 46 changed files with 470 additions and 312 deletions.
31 changes: 0 additions & 31 deletions .projectile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class DependenciesInfoTask extends DefaultTask {
* <u>
* <li><em>UNKNOWN</em> if LICENSE file is not present for this dependency.</li>
* <li><em>one SPDX identifier</em> if the LICENSE content matches with an SPDX license.</li>
* <li><em>Custom:URL</em> if it's not an SPDX license,
* <li><em>Custom;URL</em> if it's not an SPDX license,
* URL is the Github URL to the LICENSE file in elasticsearch repository.</li>
* </ul>
*
Expand Down Expand Up @@ -116,7 +116,7 @@ public class DependenciesInfoTask extends DefaultTask {
// As we have the license file, we create a Custom entry with the URL to this license file.
final gitBranch = System.getProperty('build.branch', 'master')
final String githubBaseURL = "https://raw.githubusercontent.com/elastic/elasticsearch/${gitBranch}/"
return "Custom:${license.getCanonicalPath().replaceFirst('.*/elasticsearch/', githubBaseURL)}"
return "Custom;${license.getCanonicalPath().replaceFirst('.*/elasticsearch/', githubBaseURL)}"
}
return spdx
} else {
Expand Down Expand Up @@ -156,10 +156,10 @@ public class DependenciesInfoTask extends DefaultTask {
spdx = 'LGPL-3.0'
break
case ~/.*${CDDL_1_0}.*/:
spdx = 'CDDL_1_0'
spdx = 'CDDL-1.0'
break
case ~/.*${CDDL_1_1}.*/:
spdx = 'CDDL_1_1'
spdx = 'CDDL-1.1'
break
case ~/.*${ICU}.*/:
spdx = 'ICU'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.elasticsearch.gradle.vagrant

import com.carrotsearch.gradle.junit4.RandomizedTestingPlugin
import org.apache.tools.ant.taskdefs.condition.Os
import org.elasticsearch.gradle.FileContentsTask
import org.gradle.api.*
import org.gradle.api.artifacts.dsl.RepositoryHandler
Expand Down Expand Up @@ -343,8 +344,9 @@ class VagrantTestPlugin implements Plugin<Project> {
TaskExecutionAdapter packagingReproListener = new TaskExecutionAdapter() {
@Override
void afterExecute(Task task, TaskState state) {
final String gradlew = Os.isFamily(Os.FAMILY_WINDOWS) ? "gradlew" : "./gradlew"
if (state.failure != null) {
println "REPRODUCE WITH: ./gradlew ${packaging.path} " +
println "REPRODUCE WITH: ${gradlew} ${packaging.path} " +
"-Dtests.seed=${project.testSeed} "
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ public void testCreateIndex() throws IOException {

// tag::create-index-response
boolean acknowledged = createIndexResponse.isAcknowledged(); // <1>
boolean shardsAcked = createIndexResponse.isShardsAcked(); // <2>
boolean shardsAcknowledged = createIndexResponse.isShardsAcknowledged(); // <2>
// end::create-index-response
assertTrue(acknowledged);
assertTrue(shardsAcked);
assertTrue(shardsAcknowledged);
}
}

Expand All @@ -202,7 +202,6 @@ public void testCreateIndexAsync() throws Exception {

{
CreateIndexRequest request = new CreateIndexRequest("twitter");

// tag::create-index-execute-async
client.indices().createIndexAsync(request, new ActionListener<CreateIndexResponse>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public ActiveShardCount waitForActiveShards() {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link CreateIndexResponse#isShardsAcked()} to
* to be active before returning. Check {@link CreateIndexResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public CreateIndexRequestBuilder setUpdateAllTypes(boolean updateAllTypes) {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link CreateIndexResponse#isShardsAcked()} to
* to be active before returning. Check {@link CreateIndexResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ public class CreateIndexResponse extends AcknowledgedResponse implements ToXCont
PARSER.declareField(constructorArg(), (parser, context) -> parser.text(), INDEX, ObjectParser.ValueType.STRING);
}

private boolean shardsAcked;
private boolean shardsAcknowledged;
private String index;

protected CreateIndexResponse() {
}

protected CreateIndexResponse(boolean acknowledged, boolean shardsAcked, String index) {
protected CreateIndexResponse(boolean acknowledged, boolean shardsAcknowledged, String index) {
super(acknowledged);
assert acknowledged || shardsAcked == false; // if its not acknowledged, then shards acked should be false too
this.shardsAcked = shardsAcked;
assert acknowledged || shardsAcknowledged == false; // if its not acknowledged, then shardsAcknowledged should be false too
this.shardsAcknowledged = shardsAcknowledged;
this.index = index;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
readAcknowledged(in);
shardsAcked = in.readBoolean();
shardsAcknowledged = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_5_6_0)) {
index = in.readString();
}
Expand All @@ -79,27 +79,39 @@ public void readFrom(StreamInput in) throws IOException {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
writeAcknowledged(out);
out.writeBoolean(shardsAcked);
out.writeBoolean(shardsAcknowledged);
if (out.getVersion().onOrAfter(Version.V_5_6_0)) {
out.writeString(index);
}
}

/**
* Returns true if the requisite number of shards were started before
* returning from the index creation operation. If {@link #isAcknowledged()}
* returning from the index creation operation. If {@link #isAcknowledged()}
* is false, then this also returns false.
*
* @deprecated use {@link #isShardsAcknowledged()}
*/
@Deprecated
public boolean isShardsAcked() {
return shardsAcked;
return shardsAcknowledged;
}

/**
* Returns true if the requisite number of shards were started before
* returning from the index creation operation. If {@link #isAcknowledged()}
* is false, then this also returns false.
*/
public boolean isShardsAcknowledged() {
return shardsAcknowledged;
}

public String index() {
return index;
}

public void addCustomFields(XContentBuilder builder) throws IOException {
builder.field(SHARDS_ACKNOWLEDGED.getPreferredName(), isShardsAcked());
builder.field(SHARDS_ACKNOWLEDGED.getPreferredName(), isShardsAcknowledged());
builder.field(INDEX.getPreferredName(), index());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void masterOperation(final CreateIndexRequest request, final ClusterSt
.waitForActiveShards(request.waitForActiveShards());

createIndexService.createIndex(updateRequest, ActionListener.wrap(response ->
listener.onResponse(new CreateIndexResponse(response.isAcknowledged(), response.isShardsAcked(), indexName)),
listener.onResponse(new CreateIndexResponse(response.isAcknowledged(), response.isShardsAcknowledged(), indexName)),
listener::onFailure));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ CreateIndexRequest getCreateIndexRequest() {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link RolloverResponse#isShardsAcked()} to
* to be active before returning. Check {@link RolloverResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public RolloverRequestBuilder mapping(String type, String source) {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link RolloverResponse#isShardsAcked()} to
* to be active before returning. Check {@link RolloverResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ public final class RolloverResponse extends ActionResponse implements ToXContent
private boolean dryRun;
private boolean rolledOver;
private boolean acknowledged;
private boolean shardsAcked;
private boolean shardsAcknowledged;

RolloverResponse() {
}

RolloverResponse(String oldIndex, String newIndex, Set<Condition.Result> conditionResults,
boolean dryRun, boolean rolledOver, boolean acknowledged, boolean shardsAcked) {
boolean dryRun, boolean rolledOver, boolean acknowledged, boolean shardsAcknowledged) {
this.oldIndex = oldIndex;
this.newIndex = newIndex;
this.dryRun = dryRun;
this.rolledOver = rolledOver;
this.acknowledged = acknowledged;
this.shardsAcked = shardsAcked;
this.shardsAcknowledged = shardsAcknowledged;
this.conditionStatus = conditionResults.stream()
.map(result -> new AbstractMap.SimpleEntry<>(result.condition.toString(), result.matched))
.collect(Collectors.toSet());
Expand Down Expand Up @@ -105,19 +105,31 @@ public boolean isRolledOver() {
* Returns true if the creation of the new rollover index and switching of the
* alias to the newly created index was successful, and returns false otherwise.
* If {@link #isDryRun()} is true, then this will also return false. If this
* returns false, then {@link #isShardsAcked()} will also return false.
* returns false, then {@link #isShardsAcknowledged()} will also return false.
*/
public boolean isAcknowledged() {
return acknowledged;
}

/**
* Returns true if the requisite number of shards were started in the newly
* created rollover index before returning. If {@link #isAcknowledged()} is
* created rollover index before returning. If {@link #isAcknowledged()} is
* false, then this will also return false.
*
* @deprecated use {@link #isShardsAcknowledged()}
*/
@Deprecated
public boolean isShardsAcked() {
return shardsAcked;
return shardsAcknowledged;
}

/**
* Returns true if the requisite number of shards were started in the newly
* created rollover index before returning. If {@link #isAcknowledged()} is
* false, then this will also return false.
*/
public boolean isShardsAcknowledged() {
return shardsAcknowledged;
}

@Override
Expand All @@ -136,7 +148,7 @@ public void readFrom(StreamInput in) throws IOException {
dryRun = in.readBoolean();
rolledOver = in.readBoolean();
acknowledged = in.readBoolean();
shardsAcked = in.readBoolean();
shardsAcknowledged = in.readBoolean();
}

@Override
Expand All @@ -152,7 +164,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(dryRun);
out.writeBoolean(rolledOver);
out.writeBoolean(acknowledged);
out.writeBoolean(shardsAcked);
out.writeBoolean(shardsAcknowledged);
}

@Override
Expand All @@ -163,7 +175,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(ROLLED_OVER, rolledOver);
builder.field(DRY_RUN, dryRun);
builder.field(ACKNOWLEDGED, acknowledged);
builder.field(SHARDS_ACKED, shardsAcked);
builder.field(SHARDS_ACKED, shardsAcknowledged);
builder.startObject(CONDITIONS);
for (Map.Entry<String, Boolean> entry : conditionStatus) {
builder.field(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
import org.elasticsearch.cluster.metadata.AliasOrIndex;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
import org.elasticsearch.cluster.metadata.MetaDataIndexAliasesService;
import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -115,6 +117,7 @@ protected void masterOperation(final RolloverRequest rolloverRequest, final Clus
: generateRolloverIndexName(sourceProvidedName, indexNameExpressionResolver);
final String rolloverIndexName = indexNameExpressionResolver.resolveDateMathExpression(unresolvedName);
MetaDataCreateIndexService.validateIndexName(rolloverIndexName, state); // will fail if the index already exists
checkNoDuplicatedAliasInIndexTemplate(metaData, rolloverIndexName, rolloverRequest.getAlias());
client.admin().indices().prepareStats(sourceIndexName).clear().setDocs(true).execute(
new ActionListener<IndicesStatsResponse>() {
@Override
Expand All @@ -140,8 +143,9 @@ public void onResponse(IndicesStatsResponse statsResponse) {
activeShardsObserver.waitForActiveShards(new String[]{rolloverIndexName},
rolloverRequest.getCreateIndexRequest().waitForActiveShards(),
rolloverRequest.masterNodeTimeout(),
isShardsAcked -> listener.onResponse(new RolloverResponse(sourceIndexName, rolloverIndexName,
conditionResults, false, true, true, isShardsAcked)),
isShardsAcknowledged -> listener.onResponse(new RolloverResponse(
sourceIndexName, rolloverIndexName, conditionResults, false, true, true,
isShardsAcknowledged)),
listener::onFailure);
} else {
listener.onResponse(new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults,
Expand Down Expand Up @@ -237,4 +241,19 @@ static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest(final Stri
.mappings(createIndexRequest.mappings());
}

/**
* If the newly created index matches with an index template whose aliases contains the rollover alias,
* the rollover alias will point to multiple indices. This causes indexing requests to be rejected.
* To avoid this, we make sure that there is no duplicated alias in index templates before creating a new index.
*/
static void checkNoDuplicatedAliasInIndexTemplate(MetaData metaData, String rolloverIndexName, String rolloverRequestAlias) {
final List<IndexTemplateMetaData> matchedTemplates = MetaDataIndexTemplateService.findTemplates(metaData, rolloverIndexName);
for (IndexTemplateMetaData template : matchedTemplates) {
if (template.aliases().containsKey(rolloverRequestAlias)) {
throw new IllegalArgumentException(String.format(Locale.ROOT,
"Rollover alias [%s] can point to multiple indices, found duplicated alias [%s] in index template [%s]",
rolloverRequestAlias, template.aliases().keys(), template.name()));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public String getSourceIndex() {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link ResizeResponse#isShardsAcked()} to
* to be active before returning. Check {@link ResizeResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ResizeRequestBuilder setSettings(Settings settings) {
* non-negative integer, up to the number of copies per shard (number of replicas + 1),
* to wait for the desired amount of shard copies to become active before returning.
* Index creation will only wait up until the timeout value for the number of shard copies
* to be active before returning. Check {@link ResizeResponse#isShardsAcked()} to
* to be active before returning. Check {@link ResizeResponse#isShardsAcknowledged()} to
* determine if the requisite shard copies were all started before returning or timing out.
*
* @param waitForActiveShards number of active shard copies to wait on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class ResizeResponse extends CreateIndexResponse {
ResizeResponse() {
}

ResizeResponse(boolean acknowledged, boolean shardsAcked, String index) {
super(acknowledged, shardsAcked, index);
ResizeResponse(boolean acknowledged, boolean shardsAcknowledged, String index) {
super(acknowledged, shardsAcknowledged, index);
}
}
Loading

0 comments on commit 4af4f89

Please sign in to comment.