Beispiel #1
0
        /// <summary>
        /// Updates the client member and cassandra member to the next host in the ring.
        /// Returns the current client to the pool and retreives a new client from the
        /// next pool.
        /// </summary>
        void SkipToNextHost()
        {
            //log.info("Skipping to next host. Current host is: {}", client.getUrl());
            try
            {
                Client.MarkAsError();
                pool.Return(Client.Endpoint, Client);
                Client.RemoveKeyspace(this);
            }
            catch            // (Exception e)
            {
                //log.error("Unable to invalidate client {}. Will continue anyhow.", client);
            }

            string nextHost = GetNextHost(Client.Endpoint.Host, Client.Endpoint.IP);

            if (nextHost == null)
            {
                //log.error("Unable to find next host to skip to at {}", tostring());
                throw new Exception("Unable to failover to next host");
            }
            // assume they use the same port
            Client    = pool.Borrow(new Endpoint(nextHost, Client.Port));
            cassandra = Client.Client;
            monitor.IncrementCounter(ClientCounter.SKIP_HOST_SUCCESS);
            //log.info("Skipped host. New host is: {}", client.getUrl());
        }