@@ -180,14 +180,13 @@ public final class InternalTestCluster extends TestCluster {
180
180
nodeAndClient .node .settings ()
181
181
);
182
182
183
- private static final Predicate <NodeAndClient > NO_DATA_NO_MASTER_PREDICATE = nodeAndClient -> DiscoveryNode .isMasterNode (
184
- nodeAndClient .node .settings ()
185
- ) == false && DiscoveryNode .canContainData (nodeAndClient .node .settings ()) == false ;
186
-
187
183
private static final Predicate <NodeAndClient > MASTER_NODE_PREDICATE = nodeAndClient -> DiscoveryNode .isMasterNode (
188
184
nodeAndClient .node .settings ()
189
185
);
190
186
187
+ private static final Predicate <NodeAndClient > NO_DATA_NO_MASTER_PREDICATE = DATA_NODE_PREDICATE .negate ()
188
+ .and (MASTER_NODE_PREDICATE .negate ());
189
+
191
190
public static final int DEFAULT_LOW_NUM_MASTER_NODES = 1 ;
192
191
public static final int DEFAULT_HIGH_NUM_MASTER_NODES = 3 ;
193
192
@@ -1585,10 +1584,17 @@ private <T> Iterable<T> getInstances(Class<T> clazz, Predicate<NodeAndClient> pr
1585
1584
}
1586
1585
1587
1586
/**
1588
- * Returns a reference to the given nodes instances of the given class >T<
1587
+ * @return the instance of the given class from the node with provided {@code nodeName}
1588
+ */
1589
+ public <T > T getInstance (Class <T > clazz , final String nodeName ) {
1590
+ return getInstance (clazz , nc -> nodeName == null || nodeName .equals (nc .name ));
1591
+ }
1592
+
1593
+ /**
1594
+ * @return the instance of the given class from a random node with provided {@code role}
1589
1595
*/
1590
- public <T > T getInstance (Class <T > clazz , final String node ) {
1591
- return getInstance (clazz , nc -> node == null || node . equals (nc .name ));
1596
+ public <T > T getInstance (Class <T > clazz , DiscoveryNodeRole role ) {
1597
+ return getInstance (clazz , nc -> DiscoveryNode . getRolesFromSettings (nc .node . settings ()). contains ( role ));
1592
1598
}
1593
1599
1594
1600
public <T > T getDataNodeInstance (Class <T > clazz ) {
0 commit comments