public ICassandraClient Make(Endpoint key) { if (key == null) { throw new ArgumentNullException("key"); } var transport = new TSocket(key.Host, key.Port, timeout); var protocol = new TBinaryProtocol(transport); Apache.Cassandra.Cassandra.Iface cassandra = null; cassandra = new Apache.Cassandra.Cassandra.Client(protocol); try { transport.Open(); } catch (TTransportException e) { // Thrift exceptions aren't very good in reporting, so we have to catch the exception here and // add details to it. throw new Exception("Unable to open transport to " + key.ToString() + " , ", e); } return(new CassandraClient(cassandra, new KeyspaceFactory(monitor), key, pool)); }
public IClient Create(IEndpoint endpoint, IClientPool ownerPool) { 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); } TcpClient tcpClient = socket.TcpClient; if (this.isBufferSizeSet) { transport = new TBufferedTransport(socket, this.bufferSize); } else { transport = new TBufferedTransport(socket); } TProtocol protocol = new TBinaryProtocol(transport); CassandraClient cassandraClient = new CassandraClient(protocol); IClient client = new DefaultClient() { CassandraClient = cassandraClient, Endpoint = endpoint, OwnerPool = ownerPool, TcpClient = tcpClient, Created = DateTime.Now }; return client; }
public IClient Create(IEndpoint endpoint, IClientPool ownerPool) { TSocket socket = null; if (endpoint.Timeout == 0) { socket = new TSocket(endpoint.Address, endpoint.Port); } else { socket = new TSocket(endpoint.Address, endpoint.Port, endpoint.Timeout); } TcpClient tcpClient = socket.TcpClient; TProtocol protocol = new TBinaryProtocol(socket); CassandraClient cassandraClient = new CassandraClient(protocol); IClient client = new DefaultClient() { CassandraClient = cassandraClient, Endpoint = endpoint, OwnerPool = ownerPool, TcpClient = tcpClient, Created = DateTime.Now }; return client; }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = null; var columnParent = BuildColumnParent(); var output = cassandraClient.get_slice(PartitionKey, columnParent, predicate.ToCassandraSlicePredicate(), consistencyLevel); BuildOut(output); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient, ILog logger) { Output = null; var columnParent = BuildColumnParent(); var result = cassandraClient.get_range_slices(columnParent, predicate.ToCassandraSlicePredicate(), keyRange.ToCassandraKeyRange(), consistencyLevel); BuildOut(result); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient, ILog logger) { cassandraClient.remove( PartitionKey, new ColumnPath { Column_family = columnFamily }, timestamp ?? Timestamp.Now.Ticks, consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { cassandraClient.remove( PartitionKey, new ColumnPath { Column_family = columnFamily }, timestamp ?? DateTimeService.UtcNow.Ticks, consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient, ILog logger) { var columnParent = BuildColumnParent(); var slicePredicate = predicate.ToCassandraSlicePredicate(); Output = new MultigetQueryHelper(nameof(MultiGetCountCommand), keyspace, columnFamily, consistencyLevel) .EnumerateAllKeysWithPartialFetcher( keys, queryKeys => cassandraClient.multiget_count(queryKeys, columnParent, slicePredicate, consistencyLevel), logger); }
public Client(string host, int port) { TSocket socket = null; socket = new TSocket(host, port); transport = new TFramedTransport(socket); TProtocol protocol = new TBinaryProtocol(transport); client = new CassandraClient(protocol); transport.Open(); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient, ILog logger) { ColumnOrSuperColumn columnOrSupercolumn = null; var columnPath = BuildColumnPath(columnName); try { columnOrSupercolumn = cassandraClient.get(PartitionKey, columnPath, consistencyLevel); } catch (NotFoundException) { //ничего не делаем } Output = columnOrSupercolumn?.Column.FromCassandraColumn(); }
public bool Connect() { try { _transport = new TFramedTransport(new TSocket(_host, _port)); TProtocol protocol = new TBinaryProtocol(_transport); _client = new Apache.Cassandra.Cassandra.Client(protocol); _transport.Open(); _client.set_keyspace(_keyspace); _isConnected = true; } catch (Exception ex) { log.Error(ex.ToString()); } return(_isConnected); }
public ThriftConnection(int timeout, IPEndPoint ipEndPoint, string keyspaceName, ILog logger) { isDisposed = false; isAlive = true; this.ipEndPoint = ipEndPoint; this.keyspaceName = keyspaceName; this.logger = logger; var address = ipEndPoint.Address.ToString(); var port = ipEndPoint.Port; var tsocket = timeout == 0 ? new TSocket(address, port) : new TSocket(address, port, timeout); var socket = tsocket.TcpClient.Client; socket.NoDelay = true; socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1); var transport = new TFramedTransport(tsocket); cassandraClient = new Apache.Cassandra.Cassandra.Client(new TBinaryProtocol(transport)); creationTimestamp = Timestamp.Now; OpenTransport(); }
public void Dispose() { if (transport != null) { if (transport.IsOpen) { transport.Close(); } } if (client != null) { if (client.InputProtocol.Transport.IsOpen) { client.InputProtocol.Transport.Close(); } if (client.OutputProtocol.Transport.IsOpen) { client.OutputProtocol.Transport.Close(); } } client = null; transport = null; }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Count = cassandraClient.get_count(PartitionKey, BuildColumnParent(), predicate.ToCassandraSlicePredicate(), consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { var keySpaces = cassandraClient.describe_keyspaces(); Keyspaces = BuildKeyspaces(keySpaces); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.system_update_column_family(columnFamilyDefinition.ToCassandraCfDef(keyspace)); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { cassandraClient.truncate(columnFamily); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient, ILog logger) { Output = cassandraClient.system_update_keyspace(keyspaceDefinition.ToCassandraKsDef()); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.multiget_count(keys, BuildColumnParent(), predicate.ToCassandraSlicePredicate(), consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.describe_schema_versions(); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Version = cassandraClient.describe_version(); }
private Apache.Cassandra.Cassandra.Client CreateConnection(String host) { TSocket socket = new TSocket(host, this.port); TTransport trans = new TFramedTransport(socket); try { trans.Open(); } catch (TTransportException exception) { throw new Exception("unable to connect to server", exception); } Apache.Cassandra.Cassandra.Client client = new Apache.Cassandra.Cassandra.Client(new TBinaryProtocol(trans)); if (this.ringKs != null) { try { client.set_keyspace(this.ringKs); } catch (Exception exception) { throw exception; } } return client; }
public abstract void Execute(Apache.Cassandra.Cassandra.Client client);
public abstract void Execute(Apache.Cassandra.Cassandra.Client client, ILog logger);
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.system_drop_column_family(columnFamily); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Partitioner = cassandraClient.describe_partitioner(); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.system_add_keyspace(keyspaceDefinition.ToCassandraKsDef()); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { var keyspaceDescription = cassandraClient.describe_keyspace(keyspace); KeyspaceInformation = keyspaceDescription.FromCassandraKsDef(); }
private void AttemptReconnect() { if ((this.ring == null) || (this.ring.Count == 0)) { try { this.client = CreateConnection(this.lastUsedHost); this.breaker.Success(); return; } catch (Exception e) { } } if ((this.ring == null) || (this.ring.Count == 0)) { this.client = null; return; } if (this.ring.Count == 1) { this.client = null; return; } String endpoint = GetNextServer(this.lastUsedHost); try { this.client = CreateConnection(endpoint); this.lastUsedHost = endpoint; this.breaker.Success(); CheckRing(); } catch (Exception) { this.client = null; } }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { var mutationMap = TranslateMutations(); cassandraClient.batch_mutate(mutationMap, consistencyLevel); }
internal CassandraClient(Apache.Cassandra.Cassandra.Client thriftClient, KeyspaceFactory keyspaceFactory, Endpoint endpoint, IKeyedObjectPool<Endpoint, ICassandraClient> pool) : this(keyspaceFactory, endpoint, pool) { cassandra = thriftClient; }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { cassandraClient.insert(PartitionKey, BuildColumnParent(), column.ToCassandraColumn(), consistencyLevel); }
public override void Execute(Apache.Cassandra.Cassandra.Client cassandraClient) { Output = cassandraClient.system_drop_keyspace(keyspace); }