Client transportClient() { if (closed.get()) { throw new RuntimeException("already closed"); } if (transportClient == null) { Client maybeTransportClient = client(random); if (maybeTransportClient instanceof TransportClient) { transportClient = maybeTransportClient; } else { transportClient = TransportClientFactory.NO_SNIFF_CLIENT_FACTORY.client(node, clusterName, random); } } return transportClient; }
@Override public Client client(Node node, String clusterName, Random random) { double nextDouble = random.nextDouble(); if (nextDouble < transportClientRatio) { if (logger.isDebugEnabled()) { logger.debug( "Using transport client for node [{}] sniff: [{}]", node.settings().get("name"), false); } /* no sniff client for now - doesn't work will all tests since it might throw NoNodeAvailableException if nodes are shut down. * we first need support of transportClientRatio as annotations or so */ return TransportClientFactory.NO_SNIFF_CLIENT_FACTORY.client(node, clusterName, random); } else { return node.client(); } }