Search in sources :

Example 1 with FixedAddressExploreClient

use of co.cask.cdap.explore.client.FixedAddressExploreClient in project cdap by caskdata.

the class QueryClientTest method setUp.

@Before
public void setUp() throws Throwable {
    super.setUp();
    appClient = new ApplicationClient(clientConfig);
    queryClient = new QueryClient(clientConfig);
    programClient = new ProgramClient(clientConfig);
    streamClient = new StreamClient(clientConfig);
    String accessToken = (clientConfig.getAccessToken() == null) ? null : clientConfig.getAccessToken().getValue();
    ConnectionConfig connectionConfig = clientConfig.getConnectionConfig();
    exploreClient = new FixedAddressExploreClient(connectionConfig.getHostname(), connectionConfig.getPort(), accessToken, connectionConfig.isSSLEnabled(), clientConfig.isVerifySSLCert());
    namespaceClient = new NamespaceClient(clientConfig);
}
Also used : ConnectionConfig(co.cask.cdap.client.config.ConnectionConfig) FixedAddressExploreClient(co.cask.cdap.explore.client.FixedAddressExploreClient) Before(org.junit.Before)

Example 2 with FixedAddressExploreClient

use of co.cask.cdap.explore.client.FixedAddressExploreClient in project cdap by caskdata.

the class ExploreDriver method connect.

@Override
public Connection connect(String url, Properties info) throws SQLException {
    if (!acceptsURL(url)) {
        return null;
    }
    ExploreConnectionParams params = ExploreConnectionParams.parseConnectionUrl(url);
    String authToken = getString(params, ExploreConnectionParams.Info.EXPLORE_AUTH_TOKEN, null);
    String namespace = getString(params, ExploreConnectionParams.Info.NAMESPACE, NamespaceId.DEFAULT.getNamespace());
    boolean sslEnabled = getBoolean(params, ExploreConnectionParams.Info.SSL_ENABLED, false);
    boolean verifySSLCert = getBoolean(params, ExploreConnectionParams.Info.VERIFY_SSL_CERT, true);
    ExploreClient exploreClient = new FixedAddressExploreClient(params.getHost(), params.getPort(), authToken, sslEnabled, verifySSLCert);
    try {
        exploreClient.ping();
    } catch (UnauthenticatedException e) {
        throw new SQLException("Cannot connect to " + url + ", not authenticated.");
    } catch (ServiceUnavailableException | ExploreException e) {
        throw new SQLException("Cannot connect to " + url + ", service not available.");
    }
    return new ExploreConnection(exploreClient, namespace, params);
}
Also used : ExploreClient(co.cask.cdap.explore.client.ExploreClient) FixedAddressExploreClient(co.cask.cdap.explore.client.FixedAddressExploreClient) UnauthenticatedException(co.cask.cdap.common.UnauthenticatedException) SQLException(java.sql.SQLException) ServiceUnavailableException(co.cask.cdap.common.ServiceUnavailableException) FixedAddressExploreClient(co.cask.cdap.explore.client.FixedAddressExploreClient) ExploreException(co.cask.cdap.explore.service.ExploreException)

Aggregations

FixedAddressExploreClient (co.cask.cdap.explore.client.FixedAddressExploreClient)2 ConnectionConfig (co.cask.cdap.client.config.ConnectionConfig)1 ServiceUnavailableException (co.cask.cdap.common.ServiceUnavailableException)1 UnauthenticatedException (co.cask.cdap.common.UnauthenticatedException)1 ExploreClient (co.cask.cdap.explore.client.ExploreClient)1 ExploreException (co.cask.cdap.explore.service.ExploreException)1 SQLException (java.sql.SQLException)1 Before (org.junit.Before)1