Search in sources :

Example 1 with HiveMetastoreClientFactory

use of com.netflix.metacat.connector.hive.client.thrift.HiveMetastoreClientFactory in project metacat by Netflix.

the class HiveConnectorFactory method createThriftClient.

private IMetacatHiveClient createThriftClient() throws MetaException {
    final HiveMetastoreClientFactory factory = new HiveMetastoreClientFactory(null, (int) HiveConnectorUtil.toTime(configuration.getOrDefault(HiveConfigConstants.HIVE_METASTORE_TIMEOUT, "20s"), TimeUnit.SECONDS, TimeUnit.MILLISECONDS));
    final String metastoreUri = configuration.get(HiveConfigConstants.THRIFT_URI);
    URI uri = null;
    try {
        uri = new URI(metastoreUri);
    } catch (Exception e) {
        final String message = String.format("Invalid thrift uri %s", metastoreUri);
        log.info(message);
        throw new IllegalArgumentException(message, e);
    }
    return new MetacatHiveClient(uri, factory);
}
Also used : HiveMetastoreClientFactory(com.netflix.metacat.connector.hive.client.thrift.HiveMetastoreClientFactory) MetacatHiveClient(com.netflix.metacat.connector.hive.client.thrift.MetacatHiveClient) URI(java.net.URI) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) TException(org.apache.thrift.TException)

Example 2 with HiveMetastoreClientFactory

use of com.netflix.metacat.connector.hive.client.thrift.HiveMetastoreClientFactory 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

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