simplify caching in TagsToFile

- PdbFiles no longer require dates to be monotonically
  increasing. Therefore TagsToFile does not have to ensure
  this. => We only have one file per Tags.
- Use EhCache instead of HashMap.
This commit is contained in:
2018-09-30 10:38:25 +02:00
parent d799682b4d
commit ad630fc6b2
5 changed files with 125 additions and 160 deletions

View File

@@ -84,17 +84,17 @@ public class TcpIngestorTest {
@Test
public void testIngestionThreadDoesNotDieOnErrors() throws Exception {
final OffsetDateTime invalidDate = OffsetDateTime.ofInstant(Instant.ofEpochMilli(-1), ZoneOffset.UTC);
final OffsetDateTime dateA = OffsetDateTime.ofInstant(Instant.ofEpochMilli(-1), ZoneOffset.UTC);
final OffsetDateTime dateB = OffsetDateTime.now();
final String host = "someHost";
try (TcpIngestor tcpIngestor = new TcpIngestor(dataDirectory)) {
tcpIngestor.start();
// skipped, because the date is invalid
// has a negative epoch time milli and negative value
final Map<String, Object> entryA = new HashMap<>();
entryA.put("duration", 1);
entryA.put("@timestamp", invalidDate.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
entryA.put("duration", -1);
entryA.put("@timestamp", dateA.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
entryA.put("host", host);
entryA.put("tags", Collections.emptyList());
@@ -109,18 +109,25 @@ public class TcpIngestorTest {
entryB.put("tags", Collections.emptyList());
final ObjectMapper objectMapper = new ObjectMapper();
final String data = objectMapper.writeValueAsString(entryA) + "\n" + corrupEntry + "\n"
+ objectMapper.writeValueAsString(entryB) + "\n";
final String data = String.join("\n", //
objectMapper.writeValueAsString(entryA), //
corrupEntry, //
objectMapper.writeValueAsString(entryB)//
)//
+ "\n";
PdbTestUtil.send(data);
}
try (PerformanceDb db = new PerformanceDb(dataDirectory)) {
final LongList result = db.get("host=" + host).singleGroup().flatMap();
Assert.assertEquals(result.size(), 2);
Assert.assertEquals(result.size(), 4);
Assert.assertEquals(result.get(0), dateB.toInstant().truncatedTo(ChronoUnit.MILLIS).toEpochMilli());
Assert.assertEquals(result.get(1), 2);
Assert.assertEquals(result.get(0), dateA.toInstant().truncatedTo(ChronoUnit.MILLIS).toEpochMilli());
Assert.assertEquals(result.get(1), -1);
Assert.assertEquals(result.get(2), dateB.toInstant().truncatedTo(ChronoUnit.MILLIS).toEpochMilli());
Assert.assertEquals(result.get(3), 2);
}
}
}