Пример #1
0
 @Override
 public String dropColumnFamily(
     final String keyspaceName, final String columnFamily, final boolean blockUntilComplete)
     throws HectorException {
   Operation<String> op =
       new Operation<String>(
           OperationType.META_WRITE,
           FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE,
           keyspaceName,
           getCredentials()) {
         @Override
         public String execute(Cassandra.Client cassandra) throws HectorException {
           try {
             String schemaId = cassandra.system_drop_column_family(columnFamily);
             if (blockUntilComplete) {
               waitForSchemaAgreement(cassandra);
             }
             return schemaId;
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }
Пример #2
0
 /* (non-Javadoc)
  * @see me.prettyprint.cassandra.service.Cluster#describeThriftVersion()
  */
 @Override
 public String describeThriftVersion() throws HectorException {
   Operation<String> op =
       new Operation<String>(OperationType.META_READ, getCredentials()) {
         @Override
         public String execute(Cassandra.Client cassandra) throws HectorException {
           try {
             return cassandra.describe_version();
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }
Пример #3
0
 /* (non-Javadoc)
  * @see me.prettyprint.cassandra.service.Cluster#describeKeyspaces()
  */
 @Override
 public List<KeyspaceDefinition> describeKeyspaces() throws HectorException {
   Operation<List<KeyspaceDefinition>> op =
       new Operation<List<KeyspaceDefinition>>(OperationType.META_READ, getCredentials()) {
         @Override
         public List<KeyspaceDefinition> execute(Cassandra.Client cassandra)
             throws HectorException {
           try {
             return ThriftKsDef.fromThriftList(cassandra.describe_keyspaces());
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }
Пример #4
0
 @Override
 public String describePartitioner() throws HectorException {
   Operation<String> op =
       new Operation<String>(OperationType.META_READ, getCredentials()) {
         @Override
         public String execute(Cassandra.Client cassandra) throws HectorException {
           try {
             if (log.isInfoEnabled()) {
               log.info("in execute with client {}", cassandra);
             }
             return cassandra.describe_partitioner();
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }
Пример #5
0
 /* (non-Javadoc)
  * @see me.prettyprint.cassandra.service.Cluster#describeKeyspace(java.lang.String)
  */
 @Override
 public KeyspaceDefinition describeKeyspace(final String keyspace) throws HectorException {
   Operation<KeyspaceDefinition> op =
       new Operation<KeyspaceDefinition>(OperationType.META_READ, getCredentials()) {
         @Override
         public KeyspaceDefinition execute(Cassandra.Client cassandra) throws HectorException {
           try {
             return new ThriftKsDef(cassandra.describe_keyspace(keyspace));
           } catch (org.apache.cassandra.thrift.NotFoundException nfe) {
             setException(xtrans.translate(nfe));
             return null;
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }
Пример #6
0
 @Override
 public void truncate(final String keyspaceName, final String columnFamily)
     throws HectorException {
   Operation<Void> op =
       new Operation<Void>(
           OperationType.META_WRITE,
           FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE,
           keyspaceName,
           getCredentials()) {
         @Override
         public Void execute(Cassandra.Client cassandra) throws HectorException {
           try {
             cassandra.truncate(columnFamily);
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
           return null;
         }
       };
   connectionManager.operateWithFailover(op);
 }
Пример #7
0
 @Override
 public String dropKeyspace(final String keyspace, final boolean blockUntilComplete)
     throws HectorException {
   Operation<String> op =
       new Operation<String>(OperationType.META_WRITE, getCredentials()) {
         @Override
         public String execute(Cassandra.Client cassandra) throws HectorException {
           try {
             String schemaId = cassandra.system_drop_keyspace(keyspace);
             if (blockUntilComplete) {
               waitForSchemaAgreement(cassandra);
             }
             return schemaId;
           } catch (Exception e) {
             throw xtrans.translate(e);
           }
         }
       };
   connectionManager.operateWithFailover(op);
   return op.getResult();
 }