Package com.datastax.driver.core

Examples of com.datastax.driver.core.Host$HealthMonitor


                    List<Host> l = perDcSuspectedHosts.get(localDc);
                    localSuspected = l == null ? Collections.<Host>emptySet().iterator() : l.iterator();
                }

                while (localSuspected.hasNext()) {
                    Host h = localSuspected.next();
                    waitOnReconnection(h);
                    if (h.isUp())
                        return h;
                }

                ConsistencyLevel cl = statement.getConsistencyLevel() == null
                                    ? configuration.getQueryOptions().getConsistencyLevel()
                                    : statement.getConsistencyLevel();

                if (dontHopForLocalCL && cl.isDCLocal())
                    return endOfData();

                if (remoteDcs == null) {
                    Set<String> copy = new HashSet<String>(perDcLiveHosts.keySet());
                    copy.remove(localDc);
                    remoteDcs = copy.iterator();
                }

                while (true) {
                    if (currentDcHosts != null && currentDcRemaining > 0) {
                        currentDcRemaining--;
                        int c = idx++ % currentDcHosts.size();
                        if (c < 0) {
                            c += currentDcHosts.size();
                        }
                        return currentDcHosts.get(c);
                    }

                    if (currentDcSuspected != null) {
                        while (currentDcSuspected.hasNext()) {
                            Host h = currentDcSuspected.next();
                            waitOnReconnection(h);
                            if (h.isUp())
                                return h;
                        }
                    }

                    if (!remoteDcs.hasNext())
View Full Code Here


                    if (suspected == null)
                        suspected = suspectedHosts.iterator();

                    while (suspected.hasNext()) {
                        Host h = suspected.next();
                        waitOnReconnection(h);
                        if (h.isUp())
                            return h;
                    }
                    return endOfData();
                }
View Full Code Here

        if (count < 0)
            count = -count;
        Iterator<Host> iter = hosts.iterator();
        while (count > 0 && iter.hasNext())
            iter.next();
        Host host = iter.next();
        ConcurrentLinkedQueue<Client> q = cache.get(host);
        if (q == null)
        {
            ConcurrentLinkedQueue<Client> newQ = new ConcurrentLinkedQueue<Client>();
            q = cache.putIfAbsent(host, newQ);
            if (q == null)
                q = newQ;
        }
        Client tclient = q.poll();
        if (tclient != null)
            return tclient;
        return new Client(settings.getRawThriftClient(host.getAddress().getHostAddress()), host);
    }
View Full Code Here

    {
        Set<Host> hosts = metadata.getReplicas(metadata.quote(keyspace), pk);
        int pos = roundrobin.incrementAndGet() % hosts.size();
        if (pos < 0)
            pos = -pos;
        Host host = Iterators.get(hosts.iterator(), pos);
        ConcurrentLinkedQueue<Client> q = cache.get(host);
        if (q == null)
        {
            ConcurrentLinkedQueue<Client> newQ = new ConcurrentLinkedQueue<Client>();
            q = cache.putIfAbsent(host, newQ);
            if (q == null)
                q = newQ;
        }
        Client tclient = q.poll();
        if (tclient != null)
            return tclient;
        return new Client(settings.getRawThriftClient(host.getAddress().getHostAddress()), host);
    }
View Full Code Here

            int pos = roundrobin.incrementAndGet() % hosts.size();
            for (int i = 0 ; address == null && i < hosts.size() ; i++)
            {
                if (pos < 0)
                    pos = -pos;
                Host host = Iterators.get(hosts.iterator(), (pos + i) % hosts.size());
                if (whiteset == null || whiteset.contains(host.getAddress()))
                    address = host.getAddress();
            }
        }
        if (address == null)
            address = whitelist.get(ThreadLocalRandom.current().nextInt(whitelist.size()));
        ConcurrentLinkedQueue<Client> q = cache.get(address);
View Full Code Here

    {
        Set<Host> hosts = metadata.getReplicas(metadata.quote(keyspace), pk);
        int pos = roundrobin.incrementAndGet() % hosts.size();
        if (pos < 0)
            pos = -pos;
        Host host = Iterators.get(hosts.iterator(), pos);
        ConcurrentLinkedQueue<Client> q = cache.get(host);
        if (q == null)
        {
            ConcurrentLinkedQueue<Client> newQ = new ConcurrentLinkedQueue<Client>();
            q = cache.putIfAbsent(host, newQ);
            if (q == null)
                q = newQ;
        }
        Client tclient = q.poll();
        if (tclient != null)
            return tclient;
        return new Client(settings.getRawThriftClient(host.getAddress().getHostAddress()), host);
    }
View Full Code Here

    private void rsetBegin(MappedSchemaObject<?> entity, ResultSet resultSet, String readModify) {
        StringBuilder execInfo = new StringBuilder();
        for (ExecutionInfo executionInfo : resultSet.getAllExecutionInfo()) {
            if (executionInfo == null)
                continue;
            Host qh = executionInfo.getQueriedHost();
            ConsistencyLevel cl = executionInfo.getAchievedConsistencyLevel();
            QueryTrace queryTrace = executionInfo.getQueryTrace();
            execInfo.append("\n    exeuction info: queried-host=[address=").append(qh.getAddress()).
                append(", version=").append(qh.getCassandraVersion()).
                append(", dc=").append(qh.getDatacenter()).
                append(", rac=").append(qh.getRack()).
                append("], achieved-consistency-level=").append(cl);
            if (queryTrace != null) {
                InetAddress coordinator = queryTrace.getCoordinator();
                int durationMicros = queryTrace.getDurationMicros();
                Map<String, String> parameters = queryTrace.getParameters();
View Full Code Here

                    List<Host> l = perDcSuspectedHosts.get(localDc);
                    localSuspected = l == null ? Collections.<Host>emptySet().iterator() : l.iterator();
                }

                while (localSuspected.hasNext()) {
                    Host h = localSuspected.next();
                    waitOnReconnection(h);
                    if (h.isUp())
                        return h;
                }

                ConsistencyLevel cl = statement.getConsistencyLevel() == null
                                    ? configuration.getQueryOptions().getConsistencyLevel()
                                    : statement.getConsistencyLevel();

                if (dontHopForLocalCL && cl.isDCLocal())
                    return endOfData();

                if (remoteDcs == null) {
                    Set<String> copy = new HashSet<String>(perDcLiveHosts.keySet());
                    copy.remove(localDc);
                    remoteDcs = copy.iterator();
                }

                while (true) {
                    if (currentDcHosts != null && currentDcRemaining > 0) {
                        currentDcRemaining--;
                        int c = idx++ % currentDcHosts.size();
                        if (c < 0) {
                            c += currentDcHosts.size();
                        }
                        return currentDcHosts.get(c);
                    }

                    if (currentDcSuspected != null) {
                        while (currentDcSuspected.hasNext()) {
                            Host h = currentDcSuspected.next();
                            waitOnReconnection(h);
                            if (h.isUp())
                                return h;
                        }
                    }

                    if (!remoteDcs.hasNext())
View Full Code Here

                    if (suspected == null)
                        suspected = suspectedHosts.iterator();

                    while (suspected.hasNext()) {
                        Host h = suspected.next();
                        waitOnReconnection(h);
                        if (h.isUp())
                            return h;
                    }
                    return endOfData();
                }
View Full Code Here

                    List<Host> l = perDcSuspectedHosts.get(localDc);
                    localSuspected = l == null ? Collections.<Host>emptySet().iterator() : l.iterator();
                }

                while (localSuspected.hasNext()) {
                    Host h = localSuspected.next();
                    waitOnReconnection(h);
                    if (h.isUp())
                        return h;
                }

                ConsistencyLevel cl = statement.getConsistencyLevel() == null
                                    ? configuration.getQueryOptions().getConsistencyLevel()
                                    : statement.getConsistencyLevel();

                if (dontHopForLocalCL && cl.isDCLocal())
                    return endOfData();

                if (remoteDcs == null) {
                    Set<String> copy = new HashSet<String>(perDcLiveHosts.keySet());
                    copy.remove(localDc);
                    remoteDcs = copy.iterator();
                }

                while (true) {
                    if (currentDcHosts != null && currentDcRemaining > 0) {
                        currentDcRemaining--;
                        int c = idx++ % currentDcHosts.size();
                        if (c < 0) {
                            c += currentDcHosts.size();
                        }
                        return currentDcHosts.get(c);
                    }

                    if (currentDcSuspected != null) {
                        while (currentDcSuspected.hasNext()) {
                            Host h = currentDcSuspected.next();
                            waitOnReconnection(h);
                            if (h.isUp())
                                return h;
                        }
                    }

                    if (!remoteDcs.hasNext())
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.Host$HealthMonitor

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.