use of com.datastax.driver.core.exceptions.DriverException in project metacat by Netflix.
the class CassandraConnectorTableService method list.
/**
* {@inheritDoc}
*/
@Override
public List<TableInfo> list(@Nonnull @NonNull final ConnectorRequestContext context, @Nonnull @NonNull final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
final String keyspace = name.getDatabaseName();
log.debug("Attempting to list tables in Cassandra keyspace {} for request {}", keyspace, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(name);
}
// TODO: Should we include views?
final List<TableInfo> tables = Lists.newArrayList();
for (final TableMetadata tableMetadata : keyspaceMetadata.getTables()) {
if (prefix != null && !tableMetadata.getName().startsWith(prefix.getTableName())) {
continue;
}
tables.add(this.getTableInfo(name, tableMetadata));
}
// Sort
if (sort != null) {
final Comparator<TableInfo> tableComparator = Comparator.comparing((t) -> t.getName().getTableName());
ConnectorUtils.sort(tables, sort, tableComparator);
}
// Paging
final List<TableInfo> pagedTables = ConnectorUtils.paginate(tables, pageable);
log.debug("Listed {} tables in Cassandra keyspace {} for request {}", pagedTables.size(), keyspace, context);
return pagedTables;
} catch (final DriverException de) {
log.error(de.getMessage(), de);
throw this.getExceptionMapper().toConnectorException(de, name);
}
}
use of com.datastax.driver.core.exceptions.DriverException in project apex-malhar by apache.
the class CassandraTransactionalStore method getCommittedWindowId.
@Override
public long getCommittedWindowId(String appId, int operatorId) {
try {
BoundStatement boundStatement = new BoundStatement(lastWindowFetchCommand);
lastWindowFetchStatement = boundStatement.bind(appId, operatorId);
long lastWindow = -1;
ResultSet resultSet = session.execute(lastWindowFetchStatement);
if (!resultSet.isExhausted()) {
lastWindow = resultSet.one().getLong(0);
}
lastWindowFetchCommand.disableTracing();
return lastWindow;
} catch (DriverException ex) {
throw new RuntimeException(ex);
}
}
use of com.datastax.driver.core.exceptions.DriverException in project apex-malhar by apache.
the class CassandraTransactionalStore method removeCommittedWindowId.
@Override
public void removeCommittedWindowId(String appId, int operatorId) {
try {
BoundStatement boundStatement = new BoundStatement(lastWindowDeleteCommand);
lastWindowDeleteStatement = boundStatement.bind(appId, operatorId);
session.execute(lastWindowDeleteStatement);
lastWindowDeleteCommand.disableTracing();
} catch (DriverException e) {
throw new RuntimeException(e);
}
}
Aggregations