use of com.ning.http.client.Response in project openhab1-addons by openhab.
the class PlexConnector method internalSendCommand.
private void internalSendCommand(String machineIdentifier, String url) throws IOException {
logger.debug("Calling url {}", url);
BoundRequestBuilder builder = client.prepareGet(url).setHeaders(getDefaultHeaders()).setHeader("X-Plex-Target-Client-Identifier", machineIdentifier);
builder.execute(new AsyncCompletionHandler<Response>() {
@Override
public Response onCompleted(Response response) throws Exception {
if (response.getStatusCode() != 200) {
logger.error("Error while sending command to Plex: {}\r\n{}", response.getStatusText(), response.getResponseBody());
}
return response;
}
@Override
public void onThrowable(Throwable t) {
logger.error("Error sending command to Plex", t);
}
});
}
use of com.ning.http.client.Response in project elasticsearch-suggest-plugin by spinscale.
the class RestSuggestActionTest method getStatistics.
@Override
public FstStats getStatistics() throws Exception {
List<FstStats.FstIndexShardStats> stats = Lists.newArrayList();
Response r = httpClient.prepareGet("http://localhost:" + port + "/__suggestStatistics").execute().get();
assertThat(r.getStatusCode(), is(200));
System.out.println(r.getResponseBody());
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootObj = objectMapper.readTree(r.getResponseBody());
FstStats fstStats = new FstStats();
ArrayNode jsonFstStats = (ArrayNode) rootObj.get("fstStats");
Iterator<JsonNode> nodesIterator = jsonFstStats.iterator();
while (nodesIterator.hasNext()) {
JsonNode fstStatsNodeEntry = nodesIterator.next();
if (fstStatsNodeEntry.isObject()) {
ShardId shardId = new ShardId(fstStatsNodeEntry.get("index").asText(), fstStatsNodeEntry.get("id").asInt());
FstStats.FstIndexShardStats fstIndexShardStats = new FstStats.FstIndexShardStats(shardId, null, null, fstStatsNodeEntry.get("sizeInBytes").getLongValue());
stats.add(fstIndexShardStats);
}
fstStats.getStats().addAll(stats);
}
return fstStats;
}
use of com.ning.http.client.Response in project elasticsearch-suggest-plugin by spinscale.
the class RestSuggestActionTest method refreshIndexSuggesters.
@Override
public void refreshIndexSuggesters(String index) throws Exception {
Response r = httpClient.preparePost("http://localhost:" + port + "/" + index + "/product/__suggestRefresh").execute().get();
assertThat(r.getStatusCode(), is(200));
}
use of com.ning.http.client.Response in project elasticsearch-suggest-plugin by spinscale.
the class RestSuggestActionTest method refreshAllSuggesters.
@Override
public void refreshAllSuggesters() throws Exception {
Response r = httpClient.preparePost("http://localhost:" + port + "/__suggestRefresh").execute().get();
assertThat(r.getStatusCode(), is(200));
}
use of com.ning.http.client.Response in project elasticsearch-suggest-plugin by spinscale.
the class RestSuggestActionTest method getSuggestions.
@Override
public List<String> getSuggestions(SuggestionQuery suggestionQuery) throws Exception {
String json = createJSONQuery(suggestionQuery);
String url = "http://localhost:" + port + "/" + suggestionQuery.index + "/" + suggestionQuery.type + "/__suggest";
Response r = httpClient.preparePost(url).setBody(json).execute().get();
assertThat(r.getStatusCode(), is(200));
assertThatResponseHasNoShardFailures(r);
return getSuggestionsFromResponse(r.getResponseBody());
}
Aggregations