public CassandraClient Create(CassandraEndpoint endpoint) { TSocket socket = null; TTransport transport = null; if (endpoint.Timeout == 0) { socket = new TSocket(endpoint.Address, endpoint.Port); } else { socket = new TSocket(endpoint.Address, endpoint.Port, endpoint.Timeout); } if (this.isBufferSizeSet) { transport = new TBufferedTransport(socket, this.bufferSize); } else { transport = new TBufferedTransport(socket); } TProtocol protocol = new TBinaryProtocol(transport); Cassandra.Client cassandraClient = new Cassandra.Client(protocol); CassandraClient client = new CassandraClient(cassandraClient, endpoint); this.logger.Debug(logger.StringFormatInvariantCulture("Created a new connection using: '{0}'", endpoint.ToString())); return client; }
public void Ban(CassandraEndpoint endpoint) { lock (this.blackListedEndpoints) { if (!this.blackListedEndpoints.Contains(endpoint)) { this.blackListedEndpoints.Add(endpoint); } } logger.Warn(logger.StringFormatInvariantCulture("Endpoint '{0}' was banned.", endpoint.ToString())); }
private bool IsBlackListed(CassandraEndpoint borrowedEndpoint) { bool isBlackListed = false; if (this.blackListedEndpoints.Count > 0) { lock (this.blackListedEndpoints) { isBlackListed = this.blackListedEndpoints.Contains(borrowedEndpoint); this.startTimer(DEFAULTDUETIME); } } this.logger.Debug(logger.StringFormatInvariantCulture("Endpoint: '{0}' blacklisted: {1}", borrowedEndpoint, isBlackListed)); return isBlackListed; }
public void AddEndpoint(CassandraEndpoint cassandraEndpoint) { this.availableEndpoints.Enqueue(cassandraEndpoint); this.configuredEndpoints.Add(cassandraEndpoint); }
public CassandraClient(Cassandra.Client cassandraClient, CassandraEndpoint endpoint) { this.InnerClient = cassandraClient; this.Endpoint = endpoint; }