/// <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()); }
/// <summary> /// Performs the operation on the given cassandra instance. /// </summary> /// <param name="client">client</param> /// <returns>null if no execute handler</returns> public void Execute(Cassandra.Iface client) { if (Handler == null) { throw new ApplicationException("Execution Handler was null"); } Result = Handler(client); }
public Keyspace( ICassandraClient client, string keyspaceName, IDictionary<string, Dictionary<string, string>> description, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy, IKeyedObjectPool<Endpoint, ICassandraClient> pool, ICassandraClientMonitor monitor) { if (client == null) throw new ArgumentNullException("client"); this.Client = client; this.ConsistencyLevel = consistencyLevel; this.Description = description; this.Name = keyspaceName; this.cassandra = client.Client as Cassandra.Client; this.FailoverPolicy = failoverPolicy; this.pool = pool; this.monitor = monitor; InitFailover(); }
public Keyspace( ICassandraClient client, string keyspaceName, IDictionary <string, Dictionary <string, string> > description, ConsistencyLevel consistencyLevel, FailoverPolicy failoverPolicy, IKeyedObjectPool <Endpoint, ICassandraClient> pool, ICassandraClientMonitor monitor) { if (client == null) { throw new ArgumentNullException("client"); } this.Client = client; this.ConsistencyLevel = consistencyLevel; this.Description = description; this.Name = keyspaceName; this.cassandra = client.Client as Cassandra.Client; this.FailoverPolicy = failoverPolicy; this.pool = pool; this.monitor = monitor; InitFailover(); }
/// <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()); }