Skip to content

Commit

Permalink
Merge remote-tracking branch 'es/master' into lazily_built_indices_lo…
Browse files Browse the repository at this point in the history
…okup2
  • Loading branch information
martijnvg committed Oct 7, 2021
2 parents 0ea5c7e + 67e310e commit e91f474
Show file tree
Hide file tree
Showing 139 changed files with 1,146 additions and 3,414 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def projectPathsToExclude = [

subprojects {
plugins.withType(ElasticsearchJavaPlugin).whenPluginAdded {
if (projectPathsToExclude.contains(project.path) == false) {
if (projectPathsToExclude.contains(project.path) == false ||
providers.systemProperty("es.format.everything").forUseAtConfigurationTime().isPresent()) {
project.apply plugin: "com.diffplug.spotless"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@
import org.gradle.workers.WorkParameters;
import org.gradle.workers.WorkerExecutor;

import javax.inject.Inject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;

/**
* This task wraps up the details of building a Docker image, including adding a pull
* mechanism that can retry, and emitting the image SHA as a task output.
*/
public class DockerBuildTask extends DefaultTask {
private static final Logger LOGGER = Logging.getLogger(DockerBuildTask.class);

Expand Down Expand Up @@ -167,6 +174,8 @@ public void execute() {
parameters.getBaseImages().get().forEach(this::pullBaseImage);
}

final List<String> tags = parameters.getTags().get();

LoggedExec.exec(execOperations, spec -> {
spec.executable("docker");

Expand All @@ -176,17 +185,32 @@ public void execute() {
spec.args("--no-cache");
}

parameters.getTags().get().forEach(tag -> spec.args("--tag", tag));
tags.forEach(tag -> spec.args("--tag", tag));

parameters.getBuildArgs().get().forEach((k, v) -> spec.args("--build-arg", k + "=" + v));
});

// Fetch the Docker image's hash, and write it to desk as the task's output. Doing this allows us
// to do proper up-to-date checks in Gradle.
try {
parameters.getMarkerFile().getAsFile().get().createNewFile();
final String checksum = getImageChecksum(tags.get(0));
Files.writeString(parameters.getMarkerFile().getAsFile().get().toPath(), checksum + "\n");
} catch (IOException e) {
throw new RuntimeException("Failed to create marker file", e);
throw new RuntimeException("Failed to write marker file", e);
}
}

private String getImageChecksum(String imageTag) {
final ByteArrayOutputStream stdout = new ByteArrayOutputStream();

execOperations.exec(spec -> {
spec.setCommandLine("docker", "inspect", "--format", "{{ .Id }}", imageTag);
spec.setStandardOutput(stdout);
spec.setIgnoreExitValue(false);
});

return stdout.toString().trim();
}
}

interface Parameters extends WorkParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Map<String, DatabaseInfo> getDatabases() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("files_in_temp", filesInTemp);
builder.stringListField("files_in_temp", filesInTemp);
builder.field("databases", databases.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(Map.Entry::getValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void setFollowIndexNamePattern(String followIndexNamePattern) {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(PutFollowRequest.REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
builder.field(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
builder.stringListField(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
if (leaderIndexExclusionPatterns.isEmpty() == false) {
builder.field(LEADER_EXCLUSION_PATTERNS_FIELD.getPreferredName(), leaderIndexExclusionPatterns);
builder.stringListField(LEADER_EXCLUSION_PATTERNS_FIELD.getPreferredName(), leaderIndexExclusionPatterns);
}
if (followIndexNamePattern != null) {
builder.field(FOLLOW_PATTERN_FIELD.getPreferredName(), followIndexNamePattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
{
builder.startObject(type);
{
builder.field(NamedPolicy.INDICES_FIELD.getPreferredName(), indices);
builder.stringListField(NamedPolicy.INDICES_FIELD.getPreferredName(), indices);
if (query != null) {
builder.field(NamedPolicy.QUERY_FIELD.getPreferredName(), asMap(query, XContentType.JSON));
}
builder.field(NamedPolicy.MATCH_FIELD_FIELD.getPreferredName(), matchField);
builder.field(NamedPolicy.ENRICH_FIELDS_FIELD.getPreferredName(), enrichFields);
builder.stringListField(NamedPolicy.ENRICH_FIELDS_FIELD.getPreferredName(), enrichFields);
}
builder.endObject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public final PutIndexTemplateRequest masterNodeTimeout(String timeout) {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("index_patterns", indexPatterns);
builder.stringListField("index_patterns", indexPatterns);
builder.field("order", order);
if (version != null) {
builder.field("version", version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Optional<ValidationException> validate() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.array(INDEX.getPreferredName(), indices.toArray());
builder.stringListField(INDEX.getPreferredName(), indices);
if (queryConfig != null) {
builder.field(QUERY.getPreferredName(), queryConfig.getQuery());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.startObject();

if (datafeedIds.isEmpty() == false) {
builder.field(DATAFEED_IDS.getPreferredName(), datafeedIds);
builder.stringListField(DATAFEED_IDS.getPreferredName(), datafeedIds);
}

if (allowNoMatch != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.startObject();

if (jobIds.isEmpty() == false) {
builder.field(JOB_IDS.getPreferredName(), jobIds);
builder.stringListField(JOB_IDS.getPreferredName(), jobIds);
}

if (allowNoMatch != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(MlFilter.DESCRIPTION.getPreferredName(), description);
}
if (addItems != null) {
builder.field(ADD_ITEMS.getPreferredName(), addItems);
builder.stringListField(ADD_ITEMS.getPreferredName(), addItems);
}
if (removeItems != null) {
builder.field(REMOVE_ITEMS.getPreferredName(), removeItems);
builder.stringListField(REMOVE_ITEMS.getPreferredName(), removeItems);
}
builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public String getDescription() {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(ID.getPreferredName(), id);
builder.field(JOB_IDS.getPreferredName(), jobIds);
builder.stringListField(JOB_IDS.getPreferredName(), jobIds);
if (description != null) {
builder.field(DESCRIPTION.getPreferredName(), description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

import org.elasticsearch.client.Validatable;
import org.elasticsearch.client.ValidationException;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.common.xcontent.ParseField;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ParseField;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.joda.time.DateTimeZone;

import java.io.IOException;
import java.time.ZoneId;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
Expand Down Expand Up @@ -179,7 +179,7 @@ public DateHistogramGroupConfig(final String field, final DateHistogramInterval
* The {@code field} and {@code interval} are required to compute the date histogram for the rolled up documents.
* The {@code delay} is optional and can be set to {@code null}. It defines how long to wait before rolling up new documents.
* The {@code timeZone} is optional and can be set to {@code null}. When configured, the time zone value is resolved using
* ({@link DateTimeZone#forID(String)} and must match a time zone identifier provided by the Joda Time library.
* ({@link ZoneId#of(String)} and must match a time zone identifier provided by the Joda Time library.
* </p>
* @param field the name of the date field to use for the date histogram (required)
* @param interval the interval to use for the date histogram (required)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

package org.elasticsearch.client.watcher;

import org.elasticsearch.common.xcontent.ParseField;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.joda.time.DateTime;
import org.elasticsearch.common.xcontent.ParseField;

import java.time.ZonedDateTime;
import java.util.Objects;

public class QueuedWatch {
Expand All @@ -21,8 +21,8 @@ public class QueuedWatch {
new ConstructingObjectParser<>("watcher_stats_node", true, (args, c) -> new QueuedWatch(
(String) args[0],
(String) args[1],
DateTime.parse((String) args[2]),
DateTime.parse((String) args[3])
ZonedDateTime.parse((String) args[2]),
ZonedDateTime.parse((String) args[3])
));

static {
Expand All @@ -35,10 +35,10 @@ public class QueuedWatch {

private final String watchId;
private final String watchRecordId;
private final DateTime triggeredTime;
private final DateTime executionTime;
private final ZonedDateTime triggeredTime;
private final ZonedDateTime executionTime;

public QueuedWatch(String watchId, String watchRecordId, DateTime triggeredTime, DateTime executionTime) {
public QueuedWatch(String watchId, String watchRecordId, ZonedDateTime triggeredTime, ZonedDateTime executionTime) {
this.watchId = watchId;
this.watchRecordId = watchRecordId;
this.triggeredTime = triggeredTime;
Expand All @@ -53,11 +53,11 @@ public String getWatchRecordId() {
return watchRecordId;
}

public DateTime getTriggeredTime() {
public ZonedDateTime getTriggeredTime() {
return triggeredTime;
}

public DateTime getExecutionTime() {
public ZonedDateTime getExecutionTime() {
return executionTime;
}

Expand Down
Loading

0 comments on commit e91f474

Please sign in to comment.