Introduce formal node ML role (#45174)
This commit builds on the ability for plugins to introduce new roles to add a formal node ML role.
This commit is contained in:
parent
bb22b2e45f
commit
9a142ff25c
|
@ -6,8 +6,8 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/ #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
|
||||
^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
/ #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
|
||||
^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilm]{1,4}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
|
||||
- do:
|
||||
cat.nodes:
|
||||
|
@ -15,8 +15,8 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n
|
||||
((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
/^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n
|
||||
((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilm]{1,4}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
|
||||
- do:
|
||||
cat.nodes:
|
||||
|
|
|
@ -18,7 +18,7 @@ ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master
|
|||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/3.07/(\\d+\\.\\d+( \\d+\\.\\d+ (\\d+\\.\\d+)?)?)?/]
|
||||
// TESTRESPONSE[s/65 99 42/\\d+ \\d+ \\d+/]
|
||||
// TESTRESPONSE[s/[*]/[*]/ s/mJw06l1/.+/ non_json]
|
||||
// TESTRESPONSE[s/dim/.+/ s/[*]/[*]/ s/mJw06l1/.+/ non_json]
|
||||
|
||||
The first few columns (`ip`, `heap.percent`, `ram.percent`, `cpu`, `load_*`) tell
|
||||
you where your nodes live and give a quick picture of performance stats.
|
||||
|
|
|
@ -258,10 +258,10 @@ And the response:
|
|||
[source,txt]
|
||||
--------------------------------------------------
|
||||
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
|
||||
127.0.0.1 10 5 5 4.46 dim * PB2SGZY
|
||||
127.0.0.1 10 5 5 4.46 dim * PB2SGZY
|
||||
--------------------------------------------------
|
||||
// TESTRESPONSE[s/10 5 5 4.46/\\d+ \\d+ \\d+ (\\d+\\.\\d+)? (\\d+\\.\\d+)? (\\d+\.\\d+)?/]
|
||||
// TESTRESPONSE[s/[*]/[*]/ s/PB2SGZY/.+/ non_json]
|
||||
// TESTRESPONSE[s/dim/.+/ s/[*]/[*]/ s/PB2SGZY/.+/ non_json]
|
||||
|
||||
Here, we can see our one node named "PB2SGZY", which is the single node that is currently in our cluster.
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/ #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
|
||||
^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
/ #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
|
||||
^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilm]{1,4}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
|
||||
- do:
|
||||
cat.nodes:
|
||||
|
@ -15,8 +15,8 @@
|
|||
|
||||
- match:
|
||||
$body: |
|
||||
/^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n
|
||||
((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dmi]{1,3}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
/^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n
|
||||
((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilm]{1,4}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/
|
||||
|
||||
- do:
|
||||
cat.nodes:
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
|
@ -277,6 +278,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
|
@ -297,6 +299,21 @@ public class MachineLearning extends Plugin implements ActionPlugin, AnalysisPlu
|
|||
|
||||
public static final Setting<Boolean> ML_ENABLED =
|
||||
Setting.boolSetting("node.ml", XPackSettings.MACHINE_LEARNING_ENABLED, Property.NodeScope);
|
||||
|
||||
public static final DiscoveryNodeRole ML_ROLE = new DiscoveryNodeRole("ml", "l") {
|
||||
|
||||
@Override
|
||||
protected Setting<Boolean> roleSetting() {
|
||||
return ML_ENABLED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public Set<DiscoveryNodeRole> getRoles() {
|
||||
return Collections.singleton(ML_ROLE);
|
||||
}
|
||||
|
||||
// This is not used in v7 and higher, but users are still prevented from setting it directly to avoid confusion
|
||||
private static final String PRE_V7_ML_ENABLED_NODE_ATTR = "ml.enabled";
|
||||
public static final String MAX_OPEN_JOBS_NODE_ATTR = "ml.max_open_jobs";
|
||||
|
|
|
@ -84,10 +84,6 @@ public class JobNodeSelectorTests extends ESTestCase {
|
|||
|
||||
node = new DiscoveryNode(null, "_node_id1", ta, attributes, Collections.emptySet(), Version.CURRENT);
|
||||
assertEquals("{_node_id1}{ml.machine_memory=5}", JobNodeSelector.nodeNameAndMlAttributes(node));
|
||||
|
||||
attributes.put("node.ml", "true");
|
||||
node = new DiscoveryNode("_node_name1", "_node_id1", ta, attributes, Collections.emptySet(), Version.CURRENT);
|
||||
assertEquals("{_node_name1}{ml.machine_memory=5}{node.ml=true}", JobNodeSelector.nodeNameAndMlAttributes(node));
|
||||
}
|
||||
|
||||
public void testSelectLeastLoadedMlNode_byCount() {
|
||||
|
|
Loading…
Reference in New Issue