[ML] Add check to prevent NoSuchElementException (elastic/x-pack-elasticsearch#1147)
Original commit: elastic/x-pack-elasticsearch@dca4020734
This commit is contained in:
parent
f9b8c82137
commit
a11e52fea2
|
@ -81,7 +81,9 @@ public class DataStreamDiagnostics {
|
||||||
*/
|
*/
|
||||||
public void flush() {
|
public void flush() {
|
||||||
// flush all we know
|
// flush all we know
|
||||||
flush(movingBucketHistogram.lastKey() + 1);
|
if (movingBucketHistogram.isEmpty() == false) {
|
||||||
|
flush(movingBucketHistogram.lastKey() + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -259,6 +259,12 @@ public class DataStreamDiagnosticsTests extends ESTestCase {
|
||||||
assertEquals(null, d.getLatestEmptyBucketTime());
|
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) {
|
private void sendManyDataPoints(DataStreamDiagnostics d, long recordTimestampInMsMin, long recordTimestampInMsMax, long howMuch) {
|
||||||
|
|
||||||
long range = recordTimestampInMsMax - recordTimestampInMsMin;
|
long range = recordTimestampInMsMax - recordTimestampInMsMin;
|
||||||
|
|
Loading…
Reference in New Issue