use of com.sun.jersey.api.client.config.DefaultClientConfig in project data-access by pentaho.
the class TestDataSourceResource method getConnectionByName.
private static IDatabaseConnection getConnectionByName(String aConnecitonName) {
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
IDatabaseConnection connection = null;
WebResource resource = client.resource(getURL);
try {
connection = resource.type(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_XML).entity(aConnecitonName).get(DatabaseConnection.class);
} catch (Exception ex) {
ex.printStackTrace();
}
return connection;
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project cloudbreak by hortonworks.
the class YarnHttpClient method getNewWebResource.
public WebResource getNewWebResource(String url) {
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
client.addFilter(new LoggingFilter());
return client.resource(url);
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project cloudbreak by hortonworks.
the class YarnHttpClient method deleteApplication.
@Override
public void deleteApplication(DeleteApplicationRequest deleteApplicationRequest) throws YarnClientException, MalformedURLException {
// Add the application name to the URL
YarnEndpoint dashEndpoint = new YarnEndpoint(apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH + '/' + deleteApplicationRequest.getName());
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
// Delete the application
WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString());
ClientResponse response = webResource.accept("application/json").type("application/json").delete(ClientResponse.class);
// Validate HTTP 204 return
String msg;
switch(response.getStatus()) {
case YarnResourceConstants.HTTP_NO_CONTENT:
msg = String.format("Successfully deleted application %s", deleteApplicationRequest.getName());
LOGGER.debug(msg);
break;
case YarnResourceConstants.HTTP_NOT_FOUND:
msg = String.format("Application %s not found, already deleted?", deleteApplicationRequest.getName());
LOGGER.debug(msg);
break;
default:
msg = String.format("Received %d status code from url %s, reason: %s", response.getStatus(), dashEndpoint.getFullEndpointUrl().toString(), response.getEntity(String.class));
LOGGER.debug(msg);
throw new YarnClientException(msg);
}
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project cloudbreak by hortonworks.
the class YarnHttpClient method validateApiEndpoint.
@Override
public void validateApiEndpoint() throws CloudbreakOrchestratorFailedException, MalformedURLException {
YarnEndpoint dashEndpoint = new YarnEndpoint(apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH);
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString());
ClientResponse response = webResource.accept("application/json").type("application/json").get(ClientResponse.class);
// Validate HTTP 200 status code
if (response.getStatus() != YarnResourceConstants.HTTP_SUCCESS) {
String msg = String.format("Received %d status code from url %s, reason: %s", response.getStatus(), dashEndpoint.getFullEndpointUrl().toString(), response.getEntity(String.class));
LOGGER.debug(msg);
throw new CloudbreakOrchestratorFailedException(msg);
}
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project cloudbreak by hortonworks.
the class YarnHttpClient method getNewWebResource.
public WebResource getNewWebResource(String url) {
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
return client.resource(url);
}
Aggregations