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

io.tarantool.driver.core.connection.TarantoolClusterConnectionManager 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.core.connection;

import io.tarantool.driver.api.TarantoolClientConfig;
import io.tarantool.driver.api.TarantoolClusterAddressProvider;
import io.tarantool.driver.api.TarantoolServerAddress;
import io.tarantool.driver.api.connection.TarantoolConnectionListeners;

import java.util.Collection;

/**
 * Implementation of {@link AbstractTarantoolConnectionManager}, aware of connecting to the Tarantool cluster
 *
 * @author Alexey Kuzin
 */
public class TarantoolClusterConnectionManager extends AbstractTarantoolConnectionManager {
    private final TarantoolClusterAddressProvider addressProvider;

    /**
     * Basic constructor.
     *
     * @param config            client configuration
     * @param connectionFactory manages instantiation of Tarantool server connections
     * @param listeners         are invoked after connection is established
     * @param addressProvider   provides Tarantool server nodes addresses
     */
    public TarantoolClusterConnectionManager(
        TarantoolClientConfig config,
        TarantoolConnectionFactory connectionFactory,
        TarantoolConnectionListeners listeners,
        TarantoolClusterAddressProvider addressProvider) {
        super(config, connectionFactory, listeners);
        this.addressProvider = addressProvider;
        this.addressProvider.setRefreshCallback(super::refresh);
    }

    @Override
    protected Collection getAddresses() {
        return addressProvider.getAddresses();
    }

    @Override
    public void close() {
        addressProvider.setRefreshCallback(() -> {
        });
        super.close();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy