All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinkerpop.gremlin.driver.ClusterInfo Maven / Gradle / Ivy

package com.tinkerpop.gremlin.driver;

import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
class ClusterInfo {

    private final Cluster cluster;
    private final ConcurrentMap hosts = new ConcurrentHashMap<>();

    public ClusterInfo(final Cluster cluster) {
        this.cluster = cluster;
    }

    public Host add(final InetSocketAddress address) {
        final Host newHost = new Host(address, cluster);
        final Host previous = hosts.putIfAbsent(address, newHost);
        return previous == null ? newHost : null;
    }

    Collection allHosts() {
        return hosts.values();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy