Search in sources :

Example 26 with KeyspaceMetadata

use of com.datastax.driver.core.KeyspaceMetadata 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);
    }
}
Also used : DatabaseNotFoundException(com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException) DriverException(com.datastax.driver.core.exceptions.DriverException) KeyspaceMetadata(com.datastax.driver.core.KeyspaceMetadata)

Aggregations

KeyspaceMetadata (com.datastax.driver.core.KeyspaceMetadata)26 TableMetadata (com.datastax.driver.core.TableMetadata)9 DriverException (com.datastax.driver.core.exceptions.DriverException)7 Cluster (com.datastax.driver.core.Cluster)5 DatabaseNotFoundException (com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException)5 Test (org.junit.Test)5 ImmutableList (com.google.common.collect.ImmutableList)3 QualifiedName (com.netflix.metacat.common.QualifiedName)3 RegularStatement (com.datastax.driver.core.RegularStatement)2 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)2 ArrayList (java.util.ArrayList)2 ColumnMetadata (com.datastax.driver.core.ColumnMetadata)1 MaterializedViewMetadata (com.datastax.driver.core.MaterializedViewMetadata)1 MappingManager (com.datastax.driver.mapping.MappingManager)1 EntityFieldMetaData (com.datastax.driver.mapping.meta.EntityFieldMetaData)1 EntityTypeMetadata (com.datastax.driver.mapping.meta.EntityTypeMetadata)1 PrestoException (com.facebook.presto.spi.PrestoException)1 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)1 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)1 AnnotationUDT (zipkin.storage.cassandra3.Schema.AnnotationUDT)1