use of com.datastax.driver.core.exceptions.DriverException in project apex-malhar by apache.
the class CassandraTransactionalStore method storeCommittedWindowId.
@Override
public void storeCommittedWindowId(String appId, int operatorId, long windowId) {
try {
BoundStatement boundStatement = new BoundStatement(lastWindowUpdateCommand);
lastWindowUpdateStatement = boundStatement.bind(windowId, appId, operatorId);
batchCommand.add(lastWindowUpdateStatement);
} catch (DriverException e) {
throw new RuntimeException(e);
}
}
use of com.datastax.driver.core.exceptions.DriverException in project metacat by Netflix.
the class CassandraConnectorTableService method get.
/**
* {@inheritDoc}
*/
@Override
public TableInfo get(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName name) {
final String keyspace = name.getDatabaseName();
final String table = name.getTableName();
log.debug("Attempting to get metadata for Cassandra table {}.{} for request {}", keyspace, table, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(name);
}
final TableMetadata tableMetadata = keyspaceMetadata.getTable(table);
if (tableMetadata == null) {
throw new TableNotFoundException(name);
}
final TableInfo tableInfo = this.getTableInfo(name, tableMetadata);
log.debug("Successfully got metadata for Cassandra table {}.{} for request {}", keyspace, table, context);
return tableInfo;
} 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 metacat by Netflix.
the class CassandraConnectorDatabaseService method listViewNames.
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> listViewNames(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName databaseName) {
final String catalogName = databaseName.getCatalogName();
final String keyspace = databaseName.getDatabaseName();
log.debug("Attempting to get materialized view names for keyspace {} due to request {}", keyspace, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(databaseName);
}
final ImmutableList.Builder<QualifiedName> viewsBuilder = ImmutableList.builder();
for (final MaterializedViewMetadata view : keyspaceMetadata.getMaterializedViews()) {
viewsBuilder.add(QualifiedName.ofView(catalogName, keyspace, view.getBaseTable().getName(), view.getName()));
}
final List<QualifiedName> views = viewsBuilder.build();
log.debug("Successfully found {} views for keyspace {} due to request {}", views.size(), keyspace, context);
return views;
} catch (final DriverException de) {
log.error(de.getMessage(), de);
throw this.getExceptionMapper().toConnectorException(de, databaseName);
}
}
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 ConnectorContext 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 metacat by Netflix.
the class CassandraConnectorDatabaseService method get.
/**
* {@inheritDoc}
*/
@Override
public DatabaseInfo get(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName name) {
final String keyspace = name.getDatabaseName();
log.debug("Attempting to get keyspace metadata for keyspace {} for request", keyspace, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(name);
}
log.debug("Successfully found the keyspace metadata for {} for request", name, context);
return DatabaseInfo.builder().name(name).build();
} catch (final DriverException de) {
log.error(de.getMessage(), de);
throw this.getExceptionMapper().toConnectorException(de, name);
}
}
Aggregations