From b646abd12cb0d85e84aa723292d7ab3970c05be5 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 27 Mar 2018 12:58:26 -0600 Subject: [PATCH] Adjust to XContentBuilder decoupling (elastic/x-pack-elasticsearch#4212) This is the x-pack side of https://github.com/elastic/elasticsearch/pull/29225 where some methods were renamed or take different arguments. Original commit: elastic/x-pack-elasticsearch@525e118381db61fd54704773fe588b3f44915dc5 --- .../main/java/org/elasticsearch/license/License.java | 6 +++--- .../org/elasticsearch/license/XPackInfoResponse.java | 2 +- .../xpack/core/ml/action/FlushJobAction.java | 2 +- .../xpack/core/ml/calendars/ScheduledEvent.java | 4 ++-- .../elasticsearch/xpack/core/ml/job/config/Job.java | 6 +++--- .../autodetect/output/FlushAcknowledgement.java | 2 +- .../ml/job/process/autodetect/state/DataCounts.java | 10 +++++----- .../job/process/autodetect/state/ModelSizeStats.java | 4 ++-- .../ml/job/process/autodetect/state/ModelSnapshot.java | 6 +++--- .../xpack/core/ml/job/results/AnomalyRecord.java | 2 +- .../xpack/core/ml/job/results/Bucket.java | 2 +- .../xpack/core/ml/job/results/BucketInfluencer.java | 2 +- .../xpack/core/ml/job/results/Forecast.java | 2 +- .../xpack/core/ml/job/results/Influencer.java | 2 +- .../xpack/core/ml/job/results/ModelPlot.java | 2 +- .../xpack/core/ml/job/results/OverallBucket.java | 2 +- .../xpack/core/ssl/cert/CertificateInfo.java | 2 +- .../xpack/core/watcher/actions/ActionStatus.java | 6 +++--- .../xpack/core/watcher/execution/QueuedWatch.java | 4 ++-- .../core/watcher/execution/WatchExecutionSnapshot.java | 4 ++-- .../xpack/core/watcher/watch/WatchStatus.java | 4 ++-- .../process/autodetect/AutodetectProcessManager.java | 5 +++-- .../xpack/security/audit/index/IndexAuditTrail.java | 2 +- .../xpack/watcher/notification/email/Email.java | 2 +- 24 files changed, 43 insertions(+), 42 deletions(-) diff --git a/plugin/core/src/main/java/org/elasticsearch/license/License.java b/plugin/core/src/main/java/org/elasticsearch/license/License.java index f1658e8942a..df94a9132a0 100644 --- a/plugin/core/src/main/java/org/elasticsearch/license/License.java +++ b/plugin/core/src/main/java/org/elasticsearch/license/License.java @@ -393,13 +393,13 @@ public class License implements ToXContentObject { if (version == VERSION_START) { builder.field(Fields.SUBSCRIPTION_TYPE, subscriptionType); } - builder.dateField(Fields.ISSUE_DATE_IN_MILLIS, Fields.ISSUE_DATE, issueDate); + builder.timeField(Fields.ISSUE_DATE_IN_MILLIS, Fields.ISSUE_DATE, issueDate); if (version == VERSION_START) { builder.field(Fields.FEATURE, feature); } if (expiryDate != LicenseService.BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS) { - builder.dateField(Fields.EXPIRY_DATE_IN_MILLIS, Fields.EXPIRY_DATE, expiryDate); + builder.timeField(Fields.EXPIRY_DATE_IN_MILLIS, Fields.EXPIRY_DATE, expiryDate); } builder.field(Fields.MAX_NODES, maxNodes); builder.field(Fields.ISSUED_TO, issuedTo); @@ -411,7 +411,7 @@ public class License implements ToXContentObject { builder.humanReadable(previouslyHumanReadable); } if (version >= VERSION_START_DATE) { - builder.dateField(Fields.START_DATE_IN_MILLIS, Fields.START_DATE, startDate); + builder.timeField(Fields.START_DATE_IN_MILLIS, Fields.START_DATE, startDate); } return builder; } diff --git a/plugin/core/src/main/java/org/elasticsearch/license/XPackInfoResponse.java b/plugin/core/src/main/java/org/elasticsearch/license/XPackInfoResponse.java index 0ad69728f46..7c288634547 100644 --- a/plugin/core/src/main/java/org/elasticsearch/license/XPackInfoResponse.java +++ b/plugin/core/src/main/java/org/elasticsearch/license/XPackInfoResponse.java @@ -128,7 +128,7 @@ public class XPackInfoResponse extends ActionResponse { .field("type", type) .field("mode", mode) .field("status", status.label()) - .dateField("expiry_date_in_millis", "expiry_date", expiryDate) + .timeField("expiry_date_in_millis", "expiry_date", expiryDate) .endObject(); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FlushJobAction.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FlushJobAction.java index ab02a258be1..2da2505a771 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FlushJobAction.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FlushJobAction.java @@ -246,7 +246,7 @@ public class FlushJobAction extends Action implements Writeable, ToXContentO if (description != null) { builder.field(DESCRIPTION.getPreferredName(), description); } - builder.dateField(CREATE_TIME.getPreferredName(), CREATE_TIME.getPreferredName() + humanReadableSuffix, createTime.getTime()); + builder.timeField(CREATE_TIME.getPreferredName(), CREATE_TIME.getPreferredName() + humanReadableSuffix, createTime.getTime()); if (finishedTime != null) { - builder.dateField(FINISHED_TIME.getPreferredName(), FINISHED_TIME.getPreferredName() + humanReadableSuffix, + builder.timeField(FINISHED_TIME.getPreferredName(), FINISHED_TIME.getPreferredName() + humanReadableSuffix, finishedTime.getTime()); } if (lastDataTime != null) { - builder.dateField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + humanReadableSuffix, + builder.timeField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + humanReadableSuffix, lastDataTime.getTime()); } if (establishedModelMemory != null) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/output/FlushAcknowledgement.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/output/FlushAcknowledgement.java index 8f61c10f6d6..77615603f1f 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/output/FlushAcknowledgement.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/output/FlushAcknowledgement.java @@ -84,7 +84,7 @@ public class FlushAcknowledgement implements ToXContentObject, Writeable { builder.startObject(); builder.field(ID.getPreferredName(), id); if (lastFinalizedBucketEnd != null) { - builder.dateField(LAST_FINALIZED_BUCKET_END.getPreferredName(), LAST_FINALIZED_BUCKET_END.getPreferredName() + "_string", + builder.timeField(LAST_FINALIZED_BUCKET_END.getPreferredName(), LAST_FINALIZED_BUCKET_END.getPreferredName() + "_string", lastFinalizedBucketEnd.getTime()); } builder.endObject(); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java index 37bc7e14099..7c461340c38 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/DataCounts.java @@ -576,23 +576,23 @@ public class DataCounts implements ToXContentObject, Writeable { builder.field(SPARSE_BUCKET_COUNT.getPreferredName(), sparseBucketCount); builder.field(BUCKET_COUNT.getPreferredName(), bucketCount); if (earliestRecordTimeStamp != null) { - builder.dateField(EARLIEST_RECORD_TIME.getPreferredName(), EARLIEST_RECORD_TIME.getPreferredName() + "_string", + builder.timeField(EARLIEST_RECORD_TIME.getPreferredName(), EARLIEST_RECORD_TIME.getPreferredName() + "_string", earliestRecordTimeStamp.getTime()); } if (latestRecordTimeStamp != null) { - builder.dateField(LATEST_RECORD_TIME.getPreferredName(), LATEST_RECORD_TIME.getPreferredName() + "_string", + builder.timeField(LATEST_RECORD_TIME.getPreferredName(), LATEST_RECORD_TIME.getPreferredName() + "_string", latestRecordTimeStamp.getTime()); } if (lastDataTimeStamp != null) { - builder.dateField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + "_string", + builder.timeField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + "_string", lastDataTimeStamp.getTime()); } if (latestEmptyBucketTimeStamp != null) { - builder.dateField(LATEST_EMPTY_BUCKET_TIME.getPreferredName(), LATEST_EMPTY_BUCKET_TIME.getPreferredName() + "_string", + builder.timeField(LATEST_EMPTY_BUCKET_TIME.getPreferredName(), LATEST_EMPTY_BUCKET_TIME.getPreferredName() + "_string", latestEmptyBucketTimeStamp.getTime()); } if (latestSparseBucketTimeStamp != null) { - builder.dateField(LATEST_SPARSE_BUCKET_TIME.getPreferredName(), LATEST_SPARSE_BUCKET_TIME.getPreferredName() + "_string", + builder.timeField(LATEST_SPARSE_BUCKET_TIME.getPreferredName(), LATEST_SPARSE_BUCKET_TIME.getPreferredName() + "_string", latestSparseBucketTimeStamp.getTime()); } builder.field(INPUT_RECORD_COUNT.getPreferredName(), getInputRecordCount()); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java index fa30f12454c..80429e0c3da 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java @@ -184,9 +184,9 @@ public class ModelSizeStats implements ToXContentObject, Writeable { builder.field(TOTAL_PARTITION_FIELD_COUNT_FIELD.getPreferredName(), totalPartitionFieldCount); builder.field(BUCKET_ALLOCATION_FAILURES_COUNT_FIELD.getPreferredName(), bucketAllocationFailuresCount); builder.field(MEMORY_STATUS_FIELD.getPreferredName(), memoryStatus); - builder.dateField(LOG_TIME_FIELD.getPreferredName(), LOG_TIME_FIELD.getPreferredName() + "_string", logTime.getTime()); + builder.timeField(LOG_TIME_FIELD.getPreferredName(), LOG_TIME_FIELD.getPreferredName() + "_string", logTime.getTime()); if (timestamp != null) { - builder.dateField(TIMESTAMP_FIELD.getPreferredName(), TIMESTAMP_FIELD.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(TIMESTAMP_FIELD.getPreferredName(), TIMESTAMP_FIELD.getPreferredName() + "_string", timestamp.getTime()); } return builder; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java index a7e3cc9b9ec..1bcb503fdc7 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java @@ -187,7 +187,7 @@ public class ModelSnapshot implements ToXContentObject, Writeable { builder.field(Job.ID.getPreferredName(), jobId); builder.field(MIN_VERSION.getPreferredName(), minVersion); if (timestamp != null) { - builder.dateField(TIMESTAMP.getPreferredName(), TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(TIMESTAMP.getPreferredName(), TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); } if (description != null) { builder.field(DESCRIPTION.getPreferredName(), description); @@ -200,11 +200,11 @@ public class ModelSnapshot implements ToXContentObject, Writeable { builder.field(ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName(), modelSizeStats); } if (latestRecordTimeStamp != null) { - builder.dateField(LATEST_RECORD_TIME.getPreferredName(), LATEST_RECORD_TIME.getPreferredName() + "_string", + builder.timeField(LATEST_RECORD_TIME.getPreferredName(), LATEST_RECORD_TIME.getPreferredName() + "_string", latestRecordTimeStamp.getTime()); } if (latestResultTimeStamp != null) { - builder.dateField(LATEST_RESULT_TIME.getPreferredName(), LATEST_RESULT_TIME.getPreferredName() + "_string", + builder.timeField(LATEST_RESULT_TIME.getPreferredName(), LATEST_RESULT_TIME.getPreferredName() + "_string", latestResultTimeStamp.getTime()); } if (quantiles != null) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java index 189c11f8ca3..1689f4f5dd6 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecord.java @@ -255,7 +255,7 @@ public class AnomalyRecord implements ToXContentObject, Writeable { builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(Detector.DETECTOR_INDEX.getPreferredName(), detectorIndex); builder.field(Result.IS_INTERIM.getPreferredName(), isInterim); - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); if (byFieldName != null) { builder.field(BY_FIELD_NAME.getPreferredName(), byFieldName); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java index cc395afc6ba..2dc9110ac30 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java @@ -181,7 +181,7 @@ public class Bucket implements ToXContentObject, Writeable { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(JOB_ID.getPreferredName(), jobId); - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); builder.field(ANOMALY_SCORE.getPreferredName(), anomalyScore); builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(INITIAL_ANOMALY_SCORE.getPreferredName(), initialAnomalyScore); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/BucketInfluencer.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/BucketInfluencer.java index ae665c9c8b0..fa8236d2352 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/BucketInfluencer.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/BucketInfluencer.java @@ -140,7 +140,7 @@ public class BucketInfluencer implements ToXContentObject, Writeable { builder.field(ANOMALY_SCORE.getPreferredName(), anomalyScore); builder.field(RAW_ANOMALY_SCORE.getPreferredName(), rawAnomalyScore); builder.field(PROBABILITY.getPreferredName(), probability); - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(Result.IS_INTERIM.getPreferredName(), isInterim); return builder; diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Forecast.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Forecast.java index f0e85b687b2..634c8455c31 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Forecast.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Forecast.java @@ -136,7 +136,7 @@ public class Forecast implements ToXContentObject, Writeable { builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(DETECTOR_INDEX.getPreferredName(), detectorIndex); if (timestamp != null) { - builder.dateField(Result.TIMESTAMP.getPreferredName(), + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); } if (partitionFieldName != null) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influencer.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influencer.java index ba37a08b536..fcb512a3e2a 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influencer.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influencer.java @@ -143,7 +143,7 @@ public class Influencer implements ToXContentObject, Writeable { builder.field(PROBABILITY.getPreferredName(), probability); builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(Result.IS_INTERIM.getPreferredName(), isInterim); - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); return builder; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ModelPlot.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ModelPlot.java index 31d5a59f079..5834102fcde 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ModelPlot.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ModelPlot.java @@ -202,7 +202,7 @@ public class ModelPlot implements ToXContentObject, Writeable { builder.field(DETECTOR_INDEX.getPreferredName(), detectorIndex); if (timestamp != null) { - builder.dateField(Result.TIMESTAMP.getPreferredName(), + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); } if (partitionFieldName != null) { diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java index c1bd37f386c..075001a76b1 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/OverallBucket.java @@ -70,7 +70,7 @@ public class OverallBucket implements ToXContentObject, Writeable { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); + builder.timeField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan); builder.field(OVERALL_SCORE.getPreferredName(), overallScore); builder.field(JOBS.getPreferredName(), jobs); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/cert/CertificateInfo.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/cert/CertificateInfo.java index d19a9909ab8..cb05a678863 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/cert/CertificateInfo.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/cert/CertificateInfo.java @@ -98,7 +98,7 @@ public class CertificateInfo implements ToXContentObject, Writeable { .field("subject_dn", subjectDn) .field("serial_number", serialNumber) .field("has_private_key", hasPrivateKey) - .field("expiry", expiry) + .timeField("expiry", expiry) .endObject(); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionStatus.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionStatus.java index 6eb937e1d97..fb397b8f09a 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionStatus.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionStatus.java @@ -244,7 +244,7 @@ public class ActionStatus implements ToXContentObject { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return builder.startObject() - .field(Field.TIMESTAMP.getPreferredName()).value(timestamp, dateTimeFormatter.printer()) + .field(Field.TIMESTAMP.getPreferredName()).value(dateTimeFormatter.printer().print(timestamp)) .field(Field.ACK_STATUS_STATE.getPreferredName(), state.name().toLowerCase(Locale.ROOT)) .endObject(); } @@ -342,7 +342,7 @@ public class ActionStatus implements ToXContentObject { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - builder.field(Field.TIMESTAMP.getPreferredName()).value(timestamp, dateTimeFormatter.printer()); + builder.field(Field.TIMESTAMP.getPreferredName()).value(dateTimeFormatter.printer().print(timestamp)); builder.field(Field.EXECUTION_SUCCESSFUL.getPreferredName(), successful); if (reason != null) { builder.field(Field.REASON.getPreferredName(), reason); @@ -442,7 +442,7 @@ public class ActionStatus implements ToXContentObject { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return builder.startObject() - .field(Field.TIMESTAMP.getPreferredName()).value(timestamp, dateTimeFormatter.printer()) + .field(Field.TIMESTAMP.getPreferredName()).value(dateTimeFormatter.printer().print(timestamp)) .field(Field.REASON.getPreferredName(), reason) .endObject(); } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/QueuedWatch.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/QueuedWatch.java index bd4e66dd7cf..b6b67057769 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/QueuedWatch.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/QueuedWatch.java @@ -73,8 +73,8 @@ public class QueuedWatch implements Streamable, ToXContentObject { builder.startObject(); builder.field("watch_id", watchId); builder.field("watch_record_id", watchRecordId); - builder.field("triggered_time", triggeredTime); - builder.field("execution_time", executionTime); + builder.timeField("triggered_time", triggeredTime); + builder.timeField("execution_time", executionTime); builder.endObject(); return builder; } diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/WatchExecutionSnapshot.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/WatchExecutionSnapshot.java index 4d2b87a3a5e..986011d3520 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/WatchExecutionSnapshot.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/WatchExecutionSnapshot.java @@ -110,8 +110,8 @@ public class WatchExecutionSnapshot implements Streamable, ToXContentObject { builder.startObject(); builder.field("watch_id", watchId); builder.field("watch_record_id", watchRecordId); - builder.field("triggered_time", triggeredTime); - builder.field("execution_time", executionTime); + builder.timeField("triggered_time", triggeredTime); + builder.timeField("execution_time", executionTime); builder.field("execution_phase", phase); if (executedActions != null) { builder.startArray("executed_actions"); diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/WatchStatus.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/WatchStatus.java index 114dfd2994d..69d114bd2b0 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/WatchStatus.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/WatchStatus.java @@ -250,10 +250,10 @@ public class WatchStatus implements ToXContentObject, Streamable { builder.field(Field.STATE.getPreferredName(), state, params); } if (lastChecked != null) { - builder.field(Field.LAST_CHECKED.getPreferredName(), lastChecked); + builder.timeField(Field.LAST_CHECKED.getPreferredName(), lastChecked); } if (lastMetCondition != null) { - builder.field(Field.LAST_MET_CONDITION.getPreferredName(), lastMetCondition); + builder.timeField(Field.LAST_MET_CONDITION.getPreferredName(), lastMetCondition); } if (actions != null) { builder.startObject(Field.ACTIONS.getPreferredName()); diff --git a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java index 1f4f83025b5..613f1f967aa 100644 --- a/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java +++ b/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.ml.job.process.autodetect; +import org.elasticsearch.common.xcontent.XContentElasticsearchExtension; import org.elasticsearch.core.internal.io.IOUtils; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; @@ -448,13 +449,13 @@ public class AutodetectProcessManager extends AbstractComponent { msgBuilder.append("] with latest_record_timestamp ["); Date snapshotLatestRecordTimestamp = modelSnapshot.getLatestRecordTimeStamp(); msgBuilder.append(snapshotLatestRecordTimestamp == null ? "N/A" : - XContentBuilder.DEFAULT_DATE_PRINTER.print( + XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print( snapshotLatestRecordTimestamp.getTime())); } msgBuilder.append("], job latest_record_timestamp ["); Date jobLatestRecordTimestamp = autodetectParams.dataCounts().getLatestRecordTimeStamp(); msgBuilder.append(jobLatestRecordTimestamp == null ? "N/A" - : XContentBuilder.DEFAULT_DATE_PRINTER.print(jobLatestRecordTimestamp.getTime())); + : XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(jobLatestRecordTimestamp.getTime())); msgBuilder.append("]"); String msg = msgBuilder.toString(); logger.info("[{}] {}", jobId, msg); diff --git a/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java index de5efb042ed..e16a09c8a2a 100644 --- a/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java +++ b/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/index/IndexAuditTrail.java @@ -1149,7 +1149,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail { Message start() throws IOException { builder.startObject(); - builder.field(Field.TIMESTAMP, timestamp); + builder.timeField(Field.TIMESTAMP, timestamp); return this; } diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java index df1e9c7ea06..fcf3030233f 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/Email.java @@ -128,7 +128,7 @@ public class Email implements ToXContentObject { if (priority != null) { builder.field(Field.PRIORITY.getPreferredName(), priority.value()); } - builder.field(Field.SENT_DATE.getPreferredName(), sentDate); + builder.timeField(Field.SENT_DATE.getPreferredName(), sentDate); if (to != null) { builder.field(Field.TO.getPreferredName(), to, params); }