Search in sources :

Example 1 with FixedAddressExploreClient

use of io.cdap.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.", e);
    } catch (ServiceUnavailableException | ExploreException e) {
        throw new SQLException("Cannot connect to " + url + ", service not available.", e);
    }
    return new ExploreConnection(exploreClient, namespace, params);
}
Also used : ExploreClient(io.cdap.cdap.explore.client.ExploreClient) FixedAddressExploreClient(io.cdap.cdap.explore.client.FixedAddressExploreClient) UnauthenticatedException(io.cdap.cdap.security.spi.authentication.UnauthenticatedException) SQLException(java.sql.SQLException) ServiceUnavailableException(io.cdap.cdap.common.ServiceUnavailableException) FixedAddressExploreClient(io.cdap.cdap.explore.client.FixedAddressExploreClient) ExploreException(io.cdap.cdap.explore.service.ExploreException)

Example 2 with FixedAddressExploreClient

use of io.cdap.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);
    serviceClient = new ServiceClient(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(io.cdap.cdap.client.config.ConnectionConfig) FixedAddressExploreClient(io.cdap.cdap.explore.client.FixedAddressExploreClient) Before(org.junit.Before)

Aggregations

FixedAddressExploreClient (io.cdap.cdap.explore.client.FixedAddressExploreClient)2 ConnectionConfig (io.cdap.cdap.client.config.ConnectionConfig)1 ServiceUnavailableException (io.cdap.cdap.common.ServiceUnavailableException)1 ExploreClient (io.cdap.cdap.explore.client.ExploreClient)1 ExploreException (io.cdap.cdap.explore.service.ExploreException)1 UnauthenticatedException (io.cdap.cdap.security.spi.authentication.UnauthenticatedException)1 SQLException (java.sql.SQLException)1 Before (org.junit.Before)1