예제 #1
0
 @Override
 public String describePartitioner() throws ConnectionException {
   return connectionPool
       .executeWithFailover(
           new AbstractOperationImpl<String>(
               tracerFactory.newTracer(CassandraOperationType.DESCRIBE_PARTITIONER)) {
             @Override
             public String internalExecute(Client client, ConnectionContext context)
                 throws Exception {
               return client.describe_partitioner();
             }
           },
           config.getRetryPolicy().duplicate())
       .getResult();
 }
예제 #2
0
 /**
  * Get the version from the cluster
  *
  * @return
  * @throws OperationException
  */
 @Override
 public String getVersion() throws ConnectionException {
   return connectionPool
       .executeWithFailover(
           new AbstractOperationImpl<String>(
               tracerFactory.newTracer(CassandraOperationType.GET_VERSION)) {
             @Override
             public String internalExecute(Client client, ConnectionContext state)
                 throws Exception {
               return client.describe_version();
             }
           },
           config.getRetryPolicy().duplicate())
       .getResult();
 }
예제 #3
0
 @Override
 public Map<String, List<String>> describeSchemaVersions() throws ConnectionException {
   return connectionPool
       .executeWithFailover(
           new AbstractOperationImpl<Map<String, List<String>>>(
               tracerFactory.newTracer(CassandraOperationType.DESCRIBE_SCHEMA_VERSION)) {
             @Override
             public Map<String, List<String>> internalExecute(
                 Client client, ConnectionContext context) throws Exception {
               return client.describe_schema_versions();
             }
           },
           config.getRetryPolicy().duplicate())
       .getResult();
 }
예제 #4
0
 private <K> OperationResult<K> executeSchemaChangeOperation(AbstractOperationImpl<K> op)
     throws OperationException, ConnectionException {
   int attempt = 0;
   do {
     try {
       return connectionPool.executeWithFailover(op, config.getRetryPolicy().duplicate());
     } catch (SchemaDisagreementException e) {
       if (++attempt >= MAX_SCHEMA_CHANGE_ATTEMPTS) {
         throw e;
       }
       try {
         Thread.sleep(SCHEMA_DISAGREEMENT_BACKOFF);
       } catch (InterruptedException e1) {
         Thread.interrupted();
         throw new RuntimeException(e1);
       }
     }
   } while (true);
 }
예제 #5
0
 @Override
 public List<KeyspaceDefinition> describeKeyspaces() throws ConnectionException {
   return connectionPool
       .executeWithFailover(
           new AbstractOperationImpl<List<KeyspaceDefinition>>(
               tracerFactory.newTracer(CassandraOperationType.DESCRIBE_KEYSPACES)) {
             @Override
             public List<KeyspaceDefinition> internalExecute(
                 Client client, ConnectionContext context) throws Exception {
               List<KsDef> ksDefs = client.describe_keyspaces();
               return Lists.transform(
                   ksDefs,
                   new Function<KsDef, KeyspaceDefinition>() {
                     @Override
                     public KeyspaceDefinition apply(KsDef ksDef) {
                       return new ThriftKeyspaceDefinitionImpl(ksDef);
                     }
                   });
             }
           },
           config.getRetryPolicy().duplicate())
       .getResult();
 }