public static void closeQuietly(Client client) { try { TProtocol inputProtocol = client.getInputProtocol(); if (inputProtocol == null) { return; } TTransport transport = inputProtocol.getTransport(); if (transport == null) { return; } transport.close(); } catch (Exception ignored) { } }
private CqlResult executeStatement(Client client, String statement) throws ThriftApiExecutionException { ByteBuffer buf = ByteBufferUtil.bytes(statement); try { if (cqlVersion.charAt(0) >= '3') { return client.execute_cql3_query(buf, Compression.NONE, ConsistencyLevel.ONE); } else { return client.execute_cql_query(buf, Compression.NONE); } } catch (Exception e) { getLog().debug(statement); throw new ThriftApiExecutionException(e); } }
@Override public void executeOperation(Client client) throws ThriftApiExecutionException { try { if ( columnFamilyList != null && columnFamilyList.length > 0 ) { for (int i = 0; i < columnFamilyList.length; i++) { client.system_drop_column_family(columnFamilyList[i]); getLog().info("Dropped column family \"" + columnFamilyList[i] + "\"."); } } else { client.system_drop_keyspace(keyspace); getLog().info("Dropped keyspace \"" + keyspace + "\"."); } } catch (Exception e) { throw new ThriftApiExecutionException(e); } }
public List<TokenRange> getRangeMap(String keyspace) { Client client = connectionFactory.create(); try { return client.describe_ring(keyspace); } catch (TException e) { throw new RuntimeException(e); } finally { closeQuietly(client); } }
@Override void executeOperation(Client client) throws ThriftApiExecutionException { for (String statement : statements) { if (StringUtils.isNotBlank(statement)) { results.add(executeStatement(client, statement)); } } }
public CTConnection(TTransport transport, Client client, CTConnectionFactory.Config cfg) { this.transport = transport; this.client = client; this.cfg = cfg; }
public Cassandra.Client getClient() { return client; }