Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Rename JobProvider to JobResultsProvider #32551

Merged
merged 1 commit into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
import org.elasticsearch.xpack.ml.job.categorization.MlClassicTokenizer;
import org.elasticsearch.xpack.ml.job.categorization.MlClassicTokenizerFactory;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.process.DataCountsReporter;
import org.elasticsearch.xpack.ml.job.process.NativeController;
Expand Down Expand Up @@ -357,9 +357,9 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
}

Auditor auditor = new Auditor(client, clusterService.nodeName());
JobProvider jobProvider = new JobProvider(client, settings);
JobResultsProvider jobResultsProvider = new JobResultsProvider(client, settings);
UpdateJobProcessNotifier notifier = new UpdateJobProcessNotifier(settings, client, clusterService, threadPool);
JobManager jobManager = new JobManager(env, settings, jobProvider, clusterService, auditor, client, notifier);
JobManager jobManager = new JobManager(env, settings, jobResultsProvider, clusterService, auditor, client, notifier);

JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(settings, client);
JobResultsPersister jobResultsPersister = new JobResultsPersister(settings, client);
Expand Down Expand Up @@ -390,10 +390,10 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
NormalizerFactory normalizerFactory = new NormalizerFactory(normalizerProcessFactory,
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME));
AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(env, settings, client, threadPool,
jobManager, jobProvider, jobResultsPersister, jobDataCountsPersister, autodetectProcessFactory,
jobManager, jobResultsProvider, jobResultsPersister, jobDataCountsPersister, autodetectProcessFactory,
normalizerFactory, xContentRegistry, auditor);
this.autodetectProcessManager.set(autodetectProcessManager);
DatafeedJobBuilder datafeedJobBuilder = new DatafeedJobBuilder(client, jobProvider, auditor, System::currentTimeMillis);
DatafeedJobBuilder datafeedJobBuilder = new DatafeedJobBuilder(client, jobResultsProvider, auditor, System::currentTimeMillis);
DatafeedManager datafeedManager = new DatafeedManager(threadPool, client, clusterService, datafeedJobBuilder,
System::currentTimeMillis, auditor);
this.datafeedManager.set(datafeedManager);
Expand All @@ -408,7 +408,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster

return Arrays.asList(
mlLifeCycleService,
jobProvider,
jobResultsProvider,
jobManager,
autodetectProcessManager,
new MlInitializationService(settings, threadPool, clusterService, client),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.xpack.core.ml.action.DeleteCalendarAction;
import org.elasticsearch.xpack.core.ml.calendars.Calendar;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;

import java.util.function.Supplier;

Expand All @@ -35,16 +35,17 @@ public class TransportDeleteCalendarAction extends HandledTransportAction<Delete

private final Client client;
private final JobManager jobManager;
private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;

@Inject
public TransportDeleteCalendarAction(Settings settings, TransportService transportService,
ActionFilters actionFilters, Client client, JobManager jobManager, JobProvider jobProvider) {
ActionFilters actionFilters, Client client, JobManager jobManager,
JobResultsProvider jobResultsProvider) {
super(settings, DeleteCalendarAction.NAME, transportService, actionFilters,
(Supplier<DeleteCalendarAction.Request>) DeleteCalendarAction.Request::new);
this.client = client;
this.jobManager = jobManager;
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
}

@Override
Expand All @@ -70,7 +71,7 @@ protected void doExecute(Task task, DeleteCalendarAction.Request request, Action
listener::onFailure
);

jobProvider.calendar(calendarId, calendarListener);
jobResultsProvider.calendar(calendarId, calendarListener);
}

private DeleteByQueryRequest buildDeleteByQuery(String calendarId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.elasticsearch.xpack.core.ml.calendars.Calendar;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;

import java.util.Map;

Expand All @@ -37,16 +37,16 @@ public class TransportDeleteCalendarEventAction extends HandledTransportAction<D
DeleteCalendarEventAction.Response> {

private final Client client;
private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
private final JobManager jobManager;

@Inject
public TransportDeleteCalendarEventAction(Settings settings, TransportService transportService, ActionFilters actionFilters,
Client client, JobProvider jobProvider, JobManager jobManager) {
Client client, JobResultsProvider jobResultsProvider, JobManager jobManager) {
super(settings, DeleteCalendarEventAction.NAME, transportService, actionFilters,
DeleteCalendarEventAction.Request::new);
this.client = client;
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
this.jobManager = jobManager;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ protected void doExecute(Task task, DeleteCalendarEventAction.Request request,
}, listener::onFailure);

// Get the calendar first so we check the calendar exists before checking the event exists
jobProvider.calendar(request.getCalendarId(), calendarListener);
jobResultsProvider.calendar(request.getCalendarId(), calendarListener);
}

private void deleteEvent(String eventId, Calendar calendar, ActionListener<DeleteCalendarEventAction.Response> listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.elasticsearch.xpack.core.ml.job.persistence.JobDataDeleter;
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSnapshot;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.notifications.Auditor;

import java.util.Collections;
Expand All @@ -32,17 +32,18 @@ public class TransportDeleteModelSnapshotAction extends HandledTransportAction<D
DeleteModelSnapshotAction.Response> {

private final Client client;
private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
private final ClusterService clusterService;
private final Auditor auditor;

@Inject
public TransportDeleteModelSnapshotAction(Settings settings, TransportService transportService, ActionFilters actionFilters,
JobProvider jobProvider, ClusterService clusterService, Client client, Auditor auditor) {
JobResultsProvider jobResultsProvider, ClusterService clusterService, Client client,
Auditor auditor) {
super(settings, DeleteModelSnapshotAction.NAME, transportService, actionFilters,
DeleteModelSnapshotAction.Request::new);
this.client = client;
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
this.clusterService = clusterService;
this.auditor = auditor;
}
Expand All @@ -51,7 +52,7 @@ public TransportDeleteModelSnapshotAction(Settings settings, TransportService tr
protected void doExecute(Task task, DeleteModelSnapshotAction.Request request,
ActionListener<DeleteModelSnapshotAction.Response> listener) {
// Verify the snapshot exists
jobProvider.modelSnapshots(
jobResultsProvider.modelSnapshots(
request.getJobId(), 0, 1, null, null, null, true, request.getSnapshotId(),
page -> {
List<ModelSnapshot> deleteCandidates = page.results();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.xpack.core.ml.job.results.ForecastRequestStats;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.ForecastParams;

Expand All @@ -40,15 +40,15 @@ public class TransportForecastJobAction extends TransportJobTaskAction<ForecastJ

private static final ByteSizeValue FORECAST_LOCAL_STORAGE_LIMIT = new ByteSizeValue(500, ByteSizeUnit.MB);

private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
@Inject
public TransportForecastJobAction(Settings settings, TransportService transportService,
ClusterService clusterService, ActionFilters actionFilters,
JobProvider jobProvider, AutodetectProcessManager processManager) {
JobResultsProvider jobResultsProvider, AutodetectProcessManager processManager) {
super(settings, ForecastJobAction.NAME, clusterService, transportService, actionFilters,
ForecastJobAction.Request::new, ForecastJobAction.Response::new,
ThreadPool.Names.SAME, processManager);
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
// ThreadPool.Names.SAME, because operations is executed by autodetect worker thread
}

Expand Down Expand Up @@ -107,7 +107,7 @@ protected void taskOperation(ForecastJobAction.Request request, TransportOpenJob
}
};

jobProvider.getForecastRequestStats(request.getJobId(), params.getForecastId(),
jobResultsProvider.getForecastRequestStats(request.getJobId(), params.getForecastId(),
forecastRequestStatsHandler, listener::onFailure);
} else {
listener.onFailure(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@
import org.elasticsearch.xpack.core.ml.action.GetBucketsAction;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.BucketsQueryBuilder;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;

import java.util.function.Supplier;

public class TransportGetBucketsAction extends HandledTransportAction<GetBucketsAction.Request, GetBucketsAction.Response> {

private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
private final JobManager jobManager;
private final Client client;

@Inject
public TransportGetBucketsAction(Settings settings, TransportService transportService,
ActionFilters actionFilters, JobProvider jobProvider, JobManager jobManager, Client client) {
ActionFilters actionFilters, JobResultsProvider jobResultsProvider,
JobManager jobManager, Client client) {
super(settings, GetBucketsAction.NAME, transportService, actionFilters,
(Supplier<GetBucketsAction.Request>) GetBucketsAction.Request::new);
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
this.jobManager = jobManager;
this.client = client;
}
Expand Down Expand Up @@ -59,7 +60,7 @@ protected void doExecute(Task task, GetBucketsAction.Request request, ActionList
query.start(request.getStart());
query.end(request.getEnd());
}
jobProvider.buckets(request.getJobId(), query, q ->
jobResultsProvider.buckets(request.getJobId(), query, q ->
listener.onResponse(new GetBucketsAction.Response(q)), listener::onFailure, client);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.xpack.core.ml.calendars.ScheduledEvent;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.persistence.ScheduledEventsQueryBuilder;

import java.util.Collections;
Expand All @@ -31,15 +31,16 @@
public class TransportGetCalendarEventsAction extends HandledTransportAction<GetCalendarEventsAction.Request,
GetCalendarEventsAction.Response> {

private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
private final ClusterService clusterService;

@Inject
public TransportGetCalendarEventsAction(Settings settings, TransportService transportService,
ActionFilters actionFilters, ClusterService clusterService, JobProvider jobProvider) {
ActionFilters actionFilters, ClusterService clusterService,
JobResultsProvider jobResultsProvider) {
super(settings, GetCalendarEventsAction.NAME, transportService, actionFilters,
(Supplier<GetCalendarEventsAction.Request>) GetCalendarEventsAction.Request::new);
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
this.clusterService = clusterService;
}

Expand Down Expand Up @@ -85,9 +86,9 @@ protected void doExecute(Task task, GetCalendarEventsAction.Request request,
jobGroups = job.getGroups();
}

jobProvider.scheduledEventsForJob(requestId, jobGroups, query, eventsListener);
jobResultsProvider.scheduledEventsForJob(requestId, jobGroups, query, eventsListener);
} else {
jobProvider.scheduledEvents(query, eventsListener);
jobResultsProvider.scheduledEvents(query, eventsListener);
}
},
listener::onFailure);
Expand All @@ -101,7 +102,7 @@ private void checkCalendarExists(String calendarId, ActionListener<Boolean> list
return;
}

jobProvider.calendar(calendarId, ActionListener.wrap(
jobResultsProvider.calendar(calendarId, ActionListener.wrap(
c -> listener.onResponse(true),
listener::onFailure
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
import org.elasticsearch.xpack.core.ml.action.util.QueryPage;
import org.elasticsearch.xpack.core.ml.calendars.Calendar;
import org.elasticsearch.xpack.ml.job.persistence.CalendarQueryBuilder;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;

import java.util.Collections;

public class TransportGetCalendarsAction extends HandledTransportAction<GetCalendarsAction.Request, GetCalendarsAction.Response> {

private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;

@Inject
public TransportGetCalendarsAction(Settings settings, TransportService transportService,
ActionFilters actionFilters, JobProvider jobProvider) {
ActionFilters actionFilters, JobResultsProvider jobResultsProvider) {
super(settings, GetCalendarsAction.NAME, transportService, actionFilters,
GetCalendarsAction.Request::new);
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
}

@Override
Expand All @@ -49,7 +49,7 @@ protected void doExecute(Task task, GetCalendarsAction.Request request, ActionLi

private void getCalendar(String calendarId, ActionListener<GetCalendarsAction.Response> listener) {

jobProvider.calendar(calendarId, ActionListener.wrap(
jobResultsProvider.calendar(calendarId, ActionListener.wrap(
calendar -> {
QueryPage<Calendar> page = new QueryPage<>(Collections.singletonList(calendar), 1, Calendar.RESULTS_FIELD);
listener.onResponse(new GetCalendarsAction.Response(page));
Expand All @@ -60,7 +60,7 @@ private void getCalendar(String calendarId, ActionListener<GetCalendarsAction.Re

private void getCalendars(PageParams pageParams, ActionListener<GetCalendarsAction.Response> listener) {
CalendarQueryBuilder query = new CalendarQueryBuilder().pageParams(pageParams).sort(true);
jobProvider.calendars(query, ActionListener.wrap(
jobResultsProvider.calendars(query, ActionListener.wrap(
calendars -> {
listener.onResponse(new GetCalendarsAction.Response(calendars));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.ml.action.GetCategoriesAction;
import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;

import java.util.function.Supplier;

public class TransportGetCategoriesAction extends HandledTransportAction<GetCategoriesAction.Request, GetCategoriesAction.Response> {

private final JobProvider jobProvider;
private final JobResultsProvider jobResultsProvider;
private final Client client;
private final JobManager jobManager;

@Inject
public TransportGetCategoriesAction(Settings settings, TransportService transportService,
ActionFilters actionFilters, JobProvider jobProvider, Client client, JobManager jobManager) {
ActionFilters actionFilters, JobResultsProvider jobResultsProvider,
Client client, JobManager jobManager) {
super(settings, GetCategoriesAction.NAME, transportService, actionFilters,
(Supplier<GetCategoriesAction.Request>) GetCategoriesAction.Request::new);
this.jobProvider = jobProvider;
this.jobResultsProvider = jobResultsProvider;
this.client = client;
this.jobManager = jobManager;
}
Expand All @@ -41,7 +42,7 @@ protected void doExecute(Task task, GetCategoriesAction.Request request, ActionL

Integer from = request.getPageParams() != null ? request.getPageParams().getFrom() : null;
Integer size = request.getPageParams() != null ? request.getPageParams().getSize() : null;
jobProvider.categoryDefinitions(request.getJobId(), request.getCategoryId(), true, from, size,
jobResultsProvider.categoryDefinitions(request.getJobId(), request.getCategoryId(), true, from, size,
r -> listener.onResponse(new GetCategoriesAction.Response(r)), listener::onFailure, client);
}
}
Loading