-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Core: Migrating from joda to java.time. Monitoring plugin #36297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
93541a7
Joda to java-time migration in Monitoring
pgomulka 83c024c
Merge branch 'master' into feature/monitoring
pgomulka 438ce82
remove todo
pgomulka 4cdcbf8
reverting empty lines
pgomulka 40b47a6
revert back to prev rev
pgomulka 19aff93
Update RestSqlTranslateAction.java
pgomulka 7130b85
remove uneeded changes
pgomulka 0850175
Merge branch 'master' into feature/monitoring
pgomulka 41da102
code review follow up
pgomulka dac6924
checkstyle fix
pgomulka 2e7f180
Merge branch 'master' into feature/monitoring
pgomulka 1c2d553
Merge branch 'master' into feature/monitoring
pgomulka 88f56bc
static field in test cleanup
pgomulka 9272269
Merge branch 'master' into feature/monitoring
pgomulka 33cd6dd
fix the exporter index pattern
pgomulka 1e1198f
small cleanup after review
pgomulka ab9032a
Merge branch 'master' into feature/monitoring
pgomulka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,10 +11,10 @@ | |
| import org.elasticsearch.common.settings.Setting.Property; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.settings.SettingsException; | ||
| import org.elasticsearch.common.time.DateFormatter; | ||
| import org.elasticsearch.license.XPackLicenseState; | ||
| import org.joda.time.format.DateTimeFormat; | ||
| import org.joda.time.format.DateTimeFormatter; | ||
|
|
||
| import java.time.ZoneOffset; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
@@ -70,7 +70,7 @@ public abstract class Exporter implements AutoCloseable { | |
| Setting.affixKeySetting("xpack.monitoring.exporters.","index.name.time_format", | ||
| key -> Setting.simpleString(key, Property.Dynamic, Property.NodeScope)); | ||
|
|
||
| private static final String INDEX_FORMAT = "YYYY.MM.dd"; | ||
| private static final String INDEX_FORMAT = "yyyy.MM.dd"; | ||
|
|
||
| protected final Config config; | ||
|
|
||
|
|
@@ -113,11 +113,11 @@ public void close() { | |
|
|
||
| protected abstract void doClose(); | ||
|
|
||
| protected static DateTimeFormatter dateTimeFormatter(final Config config) { | ||
| protected static DateFormatter dateTimeFormatter(final Config config) { | ||
| Setting<String> setting = INDEX_NAME_TIME_FORMAT_SETTING.getConcreteSettingForNamespace(config.name); | ||
| String format = setting.exists(config.settings()) ? setting.get(config.settings()) : INDEX_FORMAT; | ||
| try { | ||
| return DateTimeFormat.forPattern(format).withZoneUTC(); | ||
| return DateFormatter.forPattern(format).withZone(ZoneOffset.UTC); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also requires a change in 6.7, otherwise users using outdated formats will not be warned if they do so, as this uses the joda time API directly |
||
| } catch (IllegalArgumentException e) { | ||
| throw new SettingsException("[" + INDEX_NAME_TIME_FORMAT_SETTING.getKey() + "] invalid index name time format: [" | ||
| + format + "]", e); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
joda toString:
Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).when java-time
{@code 2007-12-03T10:15:30+01:00[Europe/Paris]}.but it also says:
The output is compatible with ISO-8601 if the offset and ID are the same.The quick test for sample long shows that the format is the same
Instant.ofEpochMilli(123).atZone(ZoneOffset.UTC).toString()new DateTime(123, DateTimeZone.UTC).toString();1970-01-01T00:00:00.123ZThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this more explicit and not rely on the
toString()method of classes we dont have control over (even though I assume this does not get changed) Using astrict_date_timeformatter might just work as expected?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work fine - the pattern is the same