Skip to content

Commit

Permalink
Merge branch 'master' into global-checkpoint-polling
Browse files Browse the repository at this point in the history
* master: (24 commits)
  Only notify ready global checkpoint listeners (elastic#33690)
  Don't count hits via the collector if the hit count can be computed from index stats. (elastic#33701)
  Expose retries for CCR fetch failures (elastic#33694)
  Test fix - Graph vertices could appear in different orders based on map insertion sequence (elastic#33709)
  Structured audit logging (elastic#31931)
  Core: Add DateFormatter interface for java time parsing (elastic#33467)
  [CCR] Check whether the rejected execution exception has the shutdown flag set (elastic#33703)
  Mute ClusterDisruptionIT#testSendingShardFailure
  Revert "Mute FullClusterRestartSettingsUpgradeIT"
  Adjust BWC version on settings upgrade test (elastic#33650)
  [ML] Allow overrides for some file structure detection decisions (elastic#33630)
  Adapt skip version for doc_values format deprecation
  [TEST] wait for no initializing shards
  [Docs] Minor fix in `has_child` javadoc comment (elastic#33674)
  Mute FullClusterRestartSettingsUpgradeIT
  [Kerberos] Add realm name & UPN to user metadata (elastic#33338)
  [TESTS] Disable specific locales for RestrictedTrustManagerTest (elastic#33299)
  SQL: Return functions in JDBC driver metadata (elastic#33672)
  SCRIPTING: Move terms_set Context to its Own Class (elastic#33602)
  AwaitsFix testRestoreMinmal
  ...
  • Loading branch information
jasontedor committed Sep 14, 2018
2 parents 426b359 + 3919133 commit 828b61c
Show file tree
Hide file tree
Showing 120 changed files with 4,516 additions and 2,039 deletions.
6 changes: 6 additions & 0 deletions docs/reference/migration/migrate_7_0/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ depending on whether {security} is enabled. Previously a
404 - NOT FOUND (IndexNotFoundException) could be returned in case the
current user was not authorized for any alias. An empty response with
status 200 - OK is now returned instead at all times.

==== Put User API response no longer has `user` object

The Put User API response was changed in 6.5.0 to add the `created` field
outside of the user object where it previously had been. In 7.0.0 the user
object has been removed in favor of the top level `created` field.
2 changes: 1 addition & 1 deletion docs/reference/sql/endpoints/client-apps/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[[sql-client-apps]]
== SQL Client Applications

Thanks to its <<sql-jdbc, JDBC>> interface, {es-sql} supports a broad range of applications.
Thanks to its <<sql-jdbc, JDBC>> interface, a broad range of third-party applications can use {es}'s SQL capabilities.
This section lists, in alphabetical order, a number of them and their respective configuration - the list however is by no means comprehensive (feel free to https://www.elastic.co/blog/art-of-pull-request[submit a PR] to improve it):
as long as the app can use the {es-sql} driver, it can use {es-sql}.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ public ScoreMode scoreMode() {

/**
* Returns the minimum number of children that are required to match for the parent to be considered a match.
* The default is {@value #DEFAULT_MAX_CHILDREN}
* The default is {@value #DEFAULT_MIN_CHILDREN}
*/
public int minChildren() {
return minChildren;
}

/**
* Returns the maximum number of children that are required to match for the parent to be considered a match.
* The default is {@value #DEFAULT_MIN_CHILDREN}
* The default is {@value #DEFAULT_MAX_CHILDREN}
*/
public int maxChildren() { return maxChildren; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
public class FullClusterRestartSettingsUpgradeIT extends AbstractFullClusterRestartTestCase {

public void testRemoteClusterSettingsUpgraded() throws IOException {
assumeTrue("skip_unavailable did not exist until 6.1.0", getOldClusterVersion().onOrAfter(Version.V_6_1_0));
assumeTrue("settings automatically upgraded since 6.5.0", getOldClusterVersion().before(Version.V_6_5_0));
if (isRunningAgainstOldCluster()) {
final Request putSettingsRequest = new Request("PUT", "/_cluster/settings");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ setup:
---
"docvalue_fields":
- skip:
version: " - 6.3.99"
reason: format option was added in 6.4
version: " - 6.4.0"
reason: format option was added in 6.4 and the deprecation message changed in 6.4.1
features: warnings
- do:
warnings:
Expand All @@ -148,8 +148,8 @@ setup:
---
"multiple docvalue_fields":
- skip:
version: " - 6.3.99"
reason: format option was added in 6.4
version: " - 6.4.0"
reason: format option was added in 6.4 and the deprecation message changed in 6.4.1
features: warnings
- do:
warnings:
Expand All @@ -162,8 +162,8 @@ setup:
---
"docvalue_fields as url param":
- skip:
version: " - 6.3.99"
reason: format option was added in 6.4
version: " - 6.4.0"
reason: format option was added in 6.4 and the deprecation message changed in 6.4.1
features: warnings
- do:
warnings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.CompoundDateTimeFormatter;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;
import org.elasticsearch.common.xcontent.ContextParser;
import org.elasticsearch.common.xcontent.ObjectParser;
Expand Down Expand Up @@ -368,8 +368,7 @@ public static final class Tombstone implements ToXContentObject, Writeable {
TOMBSTONE_PARSER.declareString((b, s) -> {}, new ParseField(DELETE_DATE_KEY));
}

static final CompoundDateTimeFormatter FORMATTER =
DateFormatters.forPattern("strict_date_optional_time").withZone(ZoneOffset.UTC);
static final DateFormatter FORMATTER = DateFormatters.forPattern("strict_date_optional_time").withZone(ZoneOffset.UTC);

static ContextParser<Void, Tombstone> getParser() {
return (parser, context) -> TOMBSTONE_PARSER.apply(parser, null).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.CompoundDateTimeFormatter;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContentFragment;
Expand All @@ -48,8 +48,7 @@
*/
public final class UnassignedInfo implements ToXContentFragment, Writeable {

public static final CompoundDateTimeFormatter DATE_TIME_FORMATTER =
DateFormatters.forPattern("dateOptionalTime").withZone(ZoneOffset.UTC);
public static final DateFormatter DATE_TIME_FORMATTER = DateFormatters.forPattern("dateOptionalTime").withZone(ZoneOffset.UTC);

public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING =
Setting.positiveTimeSetting("index.unassigned.node_left.delayed_timeout", TimeValue.timeValueMinutes(1), Property.Dynamic,
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/common/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.common;

import org.elasticsearch.common.time.CompoundDateTimeFormatter;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;

import java.time.Instant;
Expand Down Expand Up @@ -85,7 +85,7 @@ public Table endHeaders() {
return this;
}

private static final CompoundDateTimeFormatter FORMATTER = DateFormatters.forPattern("HH:mm:ss").withZone(ZoneOffset.UTC);
private static final DateFormatter FORMATTER = DateFormatters.forPattern("HH:mm:ss").withZone(ZoneOffset.UTC);

public Table startRow() {
if (headers.isEmpty()) {
Expand Down
133 changes: 133 additions & 0 deletions server/src/main/java/org/elasticsearch/common/time/DateFormatter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* 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.common.time;

import java.time.ZoneId;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public interface DateFormatter {

/**
* Try to parse input to a java time TemporalAccessor
* @param input An arbitrary string resembling the string representation of a date or time
* @throws DateTimeParseException If parsing fails, this exception will be thrown.
* Note that it can contained suppressed exceptions when several formatters failed parse this value
* @return The java time object containing the parsed input
*/
TemporalAccessor parse(String input);

/**
* Create a copy of this formatter that is configured to parse dates in the specified time zone
*
* @param zoneId The time zone to act on
* @return A copy of the date formatter this has been called on
*/
DateFormatter withZone(ZoneId zoneId);

/**
* Print the supplied java time accessor in a string based representation according to this formatter
*
* @param accessor The temporal accessor used to format
* @return The string result for the formatting
*/
String format(TemporalAccessor accessor);

/**
* A name based format for this formatter. Can be one of the registered formatters like <code>epoch_millis</code> or
* a configured format like <code>HH:mm:ss</code>
*
* @return The name of this formatter
*/
String pattern();

/**
* Configure a formatter using default fields for a TemporalAccessor that should be used in case
* the supplied date is not having all of those fields
*
* @param fields A <code>Map&lt;TemporalField, Long&gt;</code> of fields to be used as fallbacks
* @return A new date formatter instance, that will use those fields during parsing
*/
DateFormatter parseDefaulting(Map<TemporalField, Long> fields);

/**
* Merge several date formatters into a single one. Useful if you need to have several formatters with
* different formats act as one, for example when you specify a
* format like <code>date_hour||epoch_millis</code>
*
* @param formatters The list of date formatters to be merged together
* @return The new date formtter containing the specified date formatters
*/
static DateFormatter merge(DateFormatter ... formatters) {
return new MergedDateFormatter(formatters);
}

class MergedDateFormatter implements DateFormatter {

private final String format;
private final DateFormatter[] formatters;

MergedDateFormatter(DateFormatter ... formatters) {
this.formatters = formatters;
this.format = Arrays.stream(formatters).map(DateFormatter::pattern).collect(Collectors.joining("||"));
}

@Override
public TemporalAccessor parse(String input) {
DateTimeParseException failure = null;
for (DateFormatter formatter : formatters) {
try {
return formatter.parse(input);
} catch (DateTimeParseException e) {
if (failure == null) {
failure = e;
} else {
failure.addSuppressed(e);
}
}
}
throw failure;
}

@Override
public DateFormatter withZone(ZoneId zoneId) {
return new MergedDateFormatter(Arrays.stream(formatters).map(f -> f.withZone(zoneId)).toArray(DateFormatter[]::new));
}

@Override
public String format(TemporalAccessor accessor) {
return formatters[0].format(accessor);
}

@Override
public String pattern() {
return format;
}

@Override
public DateFormatter parseDefaulting(Map<TemporalField, Long> fields) {
return new MergedDateFormatter(Arrays.stream(formatters).map(f -> f.parseDefaulting(fields)).toArray(DateFormatter[]::new));
}
}
}
Loading

0 comments on commit 828b61c

Please sign in to comment.