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] Refactor ProcessCtrl into Autodetect and Normalizer builders #32720

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,12 +162,12 @@
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.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
import org.elasticsearch.xpack.ml.job.process.DataCountsReporter;
import org.elasticsearch.xpack.ml.job.process.NativeController;
import org.elasticsearch.xpack.ml.job.process.NativeControllerHolder;
import org.elasticsearch.xpack.ml.job.process.ProcessCtrl;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectBuilder;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessFactory;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import org.elasticsearch.xpack.ml.job.process.autodetect.BlackHoleAutodetectProcess;
Expand Down Expand Up @@ -284,8 +284,8 @@ public List<Setting<?>> getSettings() {
CONCURRENT_JOB_ALLOCATIONS,
MachineLearningField.MAX_MODEL_MEMORY_LIMIT,
MAX_MACHINE_MEMORY_PERCENT,
ProcessCtrl.DONT_PERSIST_MODEL_STATE_SETTING,
ProcessCtrl.MAX_ANOMALY_RECORDS_SETTING,
AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING,
AutodetectBuilder.MAX_ANOMALY_RECORDS_SETTING,
DataCountsReporter.ACCEPTABLE_PERCENTAGE_DATE_PARSE_ERRORS_SETTING,
DataCountsReporter.ACCEPTABLE_PERCENTAGE_OUT_OF_ORDER_ERRORS_SETTING,
AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
public class NativeController {
private static final Logger LOGGER = Loggers.getLogger(NativeController.class);

/**
* Process controller native program name
*/
private static final String CONTROLLER = "controller";

// The controller process should already be running by the time this class tries to connect to it, so the timeout
// can be short (although there's a gotcha with EBS volumes restored from snapshot, so not TOO short)
private static final Duration CONTROLLER_CONNECT_TIMEOUT = Duration.ofSeconds(10);
Expand All @@ -50,7 +55,7 @@ public class NativeController {
private final OutputStream commandStream;

NativeController(Environment env, NamedPipeHelper namedPipeHelper) throws IOException {
ProcessPipes processPipes = new ProcessPipes(env, namedPipeHelper, ProcessCtrl.CONTROLLER, null,
ProcessPipes processPipes = new ProcessPipes(env, namedPipeHelper, CONTROLLER, null,
true, true, false, false, false, false);
processPipes.connectStreams(CONTROLLER_CONNECT_TIMEOUT);
cppLogHandler = new CppLogMessageHandler(null, processPipes.getLogStream().get());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.ml.job.process;

import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.core.XPackPlugin;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

public final class ProcessBuilderUtils {

private ProcessBuilderUtils() {}

/**
* Name of the model config file
*/
public static final String ML_MODEL_CONF = "mlmodel.conf";

public static <T> void addIfNotNull(T object, String argKey, List<String> command) {
if (object != null) {
String param = argKey + object;
command.add(param);
}
}

public static void addIfNotNull(TimeValue timeValue, String argKey, List<String> command) {
addIfNotNull(timeValue == null ? null : timeValue.getSeconds(), argKey, command);
}

/**
* Return true if there is a file ES_HOME/config/mlmodel.conf
*/
public static boolean modelConfigFilePresent(Environment env) {
Path modelConfPath = XPackPlugin.resolveConfigFile(env, ML_MODEL_CONF);

return Files.isRegularFile(modelConfPath);
}
}

This file was deleted.

Loading