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);
}
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);
}
Aggregations