use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project OpenAttestation by OpenAttestation.
the class ApacheHttpClient method delete.
public ApiResponse delete(String requestURL) throws IOException, SignatureException {
log.debug("DELETE url: {}", requestURL);
HttpDelete request = new HttpDelete(requestURL);
// send the request and print the response
HttpResponse httpResponse = httpClient.execute(request);
ApiResponse apiResponse = readResponse(httpResponse);
request.releaseConnection();
return apiResponse;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project OpenAttestation by OpenAttestation.
the class ApacheHttpClient method put.
public ApiResponse put(String requestURL, ApiRequest message) throws IOException, SignatureException {
log.debug("PUT url: {}", requestURL);
log.debug("PUT content: {}", message == null ? "(empty)" : message.content);
HttpPut request = new HttpPut(requestURL);
if (message != null && message.content != null) {
request.setEntity(new StringEntity(message.content, ContentType.create(message.contentType.toString(), "UTF-8")));
}
HttpResponse httpResponse = httpClient.execute(request);
ApiResponse apiResponse = readResponse(httpResponse);
request.releaseConnection();
return apiResponse;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project OpenAttestation by OpenAttestation.
the class ApacheHttpClient method post.
public ApiResponse post(String requestURL, ApiRequest message) throws IOException, SignatureException {
log.debug("POST url: {}", requestURL);
log.debug("POST content: {}", message == null ? "(empty)" : message.content);
HttpPost request = new HttpPost(requestURL);
if (message != null && message.content != null) {
request.setEntity(new StringEntity(message.content, ContentType.create(message.contentType.toString(), "UTF-8")));
}
HttpResponse httpResponse = httpClient.execute(request);
ApiResponse apiResponse = readResponse(httpResponse);
request.releaseConnection();
return apiResponse;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project pinot by linkedin.
the class BackfillControllerAPIs method getAllSegments.
/**
* Fetches the list of all segment names for a table
* @param tableName
* @return
* @throws IOException
*/
public List<String> getAllSegments(String tableName) throws IOException {
List<String> allSegments = new ArrayList<>();
HttpClient controllerClient = new DefaultHttpClient();
HttpGet req = new HttpGet(SEGMENTS_ENDPOINT + URLEncoder.encode(tableName, UTF_8));
HttpResponse res = controllerClient.execute(controllerHttpHost, req);
try {
if (res.getStatusLine().getStatusCode() != 200) {
throw new IllegalStateException(res.getStatusLine().toString());
}
InputStream content = res.getEntity().getContent();
String response = IOUtils.toString(content);
List<String> allSegmentsPaths = getSegmentsFromResponse(response);
for (String segment : allSegmentsPaths) {
allSegments.add(segment.substring(segment.lastIndexOf("/") + 1));
}
LOGGER.info("All segments : {}", allSegments);
} finally {
if (res.getEntity() != null) {
EntityUtils.consume(res.getEntity());
}
}
return allSegments;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project pinot by linkedin.
the class BackfillControllerAPIs method getSegmentMetadata.
/**
* Returns the metadata of a segment, given the segment name and table name
* @param tableName - table where segment resides
* @param segmentName - name of the segment
* @return
* @throws IOException
*/
public Map<String, String> getSegmentMetadata(String tableName, String segmentName) throws IOException {
Map<String, String> metadata = null;
HttpClient controllerClient = new DefaultHttpClient();
HttpGet req = new HttpGet(TABLES_ENDPOINT + URLEncoder.encode(tableName, UTF_8) + "/" + SEGMENTS_ENDPOINT + URLEncoder.encode(segmentName, UTF_8) + "/" + METADATA_ENDPOINT);
HttpResponse res = controllerClient.execute(controllerHttpHost, req);
try {
if (res.getStatusLine().getStatusCode() != 200) {
throw new IllegalStateException(res.getStatusLine().toString());
}
InputStream content = res.getEntity().getContent();
String metadataResponse = IOUtils.toString(content);
metadata = getMetadataFromResponse(metadataResponse);
} finally {
if (res.getEntity() != null) {
EntityUtils.consume(res.getEntity());
}
}
return metadata;
}
Aggregations