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.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 String nodeName;
private final String auditIndex;
private final String executionOrigin;
private final AbstractAuditMessage.AbstractBuilder<T> messageBuilder;
public Auditor(Client client,
String nodeName,
String auditIndex,
String executionOrigin,
AbstractAuditMessage.AbstractBuilder<T> messageBuilder) {
public AbstractAuditor(Client client,
String nodeName,
String auditIndex,
String executionOrigin,
AbstractAuditMessage.AbstractBuilder<T> messageBuilder) {
this.client = Objects.requireNonNull(client);
this.nodeName = Objects.requireNonNull(nodeName);
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.ReservedFieldNames;
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 java.io.IOException;
@ -1122,10 +1122,10 @@ public class ElasticsearchMappings {
.startObject(Job.ID.getPreferredName())
.field(TYPE, KEYWORD)
.endObject()
.startObject(AuditMessage.LEVEL.getPreferredName())
.startObject(AnomalyDetectionAuditMessage.LEVEL.getPreferredName())
.field(TYPE, KEYWORD)
.endObject()
.startObject(AuditMessage.MESSAGE.getPreferredName())
.startObject(AnomalyDetectionAuditMessage.MESSAGE.getPreferredName())
.field(TYPE, TEXT)
.startObject(FIELDS)
.startObject(RAW)
@ -1133,10 +1133,10 @@ public class ElasticsearchMappings {
.endObject()
.endObject()
.endObject()
.startObject(AuditMessage.TIMESTAMP.getPreferredName())
.startObject(AnomalyDetectionAuditMessage.TIMESTAMP.getPreferredName())
.field(TYPE, DATE)
.endObject()
.startObject(AuditMessage.NODE_NAME.getPreferredName())
.startObject(AnomalyDetectionAuditMessage.NODE_NAME.getPreferredName())
.field(TYPE, KEYWORD)
.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.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",
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 {
PARSER.declareString(optionalConstructorArg(), Job.ID);
@ -41,11 +41,11 @@ public class AuditMessage extends AbstractAuditMessage {
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);
}
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);
}
@ -54,11 +54,11 @@ public class AuditMessage extends AbstractAuditMessage {
return Job.ID.getPreferredName();
}
public static AbstractBuilder<AuditMessage> builder() {
return new AbstractBuilder<AuditMessage>() {
public static AbstractBuilder<AnomalyDetectionAuditMessage> builder() {
return new AbstractBuilder<AnomalyDetectionAuditMessage>() {
@Override
protected AuditMessage newMessage(Level level, String resourceId, String message, String nodeName) {
return new AuditMessage(resourceId, message, level, nodeName);
protected AnomalyDetectionAuditMessage newMessage(Level level, String resourceId, String message, String 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.when;
public class AuditorTests extends ESTestCase {
private Client client;
private ArgumentCaptor<IndexRequest> indexRequestCaptor;
public class AbstractAuditorTests extends ESTestCase {
private static final String TEST_NODE_NAME = "node_1";
private static final String TEST_ORIGIN = "test_origin";
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
public void setUpMocks() {
client = mock(Client.class);
@ -47,7 +48,7 @@ public class AuditorTests extends ESTestCase {
}
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");
verify(client).index(indexRequestCaptor.capture(), any());
@ -61,7 +62,7 @@ public class AuditorTests extends ESTestCase {
}
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");
verify(client).index(indexRequestCaptor.capture(), any());
@ -75,7 +76,7 @@ public class AuditorTests extends ESTestCase {
}
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");
verify(client).index(indexRequestCaptor.capture(), any());
@ -93,4 +94,10 @@ public class AuditorTests extends ESTestCase {
.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, msg.streamInput());
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 void testFromString() {
assertEquals(Level.INFO, Level.fromString("info"));
assertEquals(Level.INFO, Level.fromString("INFO"));
assertEquals(Level.WARNING, Level.fromString("warning"));
assertEquals(Level.WARNING, Level.fromString("WARNING"));
assertEquals(Level.ERROR, Level.fromString("error"));
assertEquals(Level.ERROR, Level.fromString("ERROR"));
assertThat(Level.fromString("info"), equalTo(Level.INFO));
assertThat(Level.fromString("INFO"), equalTo(Level.INFO));
assertThat(Level.fromString("warning"), equalTo(Level.WARNING));
assertThat(Level.fromString("WARNING"), equalTo(Level.WARNING));
assertThat(Level.fromString("error"), equalTo(Level.ERROR));
assertThat(Level.fromString("ERROR"), equalTo(Level.ERROR));
}
public void testToString() {
assertEquals("info", Level.INFO.toString());
assertEquals("warning", Level.WARNING.toString());
assertEquals("error", Level.ERROR.toString());
assertThat(Level.INFO.toString(), equalTo("info"));
assertThat(Level.WARNING.toString(), equalTo("warning"));
assertThat(Level.ERROR.toString(), equalTo("error"));
}
public void testValidOrdinals() {

View File

@ -68,7 +68,7 @@ public class DataFrameAuditorIT extends DataFrameRestTestCase {
assertBusy(() -> {
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.
assertBusy(() -> {
refreshIndex(DataFrameInternalIndex.AUDIT_INDEX);

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.dataframe.notifications;
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.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
*/
public class DataFrameAuditor extends Auditor<DataFrameAuditMessage> {
public class DataFrameAuditor extends AbstractAuditor<DataFrameAuditMessage> {
public DataFrameAuditor(Client client, String nodeName) {
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.NormalizerFactory;
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.NativeController;
import org.elasticsearch.xpack.ml.process.NativeControllerHolder;
@ -469,7 +469,7 @@ public class MachineLearning extends Plugin implements ActionPlugin, AnalysisPlu
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);
JobResultsPersister jobResultsPersister = new JobResultsPersister(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.action.OpenJobAction;
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;
@ -29,18 +29,20 @@ import java.util.Objects;
public class MlAssignmentNotifier implements ClusterStateListener {
private static final Logger logger = LogManager.getLogger(MlAssignmentNotifier.class);
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final MlConfigMigrator mlConfigMigrator;
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.mlConfigMigrator = new MlConfigMigrator(settings, client, clusterService);
this.threadPool = threadPool;
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.mlConfigMigrator = mlConfigMigrator;
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.datafeed.persistence.DatafeedConfigProvider;
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.Collection;
@ -53,14 +53,14 @@ public class TransportCloseJobAction extends TransportTasksAction<TransportOpenJ
private final ThreadPool threadPool;
private final Client client;
private final ClusterService clusterService;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final PersistentTasksService persistentTasksService;
private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider;
@Inject
public TransportCloseJobAction(TransportService transportService, ThreadPool threadPool, ActionFilters actionFilters,
ClusterService clusterService, Client client, Auditor auditor,
ClusterService clusterService, Client client, AnomalyDetectionAuditor auditor,
PersistentTasksService persistentTasksService, JobConfigProvider jobConfigProvider,
DatafeedConfigProvider datafeedConfigProvider) {
// 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,
PersistentTasksCustomMetaData tasks, Auditor auditor) {
static TransportCloseJobAction.WaitForCloseRequest buildWaitForCloseRequest(List<String> openJobIds,
List<String> closingJobIds,
PersistentTasksCustomMetaData tasks,
AnomalyDetectionAuditor auditor) {
TransportCloseJobAction.WaitForCloseRequest waitForCloseRequest = new TransportCloseJobAction.WaitForCloseRequest();
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.MlDataRemover;
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 java.util.Arrays;
@ -54,7 +54,7 @@ public class TransportDeleteExpiredDataAction extends HandledTransportAction<Del
}
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(
new ExpiredResultsRemover(client, auditor),
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.JobDataDeleter;
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.utils.MlIndicesUtils;
@ -94,7 +94,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction<DeleteJo
private final Client client;
private final PersistentTasksService persistentTasksService;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final JobResultsProvider jobResultsProvider;
private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider;
@ -113,7 +113,7 @@ public class TransportDeleteJobAction extends TransportMasterNodeAction<DeleteJo
public TransportDeleteJobAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, PersistentTasksService persistentTasksService,
Client client, Auditor auditor, JobResultsProvider jobResultsProvider,
Client client, AnomalyDetectionAuditor auditor, JobResultsProvider jobResultsProvider,
JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider,
MlMemoryTracker memoryTracker) {
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.persistence.JobDataDeleter;
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.List;
@ -32,12 +32,12 @@ public class TransportDeleteModelSnapshotAction extends HandledTransportAction<D
private final Client client;
private final JobManager jobManager;
private final JobResultsProvider jobResultsProvider;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
@Inject
public TransportDeleteModelSnapshotAction(TransportService transportService, ActionFilters actionFilters,
JobResultsProvider jobResultsProvider, Client client, JobManager jobManager,
Auditor auditor) {
AnomalyDetectionAuditor auditor) {
super(DeleteModelSnapshotAction.NAME, transportService, actionFilters, DeleteModelSnapshotAction.Request::new);
this.client = client;
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.ml.MachineLearning;
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> {
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
@Inject
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,
KillProcessAction.Response::new, MachineLearning.UTILITY_THREAD_POOL_NAME, processManager);
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.persistence.DatafeedConfigProvider;
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.util.ArrayList;
@ -81,7 +81,7 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction<Star
private final PersistentTasksService persistentTasksService;
private final JobConfigProvider jobConfigProvider;
private final DatafeedConfigProvider datafeedConfigProvider;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final MlConfigMigrationEligibilityCheck migrationEligibilityCheck;
private final NamedXContentRegistry xContentRegistry;
@ -91,7 +91,7 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction<Star
PersistentTasksService persistentTasksService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
Client client, JobConfigProvider jobConfigProvider, DatafeedConfigProvider datafeedConfigProvider,
Auditor auditor, NamedXContentRegistry xContentRegistry) {
AnomalyDetectionAuditor auditor, NamedXContentRegistry xContentRegistry) {
super(StartDatafeedAction.NAME, transportService, clusterService, threadPool, actionFilters, StartDatafeedAction.Request::new,
indexNameExpressionResolver);
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
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<>();
deprecationWarnings.addAll(datafeed.getAggDeprecations(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.DelayedDataDetectorFactory.BucketWithMissingData;
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.InputStream;
@ -54,7 +54,7 @@ class DatafeedJob {
private static final int NEXT_TASK_DELAY_MS = 100;
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 DataDescription dataDescription;
private final long frequencyMs;
@ -76,7 +76,7 @@ class DatafeedJob {
DatafeedJob(String jobId, DataDescription dataDescription, long frequencyMs, long queryDelayMs,
DataExtractorFactory dataExtractorFactory, DatafeedTimingStatsReporter timingStatsReporter, Client client,
Auditor auditor, Supplier<Long> currentTimeSupplier, DelayedDataDetector delayedDataDetector,
AnomalyDetectionAuditor auditor, Supplier<Long> currentTimeSupplier, DelayedDataDetector delayedDataDetector,
long latestFinalBucketEndTimeMs, long latestRecordTimeMs) {
this.jobId = jobId;
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.JobResultsPersister;
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.Objects;
@ -39,16 +39,17 @@ public class DatafeedJobBuilder {
private final Client client;
private final NamedXContentRegistry xContentRegistry;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final Supplier<Long> currentTimeSupplier;
private final JobConfigProvider jobConfigProvider;
private final JobResultsProvider jobResultsProvider;
private final DatafeedConfigProvider datafeedConfigProvider;
private final JobResultsPersister jobResultsPersister;
public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, Auditor auditor, Supplier<Long> currentTimeSupplier,
JobConfigProvider jobConfigProvider, JobResultsProvider jobResultsProvider,
DatafeedConfigProvider datafeedConfigProvider, JobResultsPersister jobResultsPersister) {
public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, AnomalyDetectionAuditor auditor,
Supplier<Long> currentTimeSupplier, JobConfigProvider jobConfigProvider,
JobResultsProvider jobResultsProvider, DatafeedConfigProvider datafeedConfigProvider,
JobResultsPersister jobResultsPersister) {
this.client = client;
this.xContentRegistry = Objects.requireNonNull(xContentRegistry);
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.action.TransportStartDatafeedAction;
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.Iterator;
@ -58,7 +58,7 @@ public class DatafeedManager {
private final ClusterService clusterService;
private final ThreadPool threadPool;
private final Supplier<Long> currentTimeSupplier;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
// Use allocationId as key instead of datafeed id
private final ConcurrentMap<Long, Holder> runningDatafeedsOnThisNode = new ConcurrentHashMap<>();
private final DatafeedJobBuilder datafeedJobBuilder;
@ -66,7 +66,8 @@ public class DatafeedManager {
private final AutodetectProcessManager autodetectProcessManager;
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.clusterService = Objects.requireNonNull(clusterService);
this.threadPool = threadPool;

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.datafeed;
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;
@ -26,7 +26,7 @@ class ProblemTracker {
private static final int EMPTY_DATA_WARN_COUNT = 10;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final String jobId;
private volatile boolean hasProblems;
@ -34,7 +34,7 @@ class ProblemTracker {
private volatile String previousProblem;
private volatile int emptyDataCount;
ProblemTracker(Auditor auditor, String jobId) {
ProblemTracker(AnomalyDetectionAuditor auditor, String jobId) {
this.auditor = Objects.requireNonNull(auditor);
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.JobResultsProvider;
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 java.io.IOException;
@ -91,7 +91,7 @@ public class JobManager {
private final JobResultsProvider jobResultsProvider;
private final JobResultsPersister jobResultsPersister;
private final ClusterService clusterService;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final Client client;
private final ThreadPool threadPool;
private final UpdateJobProcessNotifier updateJobProcessNotifier;
@ -104,8 +104,9 @@ public class JobManager {
* Create a JobManager
*/
public JobManager(Environment environment, Settings settings, JobResultsProvider jobResultsProvider,
JobResultsPersister jobResultsPersister, ClusterService clusterService, Auditor auditor, ThreadPool threadPool,
Client client, UpdateJobProcessNotifier updateJobProcessNotifier, NamedXContentRegistry xContentRegistry) {
JobResultsPersister jobResultsPersister, ClusterService clusterService, AnomalyDetectionAuditor auditor,
ThreadPool threadPool, Client client, UpdateJobProcessNotifier updateJobProcessNotifier,
NamedXContentRegistry xContentRegistry) {
this.environment = environment;
this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider);
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.ScoresUpdater;
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 java.io.IOException;
@ -109,12 +109,12 @@ public class AutodetectProcessManager implements ClusterStateListener {
private final NamedXContentRegistry xContentRegistry;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private volatile boolean upgradeInProgress;
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,
JobDataCountsPersister jobDataCountsPersister, AutodetectProcessFactory autodetectProcessFactory,
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.normalizer.Renormalizer;
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.util.Iterator;
@ -74,7 +74,7 @@ public class AutodetectResultProcessor {
private static final Logger LOGGER = LogManager.getLogger(AutodetectResultProcessor.class);
private final Client client;
private final Auditor auditor;
private final AnomalyDetectionAuditor auditor;
private final String jobId;
private final Renormalizer renormalizer;
private final JobResultsPersister persister;
@ -96,7 +96,7 @@ public class AutodetectResultProcessor {
private volatile ModelSizeStats latestModelSizeStats;
public AutodetectResultProcessor(Client client,
Auditor auditor,
AnomalyDetectionAuditor auditor,
String jobId,
Renormalizer renormalizer,
JobResultsPersister persister,
@ -107,7 +107,7 @@ public class AutodetectResultProcessor {
}
// 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,
TimingStats timingStats,
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.ForecastRequestStats;
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.ZoneOffset;
@ -46,9 +46,9 @@ public class ExpiredResultsRemover extends AbstractExpiredJobDataRemover {
private static final Logger LOGGER = LogManager.getLogger(ExpiredResultsRemover.class);
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);
this.client = Objects.requireNonNull(client);
this.auditor = Objects.requireNonNull(auditor);

View File

@ -6,14 +6,15 @@
package org.elasticsearch.xpack.ml.notifications;
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.AuditMessage;
import org.elasticsearch.xpack.core.ml.notifications.AnomalyDetectionAuditMessage;
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) {
super(client, nodeName, AuditorField.NOTIFICATIONS_INDEX, ML_ORIGIN, AuditMessage.builder());
public AnomalyDetectionAuditor(Client client, String nodeName) {
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.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.ml.notifications.Auditor;
import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
import org.junit.Before;
import java.net.InetAddress;
@ -38,7 +38,7 @@ import static org.mockito.Mockito.when;
public class MlAssignmentNotifierTests extends ESTestCase {
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private ClusterService clusterService;
private ThreadPool threadPool;
private MlConfigMigrator configMigrator;
@ -46,7 +46,7 @@ public class MlAssignmentNotifierTests extends ESTestCase {
@Before
@SuppressWarnings("unchecked")
private void setupMocks() {
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
clusterService = mock(ClusterService.class);
threadPool = mock(ThreadPool.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.ml.datafeed.persistence.DatafeedConfigProvider;
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.junit.Before;
@ -255,14 +255,15 @@ public class TransportCloseJobActionTests extends ESTestCase {
addJobTask("closingjob1", null, JobState.CLOSING, tasksBuilder);
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.persistentTaskIds,
Arrays.asList("job-openjob1", "job-openjob2", "job-closingjob1"));
assertTrue(waitForCloseRequest.hasJobsToWaitFor());
waitForCloseRequest = TransportCloseJobAction.buildWaitForCloseRequest(Collections.emptyList(), Collections.emptyList(),
tasksBuilder.build(), mock(Auditor.class));
tasksBuilder.build(), mock(AnomalyDetectionAuditor.class));
assertFalse(waitForCloseRequest.hasJobsToWaitFor());
}
@ -275,7 +276,7 @@ public class TransportCloseJobActionTests extends ESTestCase {
private TransportCloseJobAction createAction() {
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);
}

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.ml.datafeed.DatafeedManager;
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.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 Query")).when(config).getQueryDeprecations(any(NamedXContentRegistry.class));
Auditor auditor = mock(Auditor.class);
AnomalyDetectionAuditor auditor = mock(AnomalyDetectionAuditor.class);
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).getQueryDeprecations(any(NamedXContentRegistry.class));
Auditor auditor = mock(Auditor.class);
AnomalyDetectionAuditor auditor = mock(AnomalyDetectionAuditor.class);
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.JobResultsPersister;
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 java.util.Collections;
@ -44,7 +44,7 @@ import static org.mockito.Mockito.when;
public class DatafeedJobBuilderTests extends ESTestCase {
private Client client;
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private Consumer<Exception> taskHandler;
private JobResultsProvider jobResultsProvider;
private JobConfigProvider jobConfigProvider;
@ -61,7 +61,7 @@ public class DatafeedJobBuilderTests extends ESTestCase {
when(client.threadPool()).thenReturn(threadPool);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
when(client.settings()).thenReturn(Settings.EMPTY);
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
taskHandler = mock(Consumer.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.core.ml.job.config.DataDescription;
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.junit.Before;
import org.mockito.ArgumentCaptor;
@ -70,7 +70,7 @@ public class DatafeedJobTests extends ESTestCase {
private static final String jobId = "_job_id";
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private DataExtractorFactory dataExtractorFactory;
private DataExtractor dataExtractor;
private DatafeedTimingStatsReporter timingStatsReporter;
@ -90,7 +90,7 @@ public class DatafeedJobTests extends ESTestCase {
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
dataExtractorFactory = mock(DataExtractorFactory.class);
dataExtractor = mock(DataExtractor.class);
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.TransportStartDatafeedActionTests;
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.mockito.ArgumentCaptor;
@ -71,7 +71,7 @@ public class DatafeedManagerTests extends ESTestCase {
private DatafeedJob datafeedJob;
private DatafeedManager datafeedManager;
private long currentTime = 120000;
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private ArgumentCaptor<ClusterStateListener> capturedClusterStateListener = ArgumentCaptor.forClass(ClusterStateListener.class);
private AtomicBoolean hasOpenAutodetectCommunicator;
@ -97,9 +97,9 @@ public class DatafeedManagerTests extends ESTestCase {
DiscoveryNode dNode = mock(DiscoveryNode.class);
when(dNode.getName()).thenReturn("this_node_has_a_name");
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);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
ExecutorService executorService = mock(ExecutorService.class);

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.datafeed;
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.mockito.Mockito;
@ -16,13 +16,13 @@ import static org.mockito.Mockito.verify;
public class ProblemTrackerTests extends ESTestCase {
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private ProblemTracker problemTracker;
@Before
public void setUpTests() {
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
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.ml.LocalStateMachineLearning;
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 java.util.Collection;
@ -53,7 +53,7 @@ public class AnnotationIndexIT extends MlSingleNodeTestCase {
public void testCreatedWhenAfterOtherMlIndex() throws Exception {
Auditor auditor = new Auditor(client(), "node_1");
AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), "node_1");
auditor.info("whatever", "blah");
// 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.CategoryDefinitionTests;
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.Before;
@ -87,7 +87,7 @@ public class AutodetectResultProcessorIT extends MlSingleNodeTestCase {
public void createComponents() throws Exception {
Settings.Builder builder = Settings.builder()
.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());
renormalizer = mock(Renormalizer.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.MockClientBuilder;
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.mockito.ArgumentCaptor;
import org.mockito.Matchers;
@ -105,7 +105,7 @@ public class JobManagerTests extends ESTestCase {
private ThreadPool threadPool;
private JobResultsProvider jobResultsProvider;
private JobResultsPersister jobResultsPersister;
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private UpdateJobProcessNotifier updateJobProcessNotifier;
@Override
@ -126,7 +126,7 @@ public class JobManagerTests extends ESTestCase {
jobResultsProvider = mock(JobResultsProvider.class);
jobResultsPersister = mock(JobResultsPersister.class);
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
updateJobProcessNotifier = mock(UpdateJobProcessNotifier.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.TimeRange;
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.junit.Before;
import org.mockito.ArgumentCaptor;
@ -118,7 +118,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
private AutodetectCommunicator autodetectCommunicator;
private AutodetectProcessFactory autodetectFactory;
private NormalizerFactory normalizerFactory;
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private ClusterState clusterState;
private ClusterService clusterService;
private NativeStorageProvider nativeStorageProvider;
@ -148,7 +148,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
autodetectCommunicator = mock(AutodetectCommunicator.class);
autodetectFactory = mock(AutodetectProcessFactory.class);
normalizerFactory = mock(NormalizerFactory.class);
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
clusterService = mock(ClusterService.class);
ClusterSettings clusterSettings =
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.normalizer.Renormalizer;
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.Before;
import org.mockito.InOrder;
@ -75,7 +75,7 @@ public class AutodetectResultProcessorTests extends ESTestCase {
private ThreadPool threadPool;
private Client client;
private Auditor auditor;
private AnomalyDetectionAuditor auditor;
private Renormalizer renormalizer;
private JobResultsPersister persister;
private JobResultsPersister.Builder bulkBuilder;
@ -91,7 +91,7 @@ public class AutodetectResultProcessorTests extends ESTestCase {
threadPool = mock(ThreadPool.class);
when(client.threadPool()).thenReturn(threadPool);
when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
auditor = mock(Auditor.class);
auditor = mock(AnomalyDetectionAuditor.class);
renormalizer = mock(Renormalizer.class);
persister = mock(JobResultsPersister.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.JobTests;
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.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@ -163,6 +163,6 @@ public class ExpiredResultsRemoverTests extends ESTestCase {
}
private ExpiredResultsRemover createExpiredResultsRemover() {
return new ExpiredResultsRemover(client, mock(Auditor.class));
return new ExpiredResultsRemover(client, mock(AnomalyDetectionAuditor.class));
}
}