Use snapshot's latest result time rather than snapshot's creation time when creating an annotation (#56093) (#56103)

This commit is contained in:
Przemysław Witek 2020-05-04 12:36:12 +02:00 committed by GitHub
parent e197b6c45b
commit 44f5a8ccd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View File

@ -89,6 +89,10 @@ public class ModelSnapshot implements ToXContentObject, Writeable {
*/
private final Version minVersion;
/**
* This is model snapshot's creation wall clock time.
* Use {@code latestResultTimeStamp} if you need model time instead.
*/
private final Date timestamp;
private final String description;
private final String snapshotId;

View File

@ -332,8 +332,8 @@ public class AutodetectResultProcessor {
Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_STORED, modelSnapshot.getSnapshotId()),
currentTime,
XPackUser.NAME,
modelSnapshot.getTimestamp(),
modelSnapshot.getTimestamp(),
modelSnapshot.getLatestResultTimeStamp(),
modelSnapshot.getLatestResultTimeStamp(),
jobId,
currentTime,
XPackUser.NAME,

View File

@ -482,7 +482,8 @@ public class AutodetectResultProcessorIT extends MlSingleNodeTestCase {
private static ModelSnapshot createModelSnapshot() {
return new ModelSnapshot.Builder(JOB_ID)
.setSnapshotId(randomAlphaOfLength(12))
.setTimestamp(Date.from(Instant.ofEpochMilli(1000000000)))
.setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000)))
.setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000)))
.build();
}

View File

@ -365,7 +365,8 @@ public class AutodetectResultProcessorTests extends ESTestCase {
AutodetectResult result = mock(AutodetectResult.class);
ModelSnapshot modelSnapshot = new ModelSnapshot.Builder(JOB_ID)
.setSnapshotId("a_snapshot_id")
.setTimestamp(Date.from(Instant.ofEpochMilli(1000000000)))
.setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000)))
.setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000)))
.setMinVersion(Version.CURRENT)
.build();
when(result.getModelSnapshot()).thenReturn(modelSnapshot);
@ -389,8 +390,8 @@ public class AutodetectResultProcessorTests extends ESTestCase {
"Job model snapshot with id [a_snapshot_id] stored",
Date.from(CURRENT_TIME),
XPackUser.NAME,
modelSnapshot.getTimestamp(),
modelSnapshot.getTimestamp(),
Date.from(Instant.ofEpochMilli(1000_000_000)),
Date.from(Instant.ofEpochMilli(1000_000_000)),
JOB_ID,
Date.from(CURRENT_TIME),
XPackUser.NAME,