public GremlinClient connectToEndpoints()

in gremlin-client/src/main/java/org/apache/tinkerpop/gremlin/driver/GremlinCluster.java [70:102]


    public GremlinClient connectToEndpoints(Collection<Endpoint> endpoints, Client.Settings settings) {

        logger.info("Connecting with: {}", endpoints.stream()
                .map(Endpoint::getAddress)
                .collect(Collectors.toList()));

        if (endpoints.isEmpty()) {
            throw new IllegalStateException("You must supply at least one endpoint");
        }

        Cluster parentCluster = clusterFactory.createCluster(null);

        ClientClusterCollection clientClusterCollection = new ClientClusterCollection(clusterFactory, parentCluster);

        Map<Endpoint, Cluster> clustersForEndpoints = clientClusterCollection.createClustersForEndpoints(new EndpointCollection(endpoints));
        List<EndpointClient> newEndpointClients = EndpointClient.create(clustersForEndpoints);
        EndpointClientCollection endpointClientCollection = new EndpointClientCollection(
                EndpointClientCollection.builder()
                        .withEndpointClients(newEndpointClients)
                        .setCollectMetrics(metricsConfig.enableMetrics()));

        clientClusterCollections.add(clientClusterCollection);

        return new GremlinClient(
                clientClusterCollection.getParentCluster(),
                settings,
                endpointClientCollection,
                clientClusterCollection,
                endpointStrategies,
                acquireConnectionConfig,
                metricsConfig
        );
    }