Пример #1
0
 /** Returns a node client to a given node. */
 public synchronized Client client(String nodeName) {
   ensureOpen();
   NodeAndClient nodeAndClient = nodes.get(nodeName);
   if (nodeAndClient != null) {
     return nodeAndClient.client(random);
   }
   Assert.fail("No node found with name: [" + nodeName + "]");
   return null; // can't happen
 }
Пример #2
0
 /** Returns a client to a node started with "node.client: true" */
 public synchronized Client clientNodeClient() {
   ensureOpen();
   NodeAndClient randomNodeAndClient = getRandomNodeAndClient(new ClientNodePredicate());
   if (randomNodeAndClient != null) {
     return randomNodeAndClient.client(random);
   }
   startNodeClient(ImmutableSettings.EMPTY);
   return getRandomNodeAndClient(new ClientNodePredicate()).client(random);
 }
Пример #3
0
 /**
  * Returns a random node that applies to the given predicate. The predicate can filter nodes based
  * on the nodes settings. If all nodes are filtered out this method will return <code>null</code>
  */
 public synchronized Client client(final Predicate<Settings> filterPredicate) {
   ensureOpen();
   final NodeAndClient randomNodeAndClient =
       getRandomNodeAndClient(
           new Predicate<NodeAndClient>() {
             @Override
             public boolean apply(NodeAndClient nodeAndClient) {
               return filterPredicate.apply(nodeAndClient.node.settings());
             }
           });
   if (randomNodeAndClient != null) {
     return randomNodeAndClient.client(random);
   }
   return null;
 }