use of com.netflix.astyanax.thrift.ddl.ThriftKeyspaceDefinitionImpl in project coprhd-controller by CoprHD.
the class DbClientContext method alterKeyspaceWithThrift.
/**
* Update the keyspace definition using low-level thrift API
* This is to bypass the precheck logic in Astyanax that throws SchemaDisagreementException when there are
* unreachable nodes in the cluster. Refer to https://github.com/Netflix/astyanax/issues/443 for details.
*
* @param kd existing keyspace definition, could be null
* @param update new keyspace definition
* @return new schema version after the update
*/
private String alterKeyspaceWithThrift(KeyspaceDefinition kd, KeyspaceDefinition update) throws ConnectionException {
final KeyspaceTracerFactory ks = EmptyKeyspaceTracerFactory.getInstance();
ConnectionPool<Cassandra.Client> pool = (ConnectionPool<Cassandra.Client>) clusterContext.getConnectionPool();
final KsDef def = ((ThriftKeyspaceDefinitionImpl) update).getThriftKeyspaceDefinition();
if (kd != null) {
return pool.executeWithFailover(new AbstractOperationImpl<String>(ks.newTracer(CassandraOperationType.UPDATE_KEYSPACE)) {
@Override
public String internalExecute(Cassandra.Client client, ConnectionContext context) throws Exception {
return client.system_update_keyspace(def);
}
}, clusterContext.getAstyanaxConfiguration().getRetryPolicy().duplicate()).getResult();
} else {
return pool.executeWithFailover(new AbstractOperationImpl<String>(ks.newTracer(CassandraOperationType.ADD_KEYSPACE)) {
@Override
public String internalExecute(Cassandra.Client client, ConnectionContext context) throws Exception {
return client.system_add_keyspace(def);
}
}, clusterContext.getAstyanaxConfiguration().getRetryPolicy().duplicate()).getResult();
}
}
Aggregations