|
|
@@ -9,6 +9,9 @@ import org.apache.logging.log4j.Logger;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.settings.Setting;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.common.xcontent.ToXContent;
|
|
|
+import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
+import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
|
import org.elasticsearch.env.Environment;
|
|
|
import org.elasticsearch.xpack.core.XPackPlugin;
|
|
|
import org.elasticsearch.xpack.core.ml.calendars.ScheduledEvent;
|
|
|
@@ -63,7 +66,9 @@ public class AutodetectBuilder {
|
|
|
public static final String QUANTILES_STATE_PATH_ARG = "--quantilesState=";
|
|
|
|
|
|
private static final String CONF_EXTENSION = ".conf";
|
|
|
+ private static final String JSON_EXTENSION = ".json";
|
|
|
static final String JOB_ID_ARG = "--jobid=";
|
|
|
+ private static final String CONFIG_ARG = "--config=";
|
|
|
private static final String LIMIT_CONFIG_ARG = "--limitconfig=";
|
|
|
private static final String MODEL_PLOT_CONFIG_ARG = "--modelplotconfig=";
|
|
|
private static final String FIELD_CONFIG_ARG = "--fieldconfig=";
|
|
|
@@ -173,11 +178,20 @@ public class AutodetectBuilder {
|
|
|
|
|
|
List<String> command = buildAutodetectCommand();
|
|
|
|
|
|
+ // While it may appear that the JSON formatted job config file contains data that
|
|
|
+ // is duplicated in the existing limits, modelPlot and field config files, over time
|
|
|
+ // the C++ backend will retrieve all its required configuration data from the new
|
|
|
+ // JSON config file and the old-style configuration files will be removed.
|
|
|
+ buildJobConfig(command);
|
|
|
+
|
|
|
+ // Per the comment above, these three lines will eventually be removed once migration
|
|
|
+ // to the new JSON formatted configuration file has been completed.
|
|
|
buildLimits(command);
|
|
|
buildModelPlotConfig(command);
|
|
|
+ buildFieldConfig(command);
|
|
|
|
|
|
buildQuantiles(command);
|
|
|
- buildFieldConfig(command);
|
|
|
+
|
|
|
processPipes.addArgs(command);
|
|
|
controller.startProcess(command);
|
|
|
}
|
|
|
@@ -350,4 +364,17 @@ public class AutodetectBuilder {
|
|
|
command.add(fieldConfig);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void buildJobConfig(List<String> command) throws IOException {
|
|
|
+ Path configFile = Files.createTempFile(env.tmpFile(), "config", JSON_EXTENSION);
|
|
|
+ filesToDelete.add(configFile);
|
|
|
+ try (OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(configFile),StandardCharsets.UTF_8);
|
|
|
+ XContentBuilder jsonBuilder = JsonXContent.contentBuilder()) {
|
|
|
+
|
|
|
+ job.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
|
|
|
+ osw.write(Strings.toString(jsonBuilder));
|
|
|
+ }
|
|
|
+
|
|
|
+ command.add(CONFIG_ARG + configFile.toString());
|
|
|
+ }
|
|
|
}
|