From 7d377a5b7f852f4f3dc5b4c99db9c66f1e543738 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Mon, 14 Mar 2016 16:25:00 +0100 Subject: [PATCH] Fix LocalIndicesCleanerTests Original commit: elastic/x-pack-elasticsearch@3e08c84e80f40e0f306f7c100db2e77a817fb968 --- .../resolver/MonitoringIndexNameResolver.java | 14 ++++++++------ .../cleaner/AbstractIndicesCleanerTestCase.java | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/resolver/MonitoringIndexNameResolver.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/resolver/MonitoringIndexNameResolver.java index c0c058aa55e..ac742fd9dca 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/resolver/MonitoringIndexNameResolver.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/resolver/MonitoringIndexNameResolver.java @@ -156,12 +156,14 @@ public abstract class MonitoringIndexNameResolver { public static final Setting INDEX_NAME_TIME_FORMAT_SETTING = new Setting<>("index.name.time_format","YYYY.MM.dd", Function.identity(), Setting.Property.NodeScope); - private final MonitoredSystem id; + private final MonitoredSystem system; private final DateTimeFormatter formatter; + private final String index; - public Timestamped(MonitoredSystem id, int version, Settings settings) { + public Timestamped(MonitoredSystem system, int version, Settings settings) { super(version); - this.id = id; + this.system = system; + this.index = String.join(DELIMITER, PREFIX, system.getSystem(), String.valueOf(getVersion())); String format = INDEX_NAME_TIME_FORMAT_SETTING.get(settings); try { this.formatter = DateTimeFormat.forPattern(format).withZoneUTC(); @@ -172,12 +174,12 @@ public abstract class MonitoringIndexNameResolver { @Override public String index(T document) { - return String.join(DELIMITER, PREFIX, id.getSystem(), String.valueOf(getVersion()), formatter.print(document.getTimestamp())); + return String.join(DELIMITER, index, formatter.print(document.getTimestamp())); } @Override public String indexPattern() { - return String.join(DELIMITER, PREFIX, "*", String.valueOf(getVersion()), "*"); + return String.join(DELIMITER, index, "*"); } @Override @@ -187,7 +189,7 @@ public abstract class MonitoringIndexNameResolver { } String getId() { - return id.getSystem(); + return system.getSystem(); } } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java index d70d3243de2..522c520de43 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java @@ -233,8 +233,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MarvelIntegTestCase MonitoringDoc monitoringDoc = randomMonitoringDoc(); monitoringDoc.setTimestamp(creationDate.getMillis()); - MonitoringIndexNameResolver.Timestamped resolver = new MockTimestampedIndexNameResolver(randomFrom(MonitoredSystem.values()), - version); + MonitoringIndexNameResolver.Timestamped resolver = new MockTimestampedIndexNameResolver(MonitoredSystem.ES, version); createIndex(resolver.index(monitoringDoc), creationDate); }