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

io.tarantool.driver.TarantoolAddressProviderFactory Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver;

import io.tarantool.driver.cluster.BinaryClusterDiscoveryEndpoint;
import io.tarantool.driver.cluster.BinaryDiscoveryClusterAddressProvider;
import io.tarantool.driver.cluster.TarantoolClusterDiscoveryConfig;
import io.tarantool.driver.cluster.HTTPDiscoveryClusterAddressProvider;
import io.tarantool.driver.utils.Assert;

import java.util.Collection;

/**
 * Factory for Tarantool address provider instances.
 *
 * @author Sergey Volgin
 * @author Alexey Kuzin
 */
public final class TarantoolAddressProviderFactory {

    private TarantoolAddressProviderFactory() {
    }

    public TarantoolClusterAddressProvider createClusterAddressProvider(Collection nodes) {
        Assert.notNull(nodes, "Collection of Tarantool server address should not be null");
        Assert.notEmpty(nodes, "Collection of Tarantool server address should not be empty");

        return () -> nodes;
    }

    public TarantoolClusterAddressProvider createClusterAddressProviderWithDiscovery(
            Collection nodes, TarantoolClusterDiscoveryConfig config) {
        TarantoolClusterAddressProvider addressProvider;

        if (config != null) {
            if (config.getEndpoint() instanceof BinaryClusterDiscoveryEndpoint) {
                addressProvider = new BinaryDiscoveryClusterAddressProvider(config);
            } else {
                addressProvider = new HTTPDiscoveryClusterAddressProvider(config);
            }
        } else {
            addressProvider = createClusterAddressProvider(nodes);
        }

        return addressProvider;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy