-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Introduce a setting for the process connect timeout (#43234)
This change introduces a new setting, xpack.ml.process_connect_timeout, to enable the timeout for one of the external ML processes to connect to the ES JVM to be increased. The timeout may need to be increased if many processes are being started simultaneously on the same machine. This is unlikely in clusters with many ML nodes, as we balance the processes across the ML nodes, but can happen in clusters with a single ML node and a high value for xpack.ml.node_concurrent_job_allocations.
- Loading branch information
1 parent
fa23b68
commit 362a346
Showing
5 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...rg/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactoryTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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.autodetect; | ||
|
||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.settings.ClusterSettings; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.common.util.set.Sets; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.env.TestEnvironment; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.core.ml.job.config.Job; | ||
import org.elasticsearch.xpack.ml.MachineLearning; | ||
import org.elasticsearch.xpack.ml.job.process.autodetect.params.AutodetectParams; | ||
import org.elasticsearch.xpack.ml.process.NativeController; | ||
import org.elasticsearch.xpack.ml.process.ProcessPipes; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.Collections; | ||
|
||
import static org.mockito.Matchers.eq; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class NativeAutodetectProcessFactoryTests extends ESTestCase { | ||
|
||
public void testSetProcessConnectTimeout() throws IOException { | ||
|
||
int timeoutSeconds = randomIntBetween(5, 100); | ||
|
||
Settings settings = Settings.builder() | ||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) | ||
.build(); | ||
Environment env = TestEnvironment.newEnvironment(settings); | ||
NativeController nativeController = mock(NativeController.class); | ||
Client client = mock(Client.class); | ||
ClusterSettings clusterSettings = new ClusterSettings(settings, | ||
Sets.newHashSet(MachineLearning.PROCESS_CONNECT_TIMEOUT, AutodetectBuilder.MAX_ANOMALY_RECORDS_SETTING_DYNAMIC)); | ||
ClusterService clusterService = mock(ClusterService.class); | ||
when(clusterService.getClusterSettings()).thenReturn(clusterSettings); | ||
Job job = mock(Job.class); | ||
when(job.getId()).thenReturn("set_process_connect_test_job"); | ||
AutodetectParams autodetectParams = mock(AutodetectParams.class); | ||
ProcessPipes processPipes = mock(ProcessPipes.class); | ||
|
||
NativeAutodetectProcessFactory nativeAutodetectProcessFactory = | ||
new NativeAutodetectProcessFactory(env, settings, nativeController, client, clusterService); | ||
nativeAutodetectProcessFactory.setProcessConnectTimeout(TimeValue.timeValueSeconds(timeoutSeconds)); | ||
nativeAutodetectProcessFactory.createNativeProcess(job, autodetectParams, processPipes, Collections.emptyList()); | ||
|
||
verify(processPipes, times(1)).connectStreams(eq(Duration.ofSeconds(timeoutSeconds))); | ||
} | ||
} |