Prepare the codebase for new Auditor subclasses (#45716) (#45731)

This commit is contained in:
Przemysław Witek 2019-08-20 16:03:50 +02:00 committed by GitHub
parent 80dd0a0948
commit b37ebd1adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 155 additions and 138 deletions

View File

@ -21,20 +21,20 @@ import java.util.Objects;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class Auditor<T extends AbstractAuditMessage> { public abstract class AbstractAuditor<T extends AbstractAuditMessage> {
private static final Logger logger = LogManager.getLogger(Auditor.class); private static final Logger logger = LogManager.getLogger(AbstractAuditor.class);
private final Client client; private final Client client;
private final String nodeName; private final String nodeName;
private final String auditIndex; private final String auditIndex;
private final String executionOrigin; private final String executionOrigin;
private final AbstractAuditMessage.AbstractBuilder<T> messageBuilder; private final AbstractAuditMessage.AbstractBuilder<T> messageBuilder;
public Auditor(Client client, public AbstractAuditor(Client client,
String nodeName, String nodeName,
String auditIndex, String auditIndex,
String executionOrigin, String executionOrigin,
AbstractAuditMessage.AbstractBuilder<T> messageBuilder) { AbstractAuditMessage.AbstractBuilder<T> messageBuilder) {
this.client = Objects.requireNonNull(client); this.client = Objects.requireNonNull(client);
this.nodeName = Objects.requireNonNull(nodeName); this.nodeName = Objects.requireNonNull(nodeName);
this.auditIndex = auditIndex; this.auditIndex = auditIndex;

View File

@ -58,7 +58,7 @@ import org.elasticsearch.xpack.core.ml.job.results.Influencer;
import org.elasticsearch.xpack.core.ml.job.results.ModelPlot; import org.elasticsearch.xpack.core.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.core.ml.job.results.ReservedFieldNames; import org.elasticsearch.xpack.core.ml.job.results.ReservedFieldNames;
import org.elasticsearch.xpack.core.ml.job.results.Result; import org.elasticsearch.xpack.core.ml.job.results.Result;
import org.elasticsearch.xpack.core.ml.notifications.AuditMessage; import org.elasticsearch.xpack.core.ml.notifications.AnomalyDetectionAuditMessage;
import org.elasticsearch.xpack.core.ml.utils.ExponentialAverageCalculationContext; import org.elasticsearch.xpack.core.ml.utils.ExponentialAverageCalculationContext;
import java.io.IOException; import java.io.IOException;
@ -1122,10 +1122,10 @@ public class ElasticsearchMappings {
.startObject(Job.ID.getPreferredName()) .startObject(Job.ID.getPreferredName())
.field(TYPE, KEYWORD) .field(TYPE, KEYWORD)
.endObject() .endObject()
.startObject(AuditMessage.LEVEL.getPreferredName()) .startObject(AnomalyDetectionAuditMessage.LEVEL.getPreferredName())
.field(TYPE, KEYWORD) .field(TYPE, KEYWORD)
.endObject() .endObject()
.startObject(AuditMessage.MESSAGE.getPreferredName()) .startObject(AnomalyDetectionAuditMessage.MESSAGE.getPreferredName())
.field(TYPE, TEXT) .field(TYPE, TEXT)
.startObject(FIELDS) .startObject(FIELDS)
.startObject(RAW) .startObject(RAW)
@ -1133,10 +1133,10 @@ public class ElasticsearchMappings {
.endObject() .endObject()
.endObject() .endObject()
.endObject() .endObject()
.startObject(AuditMessage.TIMESTAMP.getPreferredName()) .startObject(AnomalyDetectionAuditMessage.TIMESTAMP.getPreferredName())
.field(TYPE, DATE) .field(TYPE, DATE)
.endObject() .endObject()
.startObject(AuditMessage.NODE_NAME.getPreferredName()) .startObject(AnomalyDetectionAuditMessage.NODE_NAME.getPreferredName())
.field(TYPE, KEYWORD) .field(TYPE, KEYWORD)
.endObject() .endObject()
.endObject() .endObject()

View File

@ -18,12 +18,12 @@ import java.util.Date;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
public class AuditMessage extends AbstractAuditMessage { public class AnomalyDetectionAuditMessage extends AbstractAuditMessage {
public static final ConstructingObjectParser<AuditMessage, Void> PARSER = new ConstructingObjectParser<>( public static final ConstructingObjectParser<AnomalyDetectionAuditMessage, Void> PARSER = new ConstructingObjectParser<>(
"ml_audit_message", "ml_audit_message",
true, true,
a -> new AuditMessage((String)a[0], (String)a[1], (Level)a[2], (Date)a[3], (String)a[4])); a -> new AnomalyDetectionAuditMessage((String)a[0], (String)a[1], (Level)a[2], (Date)a[3], (String)a[4]));
static { static {
PARSER.declareString(optionalConstructorArg(), Job.ID); PARSER.declareString(optionalConstructorArg(), Job.ID);
@ -41,11 +41,11 @@ public class AuditMessage extends AbstractAuditMessage {
PARSER.declareString(optionalConstructorArg(), NODE_NAME); PARSER.declareString(optionalConstructorArg(), NODE_NAME);
} }
public AuditMessage(String resourceId, String message, Level level, String nodeName) { public AnomalyDetectionAuditMessage(String resourceId, String message, Level level, String nodeName) {
super(resourceId, message, level, nodeName); super(resourceId, message, level, nodeName);
} }
protected AuditMessage(String resourceId, String message, Level level, Date timestamp, String nodeName) { protected AnomalyDetectionAuditMessage(String resourceId, String message, Level level, Date timestamp, String nodeName) {
super(resourceId, message, level, timestamp, nodeName); super(resourceId, message, level, timestamp, nodeName);
} }
@ -54,11 +54,11 @@ public class AuditMessage extends AbstractAuditMessage {
return Job.ID.getPreferredName(); return Job.ID.getPreferredName();
} }
public static AbstractBuilder<AuditMessage> builder() { public static AbstractBuilder<AnomalyDetectionAuditMessage> builder() {
return new AbstractBuilder<AuditMessage>() { return new AbstractBuilder<AnomalyDetectionAuditMessage>() {
@Override @Override
protected AuditMessage newMessage(Level level, String resourceId, String message, String nodeName) { protected AnomalyDetectionAuditMessage newMessage(Level level, String resourceId, String message, String nodeName) {
return new AuditMessage(resourceId, message, level, nodeName); return new AnomalyDetectionAuditMessage(resourceId, message, level, nodeName);
} }
}; };
} }

View File

@ -28,14 +28,15 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
public class AuditorTests extends ESTestCase { public class AbstractAuditorTests extends ESTestCase {
private Client client;
private ArgumentCaptor<IndexRequest> indexRequestCaptor; private static final String TEST_NODE_NAME = "node_1";
private static final String TEST_ORIGIN = "test_origin"; private static final String TEST_ORIGIN = "test_origin";
private static final String TEST_INDEX = "test_index"; private static final String TEST_INDEX = "test_index";
private static final AbstractAuditMessage.AbstractBuilder<AbstractAuditMessageTests.TestAuditMessage> builder =
AbstractAuditMessageTests.TestAuditMessage.newBuilder(); private Client client;
private ArgumentCaptor<IndexRequest> indexRequestCaptor;
@Before @Before
public void setUpMocks() { public void setUpMocks() {
client = mock(Client.class); client = mock(Client.class);
@ -47,7 +48,7 @@ public class AuditorTests extends ESTestCase {
} }
public void testInfo() throws IOException { public void testInfo() throws IOException {
Auditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new Auditor<>(client, "node_1", TEST_INDEX, TEST_ORIGIN, builder); AbstractAuditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new TestAuditor(client);
auditor.info("foo", "Here is my info"); auditor.info("foo", "Here is my info");
verify(client).index(indexRequestCaptor.capture(), any()); verify(client).index(indexRequestCaptor.capture(), any());
@ -61,7 +62,7 @@ public class AuditorTests extends ESTestCase {
} }
public void testWarning() throws IOException { public void testWarning() throws IOException {
Auditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new Auditor<>(client, "node_1", TEST_INDEX, TEST_ORIGIN, builder); AbstractAuditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new TestAuditor(client);
auditor.warning("bar", "Here is my warning"); auditor.warning("bar", "Here is my warning");
verify(client).index(indexRequestCaptor.capture(), any()); verify(client).index(indexRequestCaptor.capture(), any());
@ -75,7 +76,7 @@ public class AuditorTests extends ESTestCase {
} }
public void testError() throws IOException { public void testError() throws IOException {
Auditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new Auditor<>(client, "node_1", TEST_INDEX, TEST_ORIGIN, builder); AbstractAuditor<AbstractAuditMessageTests.TestAuditMessage> auditor = new TestAuditor(client);
auditor.error("foobar", "Here is my error"); auditor.error("foobar", "Here is my error");
verify(client).index(indexRequestCaptor.capture(), any()); verify(client).index(indexRequestCaptor.capture(), any());
@ -93,4 +94,10 @@ public class AuditorTests extends ESTestCase {
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, msg.streamInput()); .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, msg.streamInput());
return AbstractAuditMessageTests.TestAuditMessage.PARSER.apply(parser, null); return AbstractAuditMessageTests.TestAuditMessage.PARSER.apply(parser, null);
} }
static class TestAuditor extends AbstractAuditor<AbstractAuditMessageTests.TestAuditMessage> {
TestAuditor(Client client) {
super(client, TEST_NODE_NAME, TEST_INDEX, TEST_ORIGIN, AbstractAuditMessageTests.TestAuditMessage.newBuilder());
}
}
} }

View File

@ -12,18 +12,18 @@ import static org.hamcrest.Matchers.equalTo;
public class LevelTests extends ESTestCase { public class LevelTests extends ESTestCase {
public void testFromString() { public void testFromString() {
assertEquals(Level.INFO, Level.fromString("info")); assertThat(Level.fromString("info"), equalTo(Level.INFO));
assertEquals(Level.INFO, Level.fromString("INFO")); assertThat(Level.fromString("INFO"), equalTo(Level.INFO));
assertEquals(Level.WARNING, Level.fromString("warning")); assertThat(Level.fromString("warning"), equalTo(Level.WARNING));
assertEquals(Level.WARNING, Level.fromString("WARNING")); assertThat(Level.fromString("WARNING"), equalTo(Level.WARNING));
assertEquals(Level.ERROR, Level.fromString("error")); assertThat(Level.fromString("error"), equalTo(Level.ERROR));
assertEquals(Level.ERROR, Level.fromString("ERROR")); assertThat(Level.fromString("ERROR"), equalTo(Level.ERROR));
} }
public void testToString() { public void testToString() {
assertEquals("info", Level.INFO.toString()); assertThat(Level.INFO.toString(), equalTo("info"));
assertEquals("warning", Level.WARNING.toString()); assertThat(Level.WARNING.toString(), equalTo("warning"));
assertEquals("error", Level.ERROR.toString()); assertThat(Level.ERROR.toString(), equalTo("error"));
} }
public void testValidOrdinals() { public void testValidOrdinals() {

View File

@ -68,7 +68,7 @@ public class DataFrameAuditorIT extends DataFrameRestTestCase {
assertBusy(() -> { assertBusy(() -> {
assertTrue(indexExists(DataFrameInternalIndex.AUDIT_INDEX)); assertTrue(indexExists(DataFrameInternalIndex.AUDIT_INDEX));
}); });
// Since calls to write the Auditor are sent and forgot (async) we could have returned from the start, // Since calls to write the AbstractAuditor are sent and forgot (async) we could have returned from the start,
// finished the job (as this is a very short DF job), all without the audit being fully written. // finished the job (as this is a very short DF job), all without the audit being fully written.
assertBusy(() -> { assertBusy(() -> {
refreshIndex(DataFrameInternalIndex.AUDIT_INDEX); refreshIndex(DataFrameInternalIndex.AUDIT_INDEX);

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.dataframe.notifications; package org.elasticsearch.xpack.dataframe.notifications;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.xpack.core.common.notifications.Auditor; import org.elasticsearch.xpack.core.common.notifications.AbstractAuditor;
import org.elasticsearch.xpack.core.dataframe.notifications.DataFrameAuditMessage; import org.elasticsearch.xpack.core.dataframe.notifications.DataFrameAuditMessage;
import org.elasticsearch.xpack.dataframe.persistence.DataFrameInternalIndex; import org.elasticsearch.xpack.dataframe.persistence.DataFrameInternalIndex;
@ -15,7 +15,7 @@ import static org.elasticsearch.xpack.core.ClientHelper.DATA_FRAME_ORIGIN;
/** /**
* DataFrameAuditor class that abstracts away generic templating for easier injection * DataFrameAuditor class that abstracts away generic templating for easier injection
*/ */
public class DataFrameAuditor extends Auditor<DataFrameAuditMessage> { public class DataFrameAuditor extends AbstractAuditor<DataFrameAuditMessage> {
public DataFrameAuditor(Client client, String nodeName) { public DataFrameAuditor(Client client, String nodeName) {
super(client, nodeName, DataFrameInternalIndex.AUDIT_INDEX, DATA_FRAME_ORIGIN, DataFrameAuditMessage.builder()); super(client, nodeName, DataFrameInternalIndex.AUDIT_INDEX, DATA_FRAME_ORIGIN, DataFrameAuditMessage.builder());
} }

View File

@ -215,7 +215,7 @@ import org.elasticsearch.xpack.ml.job.process.normalizer.MultiplyingNormalizerPr
import org.elasticsearch.xpack.ml.job.process.normalizer.NativeNormalizerProcessFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NativeNormalizerProcessFactory;
import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory;
import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerProcessFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerProcessFactory;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.process.MlMemoryTracker; import org.elasticsearch.xpack.ml.process.MlMemoryTracker;
import org.elasticsearch.xpack.ml.process.NativeController; import org.elasticsearch.xpack.ml.process.NativeController;
import org.elasticsearch.xpack.ml.process.NativeControllerHolder; import org.elasticsearch.xpack.ml.process.NativeControllerHolder;
@ -469,7 +469,7 @@ public class MachineLearning extends Plugin implements ActionPlugin, AnalysisPlu
return Collections.singletonList(new JobManagerHolder()); return Collections.singletonList(new JobManagerHolder());
} }
Auditor auditor = new Auditor(client, clusterService.getNodeName()); AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client, clusterService.getNodeName());
JobResultsProvider jobResultsProvider = new JobResultsProvider(client, settings); JobResultsProvider jobResultsProvider = new JobResultsProvider(client, settings);
JobResultsPersister jobResultsPersister = new JobResultsPersister(client); JobResultsPersister jobResultsPersister = new JobResultsPersister(client);
JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(client); JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(client);

View File

@ -21,7 +21,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.ml.MlTasks; import org.elasticsearch.xpack.core.ml.MlTasks;
import org.elasticsearch.xpack.core.ml.action.OpenJobAction; import org.elasticsearch.xpack.core.ml.action.OpenJobAction;
import org.elasticsearch.xpack.core.ml.action.StartDatafeedAction; import org.elasticsearch.xpack.core.ml.action.StartDatafeedAction;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.Objects; import java.util.Objects;
@ -29,18 +29,20 @@ import java.util.Objects;
public class MlAssignmentNotifier implements ClusterStateListener { public class MlAssignmentNotifier implements ClusterStateListener {
private static final Logger logger = LogManager.getLogger(MlAssignmentNotifier.class); private static final Logger logger = LogManager.getLogger(MlAssignmentNotifier.class);
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final MlConfigMigrator mlConfigMigrator; private final MlConfigMigrator mlConfigMigrator;
private final ThreadPool threadPool; private final ThreadPool threadPool;
MlAssignmentNotifier(Settings settings, Auditor auditor, ThreadPool threadPool, Client client, ClusterService clusterService) { MlAssignmentNotifier(Settings settings, AnomalyDetectionAuditor auditor, ThreadPool threadPool, Client client,
ClusterService clusterService) {
this.auditor = auditor; this.auditor = auditor;
this.mlConfigMigrator = new MlConfigMigrator(settings, client, clusterService); this.mlConfigMigrator = new MlConfigMigrator(settings, client, clusterService);
this.threadPool = threadPool; this.threadPool = threadPool;
clusterService.addListener(this); clusterService.addListener(this);
} }
MlAssignmentNotifier(Auditor auditor, ThreadPool threadPool, MlConfigMigrator mlConfigMigrator, ClusterService clusterService) { MlAssignmentNotifier(AnomalyDetectionAuditor auditor, ThreadPool threadPool, MlConfigMigrator mlConfigMigrator,
ClusterService clusterService) {
this.auditor = auditor; this.auditor = auditor;
this.mlConfigMigrator = mlConfigMigrator; this.mlConfigMigrator = mlConfigMigrator;
this.threadPool = threadPool; this.threadPool = threadPool;

View File

@ -37,7 +37,7 @@ import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider; import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -53,14 +53,14 @@ public class TransportCloseJobAction extends TransportTasksAction<TransportOpenJ
private final ThreadPool threadPool; private final ThreadPool threadPool;
private final Client client; private final Client client;
private final ClusterService clusterService; private final ClusterService clusterService;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final PersistentTasksService persistentTasksService; private final PersistentTasksService persistentTasksService;
private final JobConfigProvider jobConfigProvider; private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider; private final DatafeedConfigProvider datafeedConfigProvider;
@Inject @Inject
public TransportCloseJobAction(TransportService transportService, ThreadPool threadPool, ActionFilters actionFilters, public TransportCloseJobAction(TransportService transportService, ThreadPool threadPool, ActionFilters actionFilters,
ClusterService clusterService, Client client, Auditor auditor, ClusterService clusterService, Client client, AnomalyDetectionAuditor auditor,
PersistentTasksService persistentTasksService, JobConfigProvider jobConfigProvider, PersistentTasksService persistentTasksService, JobConfigProvider jobConfigProvider,
DatafeedConfigProvider datafeedConfigProvider) { DatafeedConfigProvider datafeedConfigProvider) {
// We fork in innerTaskOperation(...), so we can use ThreadPool.Names.SAME here: // We fork in innerTaskOperation(...), so we can use ThreadPool.Names.SAME here:
@ -242,8 +242,10 @@ public class TransportCloseJobAction extends TransportTasksAction<TransportOpenJ
} }
} }
static TransportCloseJobAction.WaitForCloseRequest buildWaitForCloseRequest(List<String> openJobIds, List<String> closingJobIds, static TransportCloseJobAction.WaitForCloseRequest buildWaitForCloseRequest(List<String> openJobIds,
PersistentTasksCustomMetaData tasks, Auditor auditor) { List<String> closingJobIds,
PersistentTasksCustomMetaData tasks,
AnomalyDetectionAuditor auditor) {
TransportCloseJobAction.WaitForCloseRequest waitForCloseRequest = new TransportCloseJobAction.WaitForCloseRequest(); TransportCloseJobAction.WaitForCloseRequest waitForCloseRequest = new TransportCloseJobAction.WaitForCloseRequest();
for (String jobId : openJobIds) { for (String jobId : openJobIds) {

View File

@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.job.retention.ExpiredModelSnapshotsRemover;
import org.elasticsearch.xpack.ml.job.retention.ExpiredResultsRemover; import org.elasticsearch.xpack.ml.job.retention.ExpiredResultsRemover;
import org.elasticsearch.xpack.ml.job.retention.MlDataRemover; import org.elasticsearch.xpack.ml.job.retention.MlDataRemover;
import org.elasticsearch.xpack.ml.job.retention.UnusedStateRemover; import org.elasticsearch.xpack.ml.job.retention.UnusedStateRemover;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.utils.VolatileCursorIterator; import org.elasticsearch.xpack.ml.utils.VolatileCursorIterator;
import java.util.Arrays; import java.util.Arrays;
@ -54,7 +54,7 @@ public class TransportDeleteExpiredDataAction extends HandledTransportAction<Del
} }
private void deleteExpiredData(ActionListener<DeleteExpiredDataAction.Response> listener) { private void deleteExpiredData(ActionListener<DeleteExpiredDataAction.Response> listener) {
Auditor auditor = new Auditor(client, clusterService.getNodeName()); AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client, clusterService.getNodeName());
List<MlDataRemover> dataRemovers = Arrays.asList( List<MlDataRemover> dataRemovers = Arrays.asList(
new ExpiredResultsRemover(client, auditor), new ExpiredResultsRemover(client, auditor),
new ExpiredForecastsRemover(client, threadPool), new ExpiredForecastsRemover(client, threadPool),

View File

@ -70,7 +70,7 @@ import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter; import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.process.MlMemoryTracker; import org.elasticsearch.xpack.ml.process.MlMemoryTracker;
import org.elasticsearch.xpack.ml.utils.MlIndicesUtils; import org.elasticsearch.xpack.ml.utils.MlIndicesUtils;
@ -94,7 +94,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction<DeleteJo
private final Client client; private final Client client;
private final PersistentTasksService persistentTasksService; private final PersistentTasksService persistentTasksService;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final JobResultsProvider jobResultsProvider; private final JobResultsProvider jobResultsProvider;
private final JobConfigProvider jobConfigProvider; private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider; private final DatafeedConfigProvider datafeedConfigProvider;
@ -113,7 +113,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction<DeleteJo
public TransportDeleteJobAction(Settings settings, TransportService transportService, ClusterService clusterService, public TransportDeleteJobAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, PersistentTasksService persistentTasksService, IndexNameExpressionResolver indexNameExpressionResolver, PersistentTasksService persistentTasksService,
Client client, Auditor auditor, JobResultsProvider jobResultsProvider, Client client, AnomalyDetectionAuditor auditor, JobResultsProvider jobResultsProvider,
JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider, JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider,
MlMemoryTracker memoryTracker) { MlMemoryTracker memoryTracker) {
super(DeleteJobAction.NAME, transportService, clusterService, threadPool, actionFilters, super(DeleteJobAction.NAME, transportService, clusterService, threadPool, actionFilters,

View File

@ -21,7 +21,7 @@ import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSnapsho
import org.elasticsearch.xpack.ml.job.JobManager; import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter; import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -32,12 +32,12 @@ public class TransportDeleteModelSnapshotAction extends HandledTransportAction<D
private final Client client; private final Client client;
private final JobManager jobManager; private final JobManager jobManager;
private final JobResultsProvider jobResultsProvider; private final JobResultsProvider jobResultsProvider;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
@Inject @Inject
public TransportDeleteModelSnapshotAction(TransportService transportService, ActionFilters actionFilters, public TransportDeleteModelSnapshotAction(TransportService transportService, ActionFilters actionFilters,
JobResultsProvider jobResultsProvider, Client client, JobManager jobManager, JobResultsProvider jobResultsProvider, Client client, JobManager jobManager,
Auditor auditor) { AnomalyDetectionAuditor auditor) {
super(DeleteModelSnapshotAction.NAME, transportService, actionFilters, DeleteModelSnapshotAction.Request::new); super(DeleteModelSnapshotAction.NAME, transportService, actionFilters, DeleteModelSnapshotAction.Request::new);
this.client = client; this.client = client;
this.jobManager = jobManager; this.jobManager = jobManager;

View File

@ -20,15 +20,15 @@ import org.elasticsearch.xpack.core.ml.job.messages.Messages;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
public class TransportKillProcessAction extends TransportJobTaskAction<KillProcessAction.Request, KillProcessAction.Response> { public class TransportKillProcessAction extends TransportJobTaskAction<KillProcessAction.Request, KillProcessAction.Response> {
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
@Inject @Inject
public TransportKillProcessAction(TransportService transportService, ClusterService clusterService, ActionFilters actionFilters, public TransportKillProcessAction(TransportService transportService, ClusterService clusterService, ActionFilters actionFilters,
AutodetectProcessManager processManager, Auditor auditor) { AutodetectProcessManager processManager, AnomalyDetectionAuditor auditor) {
super(KillProcessAction.NAME, clusterService, transportService, actionFilters, KillProcessAction.Request::new, super(KillProcessAction.NAME, clusterService, transportService, actionFilters, KillProcessAction.Request::new,
KillProcessAction.Response::new, MachineLearning.UTILITY_THREAD_POOL_NAME, processManager); KillProcessAction.Response::new, MachineLearning.UTILITY_THREAD_POOL_NAME, processManager);
this.auditor = auditor; this.auditor = auditor;

View File

@ -55,7 +55,7 @@ import org.elasticsearch.xpack.ml.datafeed.DatafeedTimingStatsReporter;
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory; import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider; import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -81,7 +81,7 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction<Star
private final PersistentTasksService persistentTasksService; private final PersistentTasksService persistentTasksService;
private final JobConfigProvider jobConfigProvider; private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider; private final DatafeedConfigProvider datafeedConfigProvider;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final MlConfigMigrationEligibilityCheck migrationEligibilityCheck; private final MlConfigMigrationEligibilityCheck migrationEligibilityCheck;
private final NamedXContentRegistry xContentRegistry; private final NamedXContentRegistry xContentRegistry;
@ -91,7 +91,7 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction<Star
PersistentTasksService persistentTasksService, PersistentTasksService persistentTasksService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
Client client, JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider, Client client, JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider,
Auditor auditor, NamedXContentRegistry xContentRegistry) { AnomalyDetectionAuditor auditor, NamedXContentRegistry xContentRegistry) {
super(StartDatafeedAction.NAME, transportService, clusterService, threadPool, actionFilters, StartDatafeedAction.Request::new, super(StartDatafeedAction.NAME, transportService, clusterService, threadPool, actionFilters, StartDatafeedAction.Request::new,
indexNameExpressionResolver); indexNameExpressionResolver);
this.licenseState = licenseState; this.licenseState = licenseState;
@ -118,7 +118,8 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction<Star
} }
//Get the deprecation warnings from the parsed query and aggs to audit //Get the deprecation warnings from the parsed query and aggs to audit
static void auditDeprecations(DatafeedConfig datafeed, Job job, Auditor auditor, NamedXContentRegistry xContentRegistry) { static void auditDeprecations(DatafeedConfig datafeed, Job job, AnomalyDetectionAuditor auditor,
NamedXContentRegistry xContentRegistry) {
List<String> deprecationWarnings = new ArrayList<>(); List<String> deprecationWarnings = new ArrayList<>();
deprecationWarnings.addAll(datafeed.getAggDeprecations(xContentRegistry)); deprecationWarnings.addAll(datafeed.getAggDeprecations(xContentRegistry));
deprecationWarnings.addAll(datafeed.getQueryDeprecations(xContentRegistry)); deprecationWarnings.addAll(datafeed.getQueryDeprecations(xContentRegistry));

View File

@ -35,7 +35,7 @@ import org.elasticsearch.xpack.core.security.user.XPackUser;
import org.elasticsearch.xpack.ml.datafeed.delayeddatacheck.DelayedDataDetector; import org.elasticsearch.xpack.ml.datafeed.delayeddatacheck.DelayedDataDetector;
import org.elasticsearch.xpack.ml.datafeed.delayeddatacheck.DelayedDataDetectorFactory.BucketWithMissingData; import org.elasticsearch.xpack.ml.datafeed.delayeddatacheck.DelayedDataDetectorFactory.BucketWithMissingData;
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory; import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -54,7 +54,7 @@ class DatafeedJob {
private static final int NEXT_TASK_DELAY_MS = 100; private static final int NEXT_TASK_DELAY_MS = 100;
static final long MISSING_DATA_CHECK_INTERVAL_MS = 900_000; //15 minutes in ms static final long MISSING_DATA_CHECK_INTERVAL_MS = 900_000; //15 minutes in ms
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final String jobId; private final String jobId;
private final DataDescription dataDescription; private final DataDescription dataDescription;
private final long frequencyMs; private final long frequencyMs;
@ -76,7 +76,7 @@ class DatafeedJob {
DatafeedJob(String jobId, DataDescription dataDescription, long frequencyMs, long queryDelayMs, DatafeedJob(String jobId, DataDescription dataDescription, long frequencyMs, long queryDelayMs,
DataExtractorFactory dataExtractorFactory, DatafeedTimingStatsReporter timingStatsReporter, Client client, DataExtractorFactory dataExtractorFactory, DatafeedTimingStatsReporter timingStatsReporter, Client client,
Auditor auditor, Supplier<Long> currentTimeSupplier, DelayedDataDetector delayedDataDetector, AnomalyDetectionAuditor auditor, Supplier<Long> currentTimeSupplier, DelayedDataDetector delayedDataDetector,
long latestFinalBucketEndTimeMs, long latestRecordTimeMs) { long latestFinalBucketEndTimeMs, long latestRecordTimeMs) {
this.jobId = jobId; this.jobId = jobId;
this.dataDescription = Objects.requireNonNull(dataDescription); this.dataDescription = Objects.requireNonNull(dataDescription);

View File

@ -27,7 +27,7 @@ import org.elasticsearch.xpack.ml.job.persistence.BucketsQueryBuilder;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.Collections; import java.util.Collections;
import java.util.Objects; import java.util.Objects;
@ -39,16 +39,17 @@ public class DatafeedJobBuilder {
private final Client client; private final Client client;
private final NamedXContentRegistry xContentRegistry; private final NamedXContentRegistry xContentRegistry;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final Supplier<Long> currentTimeSupplier; private final Supplier<Long> currentTimeSupplier;
private final JobConfigProvider jobConfigProvider; private final JobConfigProvider jobConfigProvider;
private final JobResultsProvider jobResultsProvider; private final JobResultsProvider jobResultsProvider;
private final DatafeedConfigProvider datafeedConfigProvider; private final DatafeedConfigProvider datafeedConfigProvider;
private final JobResultsPersister jobResultsPersister; private final JobResultsPersister jobResultsPersister;
public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, Auditor auditor, Supplier<Long> currentTimeSupplier, public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, AnomalyDetectionAuditor auditor,
JobConfigProvider jobConfigProvider, JobResultsProvider jobResultsProvider, Supplier<Long> currentTimeSupplier, JobConfigProvider jobConfigProvider,
DatafeedConfigProvider datafeedConfigProvider, JobResultsPersister jobResultsPersister) { JobResultsProvider jobResultsProvider, DatafeedConfigProvider datafeedConfigProvider,
JobResultsPersister jobResultsPersister) {
this.client = client; this.client = client;
this.xContentRegistry = Objects.requireNonNull(xContentRegistry); this.xContentRegistry = Objects.requireNonNull(xContentRegistry);
this.auditor = Objects.requireNonNull(auditor); this.auditor = Objects.requireNonNull(auditor);

View File

@ -32,7 +32,7 @@ import org.elasticsearch.xpack.core.ml.job.messages.Messages;
import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.action.TransportStartDatafeedAction; import org.elasticsearch.xpack.ml.action.TransportStartDatafeedAction;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -58,7 +58,7 @@ public class DatafeedManager {
private final ClusterService clusterService; private final ClusterService clusterService;
private final ThreadPool threadPool; private final ThreadPool threadPool;
private final Supplier<Long> currentTimeSupplier; private final Supplier<Long> currentTimeSupplier;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
// Use allocationId as key instead of datafeed id // Use allocationId as key instead of datafeed id
private final ConcurrentMap<Long, Holder> runningDatafeedsOnThisNode = new ConcurrentHashMap<>(); private final ConcurrentMap<Long, Holder> runningDatafeedsOnThisNode = new ConcurrentHashMap<>();
private final DatafeedJobBuilder datafeedJobBuilder; private final DatafeedJobBuilder datafeedJobBuilder;
@ -66,7 +66,8 @@ public class DatafeedManager {
private final AutodetectProcessManager autodetectProcessManager; private final AutodetectProcessManager autodetectProcessManager;
public DatafeedManager(ThreadPool threadPool, Client client, ClusterService clusterService, DatafeedJobBuilder datafeedJobBuilder, public DatafeedManager(ThreadPool threadPool, Client client, ClusterService clusterService, DatafeedJobBuilder datafeedJobBuilder,
Supplier<Long> currentTimeSupplier, Auditor auditor, AutodetectProcessManager autodetectProcessManager) { Supplier<Long> currentTimeSupplier, AnomalyDetectionAuditor auditor,
AutodetectProcessManager autodetectProcessManager) {
this.client = Objects.requireNonNull(client); this.client = Objects.requireNonNull(client);
this.clusterService = Objects.requireNonNull(clusterService); this.clusterService = Objects.requireNonNull(clusterService);
this.threadPool = threadPool; this.threadPool = threadPool;

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.datafeed; package org.elasticsearch.xpack.ml.datafeed;
import org.elasticsearch.xpack.core.ml.job.messages.Messages; import org.elasticsearch.xpack.core.ml.job.messages.Messages;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.Objects; import java.util.Objects;
@ -26,7 +26,7 @@ class ProblemTracker {
private static final int EMPTY_DATA_WARN_COUNT = 10; private static final int EMPTY_DATA_WARN_COUNT = 10;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final String jobId; private final String jobId;
private volatile boolean hasProblems; private volatile boolean hasProblems;
@ -34,7 +34,7 @@ class ProblemTracker {
private volatile String previousProblem; private volatile String previousProblem;
private volatile int emptyDataCount; private volatile int emptyDataCount;
ProblemTracker(Auditor auditor, String jobId) { ProblemTracker(AnomalyDetectionAuditor auditor, String jobId) {
this.auditor = Objects.requireNonNull(auditor); this.auditor = Objects.requireNonNull(auditor);
this.jobId = Objects.requireNonNull(jobId); this.jobId = Objects.requireNonNull(jobId);
} }

View File

@ -57,7 +57,7 @@ import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.process.autodetect.UpdateParams; import org.elasticsearch.xpack.ml.job.process.autodetect.UpdateParams;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.utils.VoidChainTaskExecutor; import org.elasticsearch.xpack.ml.utils.VoidChainTaskExecutor;
import java.io.IOException; import java.io.IOException;
@ -91,7 +91,7 @@ public class JobManager {
private final JobResultsProvider jobResultsProvider; private final JobResultsProvider jobResultsProvider;
private final JobResultsPersister jobResultsPersister; private final JobResultsPersister jobResultsPersister;
private final ClusterService clusterService; private final ClusterService clusterService;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final Client client; private final Client client;
private final ThreadPool threadPool; private final ThreadPool threadPool;
private final UpdateJobProcessNotifier updateJobProcessNotifier; private final UpdateJobProcessNotifier updateJobProcessNotifier;
@ -104,8 +104,9 @@ public class JobManager {
* Create a JobManager * Create a JobManager
*/ */
public JobManager(Environment environment, Settings settings, JobResultsProvider jobResultsProvider, public JobManager(Environment environment, Settings settings, JobResultsProvider jobResultsProvider,
JobResultsPersister jobResultsPersister, ClusterService clusterService, Auditor auditor, ThreadPool threadPool, JobResultsPersister jobResultsPersister, ClusterService clusterService, AnomalyDetectionAuditor auditor,
Client client, UpdateJobProcessNotifier updateJobProcessNotifier, NamedXContentRegistry xContentRegistry) { ThreadPool threadPool, Client client, UpdateJobProcessNotifier updateJobProcessNotifier,
NamedXContentRegistry xContentRegistry) {
this.environment = environment; this.environment = environment;
this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider); this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider);
this.jobResultsPersister = Objects.requireNonNull(jobResultsPersister); this.jobResultsPersister = Objects.requireNonNull(jobResultsPersister);

View File

@ -66,7 +66,7 @@ import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory;
import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer; import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer;
import org.elasticsearch.xpack.ml.job.process.normalizer.ScoresUpdater; import org.elasticsearch.xpack.ml.job.process.normalizer.ScoresUpdater;
import org.elasticsearch.xpack.ml.job.process.normalizer.ShortCircuitingRenormalizer; import org.elasticsearch.xpack.ml.job.process.normalizer.ShortCircuitingRenormalizer;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.process.NativeStorageProvider; import org.elasticsearch.xpack.ml.process.NativeStorageProvider;
import java.io.IOException; import java.io.IOException;
@ -109,12 +109,12 @@ public class AutodetectProcessManager implements ClusterStateListener {
private final NamedXContentRegistry xContentRegistry; private final NamedXContentRegistry xContentRegistry;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private volatile boolean upgradeInProgress; private volatile boolean upgradeInProgress;
public AutodetectProcessManager(Environment environment, Settings settings, Client client, ThreadPool threadPool, public AutodetectProcessManager(Environment environment, Settings settings, Client client, ThreadPool threadPool,
NamedXContentRegistry xContentRegistry, Auditor auditor, ClusterService clusterService, NamedXContentRegistry xContentRegistry, AnomalyDetectionAuditor auditor, ClusterService clusterService,
JobManager jobManager, JobResultsProvider jobResultsProvider, JobResultsPersister jobResultsPersister, JobManager jobManager, JobResultsProvider jobResultsProvider, JobResultsPersister jobResultsPersister,
JobDataCountsPersister jobDataCountsPersister, AutodetectProcessFactory autodetectProcessFactory, JobDataCountsPersister jobDataCountsPersister, AutodetectProcessFactory autodetectProcessFactory,
NormalizerFactory normalizerFactory, NativeStorageProvider nativeStorageProvider) { NormalizerFactory normalizerFactory, NativeStorageProvider nativeStorageProvider) {

View File

@ -38,7 +38,7 @@ import org.elasticsearch.xpack.ml.job.persistence.TimingStatsReporter;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcess; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcess;
import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer; import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer;
import org.elasticsearch.xpack.ml.job.results.AutodetectResult; import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.time.Duration; import java.time.Duration;
import java.util.Iterator; import java.util.Iterator;
@ -74,7 +74,7 @@ public class AutodetectResultProcessor {
private static final Logger LOGGER = LogManager.getLogger(AutodetectResultProcessor.class); private static final Logger LOGGER = LogManager.getLogger(AutodetectResultProcessor.class);
private final Client client; private final Client client;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
private final String jobId; private final String jobId;
private final Renormalizer renormalizer; private final Renormalizer renormalizer;
private final JobResultsPersister persister; private final JobResultsPersister persister;
@ -96,7 +96,7 @@ public class AutodetectResultProcessor {
private volatile ModelSizeStats latestModelSizeStats; private volatile ModelSizeStats latestModelSizeStats;
public AutodetectResultProcessor(Client client, public AutodetectResultProcessor(Client client,
Auditor auditor, AnomalyDetectionAuditor auditor,
String jobId, String jobId,
Renormalizer renormalizer, Renormalizer renormalizer,
JobResultsPersister persister, JobResultsPersister persister,
@ -107,7 +107,7 @@ public class AutodetectResultProcessor {
} }
// Visible for testing // Visible for testing
AutodetectResultProcessor(Client client, Auditor auditor, String jobId, Renormalizer renormalizer, AutodetectResultProcessor(Client client, AnomalyDetectionAuditor auditor, String jobId, Renormalizer renormalizer,
JobResultsPersister persister, AutodetectProcess autodetectProcess, ModelSizeStats latestModelSizeStats, JobResultsPersister persister, AutodetectProcess autodetectProcess, ModelSizeStats latestModelSizeStats,
TimingStats timingStats, TimingStats timingStats,
FlushListener flushListener) { FlushListener flushListener) {

View File

@ -23,7 +23,7 @@ import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSizeSta
import org.elasticsearch.xpack.core.ml.job.results.Forecast; import org.elasticsearch.xpack.core.ml.job.results.Forecast;
import org.elasticsearch.xpack.core.ml.job.results.ForecastRequestStats; import org.elasticsearch.xpack.core.ml.job.results.ForecastRequestStats;
import org.elasticsearch.xpack.core.ml.job.results.Result; import org.elasticsearch.xpack.core.ml.job.results.Result;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneOffset; import java.time.ZoneOffset;
@ -46,9 +46,9 @@ public class ExpiredResultsRemover extends AbstractExpiredJobDataRemover {
private static final Logger LOGGER = LogManager.getLogger(ExpiredResultsRemover.class); private static final Logger LOGGER = LogManager.getLogger(ExpiredResultsRemover.class);
private final Client client; private final Client client;
private final Auditor auditor; private final AnomalyDetectionAuditor auditor;
public ExpiredResultsRemover(Client client, Auditor auditor) { public ExpiredResultsRemover(Client client, AnomalyDetectionAuditor auditor) {
super(client); super(client);
this.client = Objects.requireNonNull(client); this.client = Objects.requireNonNull(client);
this.auditor = Objects.requireNonNull(auditor); this.auditor = Objects.requireNonNull(auditor);

View File

@ -6,14 +6,15 @@
package org.elasticsearch.xpack.ml.notifications; package org.elasticsearch.xpack.ml.notifications;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.xpack.core.common.notifications.AbstractAuditor;
import org.elasticsearch.xpack.core.ml.notifications.AuditorField; import org.elasticsearch.xpack.core.ml.notifications.AuditorField;
import org.elasticsearch.xpack.core.ml.notifications.AuditMessage; import org.elasticsearch.xpack.core.ml.notifications.AnomalyDetectionAuditMessage;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN; import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
public class Auditor extends org.elasticsearch.xpack.core.common.notifications.Auditor<AuditMessage> { public class AnomalyDetectionAuditor extends AbstractAuditor<AnomalyDetectionAuditMessage> {
public Auditor(Client client, String nodeName) { public AnomalyDetectionAuditor(Client client, String nodeName) {
super(client, nodeName, AuditorField.NOTIFICATIONS_INDEX, ML_ORIGIN, AuditMessage.builder()); super(client, nodeName, AuditorField.NOTIFICATIONS_INDEX, ML_ORIGIN, AnomalyDetectionAuditMessage.builder());
} }
} }

View File

@ -18,7 +18,7 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.persistent.PersistentTasksCustomMetaData;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import java.net.InetAddress; import java.net.InetAddress;
@ -38,7 +38,7 @@ import static org.mockito.Mockito.when;
public class MlAssignmentNotifierTests extends ESTestCase { public class MlAssignmentNotifierTests extends ESTestCase {
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private ClusterService clusterService; private ClusterService clusterService;
private ThreadPool threadPool; private ThreadPool threadPool;
private MlConfigMigrator configMigrator; private MlConfigMigrator configMigrator;
@ -46,7 +46,7 @@ public class MlAssignmentNotifierTests extends ESTestCase {
@Before @Before
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void setupMocks() { private void setupMocks() {
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
clusterService = mock(ClusterService.class); clusterService = mock(ClusterService.class);
threadPool = mock(ThreadPool.class); threadPool = mock(ThreadPool.class);
configMigrator = mock(MlConfigMigrator.class); configMigrator = mock(MlConfigMigrator.class);

View File

@ -30,7 +30,7 @@ import org.elasticsearch.xpack.core.ml.datafeed.DatafeedState;
import org.elasticsearch.xpack.core.ml.job.config.JobState; import org.elasticsearch.xpack.core.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider; import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase;
import org.junit.Before; import org.junit.Before;
@ -255,14 +255,15 @@ public class TransportCloseJobActionTests extends ESTestCase {
addJobTask("closingjob1", null, JobState.CLOSING, tasksBuilder); addJobTask("closingjob1", null, JobState.CLOSING, tasksBuilder);
TransportCloseJobAction.WaitForCloseRequest waitForCloseRequest = TransportCloseJobAction.WaitForCloseRequest waitForCloseRequest =
TransportCloseJobAction.buildWaitForCloseRequest(openJobIds, closingJobIds, tasksBuilder.build(), mock(Auditor.class)); TransportCloseJobAction.buildWaitForCloseRequest(
openJobIds, closingJobIds, tasksBuilder.build(), mock(AnomalyDetectionAuditor.class));
assertEquals(waitForCloseRequest.jobsToFinalize, Arrays.asList("openjob1", "openjob2")); assertEquals(waitForCloseRequest.jobsToFinalize, Arrays.asList("openjob1", "openjob2"));
assertEquals(waitForCloseRequest.persistentTaskIds, assertEquals(waitForCloseRequest.persistentTaskIds,
Arrays.asList("job-openjob1", "job-openjob2", "job-closingjob1")); Arrays.asList("job-openjob1", "job-openjob2", "job-closingjob1"));
assertTrue(waitForCloseRequest.hasJobsToWaitFor()); assertTrue(waitForCloseRequest.hasJobsToWaitFor());
waitForCloseRequest = TransportCloseJobAction.buildWaitForCloseRequest(Collections.emptyList(), Collections.emptyList(), waitForCloseRequest = TransportCloseJobAction.buildWaitForCloseRequest(Collections.emptyList(), Collections.emptyList(),
tasksBuilder.build(), mock(Auditor.class)); tasksBuilder.build(), mock(AnomalyDetectionAuditor.class));
assertFalse(waitForCloseRequest.hasJobsToWaitFor()); assertFalse(waitForCloseRequest.hasJobsToWaitFor());
} }
@ -275,7 +276,7 @@ public class TransportCloseJobActionTests extends ESTestCase {
private TransportCloseJobAction createAction() { private TransportCloseJobAction createAction() {
return new TransportCloseJobAction(mock(TransportService.class), mock(ThreadPool.class), mock(ActionFilters.class), return new TransportCloseJobAction(mock(TransportService.class), mock(ThreadPool.class), mock(ActionFilters.class),
clusterService, mock(Client.class), mock(Auditor.class), mock(PersistentTasksService.class), clusterService, mock(Client.class), mock(AnomalyDetectionAuditor.class), mock(PersistentTasksService.class),
jobConfigProvider, datafeedConfigProvider); jobConfigProvider, datafeedConfigProvider);
} }

View File

@ -19,7 +19,7 @@ import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.config.JobState; import org.elasticsearch.xpack.core.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.datafeed.DatafeedManager; import org.elasticsearch.xpack.ml.datafeed.DatafeedManager;
import org.elasticsearch.xpack.ml.datafeed.DatafeedManagerTests; import org.elasticsearch.xpack.ml.datafeed.DatafeedManagerTests;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
@ -78,7 +78,7 @@ public class TransportStartDatafeedActionTests extends ESTestCase {
doReturn(Collections.singletonList("Deprecated Agg")).when(config).getAggDeprecations(any(NamedXContentRegistry.class)); doReturn(Collections.singletonList("Deprecated Agg")).when(config).getAggDeprecations(any(NamedXContentRegistry.class));
doReturn(Collections.singletonList("Deprecated Query")).when(config).getQueryDeprecations(any(NamedXContentRegistry.class)); doReturn(Collections.singletonList("Deprecated Query")).when(config).getQueryDeprecations(any(NamedXContentRegistry.class));
Auditor auditor = mock(Auditor.class); AnomalyDetectionAuditor auditor = mock(AnomalyDetectionAuditor.class);
TransportStartDatafeedAction.auditDeprecations(config, job1, auditor, xContentRegistry()); TransportStartDatafeedAction.auditDeprecations(config, job1, auditor, xContentRegistry());
@ -93,7 +93,7 @@ public class TransportStartDatafeedActionTests extends ESTestCase {
doReturn(Collections.emptyList()).when(config).getAggDeprecations(any(NamedXContentRegistry.class)); doReturn(Collections.emptyList()).when(config).getAggDeprecations(any(NamedXContentRegistry.class));
doReturn(Collections.emptyList()).when(config).getQueryDeprecations(any(NamedXContentRegistry.class)); doReturn(Collections.emptyList()).when(config).getQueryDeprecations(any(NamedXContentRegistry.class));
Auditor auditor = mock(Auditor.class); AnomalyDetectionAuditor auditor = mock(AnomalyDetectionAuditor.class);
TransportStartDatafeedAction.auditDeprecations(config, job1, auditor, xContentRegistry()); TransportStartDatafeedAction.auditDeprecations(config, job1, auditor, xContentRegistry());

View File

@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import java.util.Collections; import java.util.Collections;
@ -44,7 +44,7 @@ import static org.mockito.Mockito.when;
public class DatafeedJobBuilderTests extends ESTestCase { public class DatafeedJobBuilderTests extends ESTestCase {
private Client client; private Client client;
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private Consumer<Exception> taskHandler; private Consumer<Exception> taskHandler;
private JobResultsProvider jobResultsProvider; private JobResultsProvider jobResultsProvider;
private JobConfigProvider jobConfigProvider; private JobConfigProvider jobConfigProvider;
@ -61,7 +61,7 @@ public class DatafeedJobBuilderTests extends ESTestCase {
when(client.threadPool()).thenReturn(threadPool); when(client.threadPool()).thenReturn(threadPool);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
when(client.settings()).thenReturn(Settings.EMPTY); when(client.settings()).thenReturn(Settings.EMPTY);
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
taskHandler = mock(Consumer.class); taskHandler = mock(Consumer.class);
jobResultsPersister = mock(JobResultsPersister.class); jobResultsPersister = mock(JobResultsPersister.class);

View File

@ -36,7 +36,7 @@ import org.elasticsearch.xpack.ml.datafeed.delayeddatacheck.DelayedDataDetectorF
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory; import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
import org.elasticsearch.xpack.core.ml.job.config.DataDescription; import org.elasticsearch.xpack.core.ml.job.config.DataDescription;
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts; import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.junit.Before; import org.junit.Before;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -70,7 +70,7 @@ public class DatafeedJobTests extends ESTestCase {
private static final String jobId = "_job_id"; private static final String jobId = "_job_id";
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private DataExtractorFactory dataExtractorFactory; private DataExtractorFactory dataExtractorFactory;
private DataExtractor dataExtractor; private DataExtractor dataExtractor;
private DatafeedTimingStatsReporter timingStatsReporter; private DatafeedTimingStatsReporter timingStatsReporter;
@ -90,7 +90,7 @@ public class DatafeedJobTests extends ESTestCase {
@Before @Before
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setup() throws Exception { public void setup() throws Exception {
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
dataExtractorFactory = mock(DataExtractorFactory.class); dataExtractorFactory = mock(DataExtractorFactory.class);
dataExtractor = mock(DataExtractor.class); dataExtractor = mock(DataExtractor.class);
when(dataExtractorFactory.newExtractor(anyLong(), anyLong())).thenReturn(dataExtractor); when(dataExtractorFactory.newExtractor(anyLong(), anyLong())).thenReturn(dataExtractor);

View File

@ -37,7 +37,7 @@ import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.action.TransportStartDatafeedAction.DatafeedTask; import org.elasticsearch.xpack.ml.action.TransportStartDatafeedAction.DatafeedTask;
import org.elasticsearch.xpack.ml.action.TransportStartDatafeedActionTests; import org.elasticsearch.xpack.ml.action.TransportStartDatafeedActionTests;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -71,7 +71,7 @@ public class DatafeedManagerTests extends ESTestCase {
private DatafeedJob datafeedJob; private DatafeedJob datafeedJob;
private DatafeedManager datafeedManager; private DatafeedManager datafeedManager;
private long currentTime = 120000; private long currentTime = 120000;
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private ArgumentCaptor<ClusterStateListener> capturedClusterStateListener = ArgumentCaptor.forClass(ClusterStateListener.class); private ArgumentCaptor<ClusterStateListener> capturedClusterStateListener = ArgumentCaptor.forClass(ClusterStateListener.class);
private AtomicBoolean hasOpenAutodetectCommunicator; private AtomicBoolean hasOpenAutodetectCommunicator;
@ -97,9 +97,9 @@ public class DatafeedManagerTests extends ESTestCase {
DiscoveryNode dNode = mock(DiscoveryNode.class); DiscoveryNode dNode = mock(DiscoveryNode.class);
when(dNode.getName()).thenReturn("this_node_has_a_name"); when(dNode.getName()).thenReturn("this_node_has_a_name");
when(clusterService.localNode()).thenReturn(dNode); when(clusterService.localNode()).thenReturn(dNode);
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
threadPool = mock(ThreadPool.class); threadPool = mock(ThreadPool.class);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
ExecutorService executorService = mock(ExecutorService.class); ExecutorService executorService = mock(ExecutorService.class);

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.datafeed; package org.elasticsearch.xpack.ml.datafeed;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -16,13 +16,13 @@ import static org.mockito.Mockito.verify;
public class ProblemTrackerTests extends ESTestCase { public class ProblemTrackerTests extends ESTestCase {
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private ProblemTracker problemTracker; private ProblemTracker problemTracker;
@Before @Before
public void setUpTests() { public void setUpTests() {
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
problemTracker = new ProblemTracker(auditor, "foo"); problemTracker = new ProblemTracker(auditor, "foo");
} }

View File

@ -14,7 +14,7 @@ import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.ml.annotations.AnnotationIndex; import org.elasticsearch.xpack.core.ml.annotations.AnnotationIndex;
import org.elasticsearch.xpack.ml.LocalStateMachineLearning; import org.elasticsearch.xpack.ml.LocalStateMachineLearning;
import org.elasticsearch.xpack.ml.MlSingleNodeTestCase; import org.elasticsearch.xpack.ml.MlSingleNodeTestCase;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import java.util.Collection; import java.util.Collection;
@ -53,7 +53,7 @@ public class AnnotationIndexIT extends MlSingleNodeTestCase {
public void testCreatedWhenAfterOtherMlIndex() throws Exception { public void testCreatedWhenAfterOtherMlIndex() throws Exception {
Auditor auditor = new Auditor(client(), "node_1"); AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), "node_1");
auditor.info("whatever", "blah"); auditor.info("whatever", "blah");
// Creating a document in the .ml-notifications index should cause .ml-annotations // Creating a document in the .ml-notifications index should cause .ml-annotations

View File

@ -45,7 +45,7 @@ import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
import org.elasticsearch.xpack.ml.job.results.BucketTests; import org.elasticsearch.xpack.ml.job.results.BucketTests;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinitionTests; import org.elasticsearch.xpack.ml.job.results.CategoryDefinitionTests;
import org.elasticsearch.xpack.ml.job.results.ModelPlotTests; import org.elasticsearch.xpack.ml.job.results.ModelPlotTests;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -87,7 +87,7 @@ public class AutodetectResultProcessorIT extends MlSingleNodeTestCase {
public void createComponents() throws Exception { public void createComponents() throws Exception {
Settings.Builder builder = Settings.builder() Settings.Builder builder = Settings.builder()
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueSeconds(1)); .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueSeconds(1));
Auditor auditor = new Auditor(client(), "test_node"); AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), "test_node");
jobResultsProvider = new JobResultsProvider(client(), builder.build()); jobResultsProvider = new JobResultsProvider(client(), builder.build());
renormalizer = mock(Renormalizer.class); renormalizer = mock(Renormalizer.class);
process = mock(AutodetectProcess.class); process = mock(AutodetectProcess.class);

View File

@ -62,7 +62,7 @@ import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.persistence.MockClientBuilder; import org.elasticsearch.xpack.ml.job.persistence.MockClientBuilder;
import org.elasticsearch.xpack.ml.job.process.autodetect.UpdateParams; import org.elasticsearch.xpack.ml.job.process.autodetect.UpdateParams;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Matchers; import org.mockito.Matchers;
@ -105,7 +105,7 @@ public class JobManagerTests extends ESTestCase {
private ThreadPool threadPool; private ThreadPool threadPool;
private JobResultsProvider jobResultsProvider; private JobResultsProvider jobResultsProvider;
private JobResultsPersister jobResultsPersister; private JobResultsPersister jobResultsPersister;
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private UpdateJobProcessNotifier updateJobProcessNotifier; private UpdateJobProcessNotifier updateJobProcessNotifier;
@Override @Override
@ -126,7 +126,7 @@ public class JobManagerTests extends ESTestCase {
jobResultsProvider = mock(JobResultsProvider.class); jobResultsProvider = mock(JobResultsProvider.class);
jobResultsPersister = mock(JobResultsPersister.class); jobResultsPersister = mock(JobResultsPersister.class);
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
updateJobProcessNotifier = mock(UpdateJobProcessNotifier.class); updateJobProcessNotifier = mock(UpdateJobProcessNotifier.class);
ExecutorService executorService = mock(ExecutorService.class); ExecutorService executorService = mock(ExecutorService.class);

View File

@ -52,7 +52,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.FlushJobParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.FlushJobParams;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.TimeRange; import org.elasticsearch.xpack.ml.job.process.autodetect.params.TimeRange;
import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.elasticsearch.xpack.ml.process.NativeStorageProvider; import org.elasticsearch.xpack.ml.process.NativeStorageProvider;
import org.junit.Before; import org.junit.Before;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -118,7 +118,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
private AutodetectCommunicator autodetectCommunicator; private AutodetectCommunicator autodetectCommunicator;
private AutodetectProcessFactory autodetectFactory; private AutodetectProcessFactory autodetectFactory;
private NormalizerFactory normalizerFactory; private NormalizerFactory normalizerFactory;
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private ClusterState clusterState; private ClusterState clusterState;
private ClusterService clusterService; private ClusterService clusterService;
private NativeStorageProvider nativeStorageProvider; private NativeStorageProvider nativeStorageProvider;
@ -148,7 +148,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
autodetectCommunicator = mock(AutodetectCommunicator.class); autodetectCommunicator = mock(AutodetectCommunicator.class);
autodetectFactory = mock(AutodetectProcessFactory.class); autodetectFactory = mock(AutodetectProcessFactory.class);
normalizerFactory = mock(NormalizerFactory.class); normalizerFactory = mock(NormalizerFactory.class);
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
clusterService = mock(ClusterService.class); clusterService = mock(ClusterService.class);
ClusterSettings clusterSettings = ClusterSettings clusterSettings =
new ClusterSettings(Settings.EMPTY, Collections.singleton(MachineLearning.MAX_OPEN_JOBS_PER_NODE)); new ClusterSettings(Settings.EMPTY, Collections.singleton(MachineLearning.MAX_OPEN_JOBS_PER_NODE));

View File

@ -37,7 +37,7 @@ import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcess; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcess;
import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer; import org.elasticsearch.xpack.ml.job.process.normalizer.Renormalizer;
import org.elasticsearch.xpack.ml.job.results.AutodetectResult; import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.mockito.InOrder; import org.mockito.InOrder;
@ -75,7 +75,7 @@ public class AutodetectResultProcessorTests extends ESTestCase {
private ThreadPool threadPool; private ThreadPool threadPool;
private Client client; private Client client;
private Auditor auditor; private AnomalyDetectionAuditor auditor;
private Renormalizer renormalizer; private Renormalizer renormalizer;
private JobResultsPersister persister; private JobResultsPersister persister;
private JobResultsPersister.Builder bulkBuilder; private JobResultsPersister.Builder bulkBuilder;
@ -91,7 +91,7 @@ public class AutodetectResultProcessorTests extends ESTestCase {
threadPool = mock(ThreadPool.class); threadPool = mock(ThreadPool.class);
when(client.threadPool()).thenReturn(threadPool); when(client.threadPool()).thenReturn(threadPool);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
auditor = mock(Auditor.class); auditor = mock(AnomalyDetectionAuditor.class);
renormalizer = mock(Renormalizer.class); renormalizer = mock(Renormalizer.class);
persister = mock(JobResultsPersister.class); persister = mock(JobResultsPersister.class);
bulkBuilder = mock(JobResultsPersister.Builder.class); bulkBuilder = mock(JobResultsPersister.Builder.class);

View File

@ -20,7 +20,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.config.JobTests; import org.elasticsearch.xpack.core.ml.job.config.JobTests;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
import org.elasticsearch.xpack.ml.notifications.Auditor; import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before; import org.junit.Before;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
@ -163,6 +163,6 @@ public class ExpiredResultsRemoverTests extends ESTestCase {
} }
private ExpiredResultsRemover createExpiredResultsRemover() { private ExpiredResultsRemover createExpiredResultsRemover() {
return new ExpiredResultsRemover(client, mock(Auditor.class)); return new ExpiredResultsRemover(client, mock(AnomalyDetectionAuditor.class));
} }
} }