[ML] Remove usage of base action logger in ml actions (#50074) (#50236)

This commit is contained in:
David Kyle 2019-12-17 13:03:27 +00:00 committed by GitHub
parent 2079f1cbeb
commit 098f540f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 61 additions and 17 deletions

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
@ -50,6 +52,8 @@ import java.util.stream.Collectors;
public class TransportCloseJobAction extends TransportTasksAction<TransportOpenJobAction.JobTask, CloseJobAction.Request,
CloseJobAction.Response, CloseJobAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportCloseJobAction.class);
private final ThreadPool threadPool;
private final Client client;
private final ClusterService clusterService;

View File

@ -65,7 +65,7 @@ import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class TransportDeleteDataFrameAnalyticsAction
extends TransportMasterNodeAction<DeleteDataFrameAnalyticsAction.Request, AcknowledgedResponse> {
private static final Logger LOGGER = LogManager.getLogger(TransportDeleteDataFrameAnalyticsAction.class);
private static final Logger logger = LogManager.getLogger(TransportDeleteDataFrameAnalyticsAction.class);
private final Client client;
private final MlMemoryTracker memoryTracker;
@ -124,13 +124,13 @@ public class TransportDeleteDataFrameAnalyticsAction
ActionListener<BulkByScrollResponse> deleteStateHandler = ActionListener.wrap(
bulkByScrollResponse -> {
if (bulkByScrollResponse.isTimedOut()) {
LOGGER.warn("[{}] DeleteByQuery for state timed out", id);
logger.warn("[{}] DeleteByQuery for state timed out", id);
}
if (bulkByScrollResponse.getBulkFailures().isEmpty() == false) {
LOGGER.warn("[{}] {} failures and {} conflicts encountered while runnint DeleteByQuery for state", id,
logger.warn("[{}] {} failures and {} conflicts encountered while runnint DeleteByQuery for state", id,
bulkByScrollResponse.getBulkFailures().size(), bulkByScrollResponse.getVersionConflicts());
for (BulkItemResponse.Failure failure : bulkByScrollResponse.getBulkFailures()) {
LOGGER.warn("[{}] DBQ failure: {}", id, failure);
logger.warn("[{}] DBQ failure: {}", id, failure);
}
}
deleteConfig(parentTaskClient, id, listener);
@ -159,7 +159,7 @@ public class TransportDeleteDataFrameAnalyticsAction
return;
}
assert deleteResponse.getResult() == DocWriteResponse.Result.DELETED;
LOGGER.info("[{}] Deleted", id);
logger.info("[{}] Deleted", id);
auditor.info(id, Messages.DATA_FRAME_ANALYTICS_AUDIT_DELETED);
listener.onResponse(new AcknowledgedResponse(true));
},

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
@ -37,6 +39,8 @@ import java.util.function.Supplier;
public class TransportDeleteExpiredDataAction extends HandledTransportAction<DeleteExpiredDataAction.Request,
DeleteExpiredDataAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportDeleteExpiredDataAction.class);
// TODO: make configurable in the request
static final Duration MAX_DURATION = Duration.ofHours(8);

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.ResourceNotFoundException;
@ -66,6 +68,8 @@ import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class TransportDeleteForecastAction extends HandledTransportAction<DeleteForecastAction.Request, AcknowledgedResponse> {
private static final Logger logger = LogManager.getLogger(TransportDeleteForecastAction.class);
private final Client client;
private static final int MAX_FORECAST_TO_SEARCH = 10_000;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
@ -29,6 +31,8 @@ import java.util.List;
public class TransportDeleteModelSnapshotAction extends HandledTransportAction<DeleteModelSnapshotAction.Request,
AcknowledgedResponse> {
private static final Logger logger = LogManager.getLogger(TransportDeleteModelSnapshotAction.class);
private final Client client;
private final JobManager jobManager;
private final JobResultsProvider jobResultsProvider;

View File

@ -46,7 +46,7 @@ import java.util.Set;
public class TransportDeleteTrainedModelAction
extends TransportMasterNodeAction<DeleteTrainedModelAction.Request, AcknowledgedResponse> {
private static final Logger LOGGER = LogManager.getLogger(TransportDeleteTrainedModelAction.class);
private static final Logger logger = LogManager.getLogger(TransportDeleteTrainedModelAction.class);
private final TrainedModelProvider trainedModelProvider;
private final InferenceAuditor auditor;
@ -118,7 +118,7 @@ public class TransportDeleteTrainedModelAction
.map(InferenceProcessor::getModelId)
.forEach(allReferencedModelKeys::add);
} catch (Exception ex) {
LOGGER.warn(new ParameterizedMessage("failed to load pipeline [{}]", pipelineId), ex);
logger.warn(new ParameterizedMessage("failed to load pipeline [{}]", pipelineId), ex);
}
}
return allReferencedModelKeys;

View File

@ -65,7 +65,7 @@ public class TransportGetDataFrameAnalyticsStatsAction
extends TransportTasksAction<DataFrameAnalyticsTask, GetDataFrameAnalyticsStatsAction.Request,
GetDataFrameAnalyticsStatsAction.Response, QueryPage<Stats>> {
private static final Logger LOGGER = LogManager.getLogger(TransportGetDataFrameAnalyticsStatsAction.class);
private static final Logger logger = LogManager.getLogger(TransportGetDataFrameAnalyticsStatsAction.class);
private final Client client;
@ -95,7 +95,7 @@ public class TransportGetDataFrameAnalyticsStatsAction
@Override
protected void taskOperation(GetDataFrameAnalyticsStatsAction.Request request, DataFrameAnalyticsTask task,
ActionListener<QueryPage<Stats>> listener) {
LOGGER.debug("Get stats for running task [{}]", task.getParams().getId());
logger.debug("Get stats for running task [{}]", task.getParams().getId());
ActionListener<List<PhaseProgress>> progressListener = ActionListener.wrap(
progress -> {
@ -118,7 +118,7 @@ public class TransportGetDataFrameAnalyticsStatsAction
@Override
protected void doExecute(Task task, GetDataFrameAnalyticsStatsAction.Request request,
ActionListener<GetDataFrameAnalyticsStatsAction.Response> listener) {
LOGGER.debug("Get stats for data frame analytics [{}]", request.getId());
logger.debug("Get stats for data frame analytics [{}]", request.getId());
ActionListener<GetDataFrameAnalyticsAction.Response> getResponseListener = ActionListener.wrap(
getResponse -> {
@ -221,7 +221,7 @@ public class TransportGetDataFrameAnalyticsStatsAction
StoredProgress storedProgress = StoredProgress.PARSER.apply(parser, null);
return storedProgress;
} catch (IOException e) {
LOGGER.error(new ParameterizedMessage("failed to parse progress from doc with it [{}]", hit.getId()), e);
logger.error(new ParameterizedMessage("failed to parse progress from doc with it [{}]", hit.getId()), e);
return new StoredProgress(Collections.emptyList());
}
}

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.TaskOperationFailure;
@ -50,6 +52,8 @@ import java.util.stream.Collectors;
public class TransportGetJobsStatsAction extends TransportTasksAction<TransportOpenJobAction.JobTask, GetJobsStatsAction.Request,
GetJobsStatsAction.Response, QueryPage<JobStats>> {
private static final Logger logger = LogManager.getLogger(TransportGetJobsStatsAction.class);
private final ClusterService clusterService;
private final AutodetectProcessManager processManager;
private final JobResultsProvider jobResultsProvider;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
@ -22,6 +24,8 @@ import java.util.stream.Collectors;
public class TransportGetModelSnapshotsAction extends HandledTransportAction<GetModelSnapshotsAction.Request,
GetModelSnapshotsAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportGetModelSnapshotsAction.class);
private final JobResultsProvider jobResultsProvider;
private final JobManager jobManager;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
@ -54,6 +56,8 @@ import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class TransportGetOverallBucketsAction extends HandledTransportAction<GetOverallBucketsAction.Request,
GetOverallBucketsAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportGetOverallBucketsAction.class);
private static final String EARLIEST_TIME = "earliest_time";
private static final String LATEST_TIME = "latest_time";

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -24,6 +26,8 @@ import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
public class TransportKillProcessAction extends TransportJobTaskAction<KillProcessAction.Request, KillProcessAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportKillProcessAction.class);
private final AnomalyDetectionAuditor auditor;
@Inject

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
@ -34,6 +36,8 @@ import java.util.concurrent.TimeoutException;
public class TransportMlInfoAction extends HandledTransportAction<MlInfoAction.Request, MlInfoAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportMlInfoAction.class);
private final ClusterService clusterService;
private final NamedXContentRegistry xContentRegistry;
private final Map<String, Object> nativeCodeInfo;

View File

@ -92,7 +92,7 @@ import static org.elasticsearch.xpack.ml.MachineLearning.MAX_OPEN_JOBS_PER_NODE;
public class TransportStartDataFrameAnalyticsAction
extends TransportMasterNodeAction<StartDataFrameAnalyticsAction.Request, AcknowledgedResponse> {
private static final Logger LOGGER = LogManager.getLogger(TransportStartDataFrameAnalyticsAction.class);
private static final Logger logger = LogManager.getLogger(TransportStartDataFrameAnalyticsAction.class);
private final XPackLicenseState licenseState;
private final Client client;
@ -253,7 +253,7 @@ public class TransportStartDataFrameAnalyticsAction
toValidateMappingsListener.onResponse(startContext);
break;
case FINISHED:
LOGGER.info("[{}] Job has already finished", startContext.config.getId());
logger.info("[{}] Job has already finished", startContext.config.getId());
finalListener.onFailure(ExceptionsHelper.badRequestException(
"Cannot start because the job has already finished"));
break;
@ -477,7 +477,7 @@ public class TransportStartDataFrameAnalyticsAction
@Override
public void onFailure(Exception e) {
LOGGER.error("[" + persistentTask.getParams().getId() + "] Failed to cancel persistent task that could " +
logger.error("[" + persistentTask.getParams().getId() + "] Failed to cancel persistent task that could " +
"not be assigned due to [" + exception.getMessage() + "]", e);
listener.onFailure(exception);
}
@ -553,7 +553,7 @@ public class TransportStartDataFrameAnalyticsAction
if (unavailableIndices.size() != 0) {
String reason = "Not opening data frame analytics job [" + id +
"], because not all primary shards are active for the following indices [" + String.join(",", unavailableIndices) + "]";
LOGGER.debug(reason);
logger.debug(reason);
return new PersistentTasksCustomMetaData.Assignment(null, reason);
}
@ -563,7 +563,7 @@ public class TransportStartDataFrameAnalyticsAction
if (scheduledRefresh) {
String reason = "Not opening data frame analytics job [" + id +
"] because job memory requirements are stale - refresh requested";
LOGGER.debug(reason);
logger.debug(reason);
return new PersistentTasksCustomMetaData.Assignment(null, reason);
}
}
@ -579,7 +579,7 @@ public class TransportStartDataFrameAnalyticsAction
@Override
protected void nodeOperation(AllocatedPersistentTask task, StartDataFrameAnalyticsAction.TaskParams params,
PersistentTaskState state) {
LOGGER.info("[{}] Starting data frame analytics", params.getId());
logger.info("[{}] Starting data frame analytics", params.getId());
DataFrameAnalyticsTaskState analyticsTaskState = (DataFrameAnalyticsTaskState) state;
// If we are "stopping" there is nothing to do

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
@ -45,6 +47,8 @@ import java.util.stream.Stream;
public class TransportStopDatafeedAction extends TransportTasksAction<TransportStartDatafeedAction.DatafeedTask, StopDatafeedAction.Request,
StopDatafeedAction.Response, StopDatafeedAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportStopDatafeedAction.class);
private final ThreadPool threadPool;
private final PersistentTasksService persistentTasksService;
private final DatafeedConfigProvider datafeedConfigProvider;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.action;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.bulk.BulkAction;
@ -36,6 +38,8 @@ import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class TransportUpdateModelSnapshotAction extends HandledTransportAction<UpdateModelSnapshotAction.Request,
UpdateModelSnapshotAction.Response> {
private static final Logger logger = LogManager.getLogger(TransportUpdateModelSnapshotAction.class);
private final JobResultsProvider jobResultsProvider;
private final Client client;