[ML] Add check to prevent NoSuchElementException (elastic/x-pack-elasticsearch#1147)

Original commit: elastic/x-pack-elasticsearch@dca4020734
This commit is contained in:
David Kyle 2017-04-20 18:10:32 +01:00 committed by GitHub
parent f9b8c82137
commit a11e52fea2
2 changed files with 9 additions and 1 deletions

View File

@ -81,8 +81,10 @@ public class DataStreamDiagnostics {
*/
public void flush() {
// flush all we know
if (movingBucketHistogram.isEmpty() == false) {
flush(movingBucketHistogram.lastKey() + 1);
}
}
/**
* Check bucketing of record. Report empty and sparse buckets.

View File

@ -259,6 +259,12 @@ public class DataStreamDiagnosticsTests extends ESTestCase {
assertEquals(null, d.getLatestEmptyBucketTime());
}
public void testFlushAfterZeroRecords() {
DataStreamDiagnostics d = new DataStreamDiagnostics(job);
d.flush();
assertEquals(0, d.getBucketCount());
}
private void sendManyDataPoints(DataStreamDiagnostics d, long recordTimestampInMsMin, long recordTimestampInMsMax, long howMuch) {
long range = recordTimestampInMsMax - recordTimestampInMsMin;