Search in sources :

Example 1 with IMetacatHiveClient

use of com.netflix.metacat.connector.hive.IMetacatHiveClient in project metacat by Netflix.

the class HiveConnectorConfig method createThriftClient.

/**
 * create thrift hive client.
 *
 * @param connectorContext connector config.
 * @return data source
 * @throws MetaException meta exception
 */
@Bean
@ConditionalOnMissingBean(IMetacatHiveClient.class)
public IMetacatHiveClient createThriftClient(final ConnectorContext connectorContext) throws MetaException {
    final HiveMetastoreClientFactory factory = new HiveMetastoreClientFactory(null, (int) TimeUtil.toTime(connectorContext.getConfiguration().getOrDefault(HiveConfigConstants.HIVE_METASTORE_TIMEOUT, "20s"), TimeUnit.SECONDS, TimeUnit.MILLISECONDS));
    final String metastoreUri = connectorContext.getConfiguration().get(HiveConfigConstants.THRIFT_URI);
    try {
        return new MetacatHiveClient(new URI(metastoreUri), factory);
    } catch (Exception e) {
        final String message = String.format("Invalid thrift uri %s", metastoreUri);
        log.info(message);
        throw new IllegalArgumentException(message, e);
    }
}
Also used : HiveMetastoreClientFactory(com.netflix.metacat.connector.hive.client.thrift.HiveMetastoreClientFactory) IMetacatHiveClient(com.netflix.metacat.connector.hive.IMetacatHiveClient) MetacatHiveClient(com.netflix.metacat.connector.hive.client.thrift.MetacatHiveClient) URI(java.net.URI) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

IMetacatHiveClient (com.netflix.metacat.connector.hive.IMetacatHiveClient)1 HiveMetastoreClientFactory (com.netflix.metacat.connector.hive.client.thrift.HiveMetastoreClientFactory)1 MetacatHiveClient (com.netflix.metacat.connector.hive.client.thrift.MetacatHiveClient)1 URI (java.net.URI)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1