use of com.netflix.metacat.common.server.connectors.model.DatabaseInfo in project metacat by Netflix.
the class JdbcConnectorDatabaseService method list.
/**
* {@inheritDoc}
*/
@Override
public List<DatabaseInfo> list(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
final String catalogName = name.getCatalogName();
log.debug("Beginning to list database metadata for catalog {} for request {}", catalogName, context);
final ImmutableList.Builder<DatabaseInfo> builder = ImmutableList.builder();
for (final QualifiedName dbName : this.listNames(context, name, prefix, sort, pageable)) {
builder.add(this.get(context, dbName));
}
log.debug("Finished listing database metadata for catalog {} for request {}", catalogName, context);
return builder.build();
}
use of com.netflix.metacat.common.server.connectors.model.DatabaseInfo in project metacat by Netflix.
the class HiveConnectorDatabaseService method list.
/**
* {@inheritDoc}.
*/
@Override
public List<DatabaseInfo> list(@Nonnull @NonNull final ConnectorContext requestContext, @Nonnull @NonNull final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
try {
final List<DatabaseInfo> databaseInfos = Lists.newArrayList();
for (String databaseName : metacatHiveClient.getAllDatabases()) {
final QualifiedName qualifiedName = QualifiedName.ofDatabase(name.getCatalogName(), databaseName);
if (!qualifiedName.toString().startsWith(prefix.toString())) {
continue;
}
databaseInfos.add(DatabaseInfo.builder().name(qualifiedName).build());
}
//supporting sort by name only
if (sort != null) {
ConnectorUtils.sort(databaseInfos, sort, Comparator.comparing(p -> p.getName().getDatabaseName()));
}
return ConnectorUtils.paginate(databaseInfos, pageable);
} catch (MetaException exception) {
throw new InvalidMetaException(name, exception);
} catch (TException exception) {
throw new ConnectorException(String.format("Failed list hive database %s", name), exception);
}
}
use of com.netflix.metacat.common.server.connectors.model.DatabaseInfo in project metacat by Netflix.
the class CassandraConnectorDatabaseService method list.
/**
* {@inheritDoc}
*/
@Override
public List<DatabaseInfo> list(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
log.debug("Attempting to list keyspaces for request {}", context);
final ImmutableList.Builder<DatabaseInfo> keyspacesBuilder = ImmutableList.builder();
for (final QualifiedName keyspace : this.listNames(context, name, prefix, sort, pageable)) {
keyspacesBuilder.add(DatabaseInfo.builder().name(keyspace).build());
}
final List<DatabaseInfo> keyspaces = keyspacesBuilder.build();
log.debug("Successfully listed {} keyspaces for request {}", keyspaces.size(), context);
return keyspaces;
}
Aggregations