use of co.cask.cdap.client.config.ConnectionConfig in project cdap by caskdata.
the class AppFabricTestBase method getClientConfig.
private static ClientConfig getClientConfig(DiscoveryServiceClient discoveryClient, String service) {
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryClient.discover(service));
Discoverable discoverable = endpointStrategy.pick(1, TimeUnit.SECONDS);
Assert.assertNotNull(discoverable);
int port = discoverable.getSocketAddress().getPort();
ConnectionConfig connectionConfig = ConnectionConfig.builder().setHostname(hostname).setPort(port).build();
return ClientConfig.builder().setConnectionConfig(connectionConfig).build();
}
use of co.cask.cdap.client.config.ConnectionConfig in project cdap by caskdata.
the class ArtifactHttpHandlerTest method setup.
@BeforeClass
public static void setup() throws IOException {
artifactRepository = getInjector().getInstance(ArtifactRepository.class);
systemArtifactsDir = getInjector().getInstance(CConfiguration.class).get(Constants.AppFabric.SYSTEM_ARTIFACTS_DIR);
DiscoveryServiceClient discoveryClient = getInjector().getInstance(DiscoveryServiceClient.class);
ServiceDiscovered metadataHttpDiscovered = discoveryClient.discover(Constants.Service.METADATA_SERVICE);
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(metadataHttpDiscovered);
Discoverable discoverable = endpointStrategy.pick(1, TimeUnit.SECONDS);
Assert.assertNotNull(discoverable);
String host = "127.0.0.1";
int port = discoverable.getSocketAddress().getPort();
ConnectionConfig connectionConfig = ConnectionConfig.builder().setHostname(host).setPort(port).build();
clientConfig = ClientConfig.builder().setConnectionConfig(connectionConfig).build();
metadataClient = new MetadataClient(clientConfig);
}
use of co.cask.cdap.client.config.ConnectionConfig 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.client.config.ConnectionConfig in project cdap by caskdata.
the class AbstractClientTest method setUp.
@Before
public void setUp() throws Throwable {
StandaloneTester standalone = getStandaloneTester();
ConnectionConfig connectionConfig = InstanceURIParser.DEFAULT.parse(standalone.getBaseURI().toString());
clientConfig = new ClientConfig.Builder().setDefaultReadTimeout(60 * 1000).setUploadReadTimeout(120 * 1000).setConnectionConfig(connectionConfig).build();
}
use of co.cask.cdap.client.config.ConnectionConfig in project cdap by caskdata.
the class InstanceURIParser method parse.
public CLIConnectionConfig parse(String uriString) {
if (!uriString.contains("://")) {
uriString = DEFAULT_PROTOCOL + "://" + uriString;
}
URI uri = URI.create(uriString);
NamespaceId namespace = (uri.getPath() == null || uri.getPath().isEmpty() || "/".equals(uri.getPath())) ? NamespaceId.DEFAULT : new NamespaceId(uri.getPath().substring(1));
String hostname = uri.getHost();
boolean sslEnabled = "https".equals(uri.getScheme());
int port = uri.getPort();
if (port == -1) {
port = sslEnabled ? cConf.getInt(Constants.Router.ROUTER_SSL_PORT) : cConf.getInt(Constants.Router.ROUTER_PORT);
}
ConnectionConfig config = ConnectionConfig.builder().setHostname(hostname).setPort(port).setSSLEnabled(sslEnabled).build();
return new CLIConnectionConfig(config, namespace, null);
}
Aggregations