Package com.netflix.astyanax.connectionpool.exceptions

Examples of com.netflix.astyanax.connectionpool.exceptions.HostDownException


    }

    @Override
    public int primeConnections(int numConnections) throws ConnectionException, InterruptedException {
        if (isReconnecting()) {
            throw new HostDownException("Can't prime connections on downed host.");
        }
        // Don't try to create more than we're allowed
        int remaining = Math.min(numConnections, config.getMaxConnsPerHost() - getActiveConnectionCount());
       
        // Attempt to open 'count' connections and allow for MAX_PRIME_CONNECTIONS_RETRY_ATTEMPT
        // retries before giving up if we can't open more.
        int opened = 0;
        Exception lastException = null;
        for (int i = 0; opened < remaining && i < MAX_PRIME_CONNECTIONS_RETRY_ATTEMPT;) {
            try {
                reconnect();
                opened++;
            }
            catch (Exception e) {
                lastException = e;
                Thread.sleep(PRIME_CONNECTION_DELAY);
                i++;
            }
        }
       
        // If no connection was opened then mark this host as down
        if (remaining > 0 && opened == 0) {
            this.markAsDown(null);
            throw new HostDownException("Failed to prime connections", lastException);
        }
        return opened;
    }
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.connectionpool.exceptions.HostDownException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.