Search in sources :

Example 1 with InvalidMetadataException

use of com.netflix.metacat.common.server.connectors.exception.InvalidMetadataException in project metacat by Netflix.

the class DruidConnectorTableService method get.

/**
 * {@inheritDoc}
 */
@Override
public TableInfo get(@Nonnull final ConnectorRequestContext context, @Nonnull final QualifiedName name) {
    log.debug("Get table metadata for qualified name {} for request {}", name, context);
    try {
        final ObjectNode node = this.druidClient.getLatestDataByName(name.getTableName());
        final DataSource dataSource = DruidConverterUtil.getDatasourceFromLatestSegmentJsonObject(node);
        return this.druidConnectorInfoConverter.getTableInfoFromDatasource(dataSource);
    } catch (MetacatException e) {
        log.error(String.format("Table %s not found.", name), e);
        throw new TableNotFoundException(name);
    } catch (HttpClientErrorException e) {
        log.error(String.format("Failed getting table %s.", name), e);
        if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
            throw new TableNotFoundException(name);
        } else {
            throw new InvalidMetadataException(String.format("Invalid table %s. %s", name, e.getMessage()));
        }
    }
}
Also used : TableNotFoundException(com.netflix.metacat.common.server.connectors.exception.TableNotFoundException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MetacatException(com.netflix.metacat.common.exception.MetacatException) InvalidMetadataException(com.netflix.metacat.common.server.connectors.exception.InvalidMetadataException) DataSource(com.netflix.metacat.connector.druid.converter.DataSource)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 MetacatException (com.netflix.metacat.common.exception.MetacatException)1 InvalidMetadataException (com.netflix.metacat.common.server.connectors.exception.InvalidMetadataException)1 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)1 DataSource (com.netflix.metacat.connector.druid.converter.DataSource)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1