org.asynchttpclient.Param Java Examples
The following examples show how to use
org.asynchttpclient.Param.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SMSWrapper.java From blynk-server with GNU General Public License v3.0 | 6 votes |
public void send(String to, String text) { ArrayList<Param> params = new ArrayList<>(); params.add(new Param("api_key", key)); params.add(new Param("api_secret", secret)); params.add(new Param("from", "Blynk")); params.add(new Param("to", to)); params.add(new Param("text", text)); httpclient.preparePost("https://rest.nexmo.com/sms/json") .setQueryParams(params) .execute(new AsyncCompletionHandler<Response>() { @Override public Response onCompleted(org.asynchttpclient.Response response) throws Exception { if (response.getStatusCode() == 200) { SmsResponse smsResponse = smsResponseReader.readValue(response.getResponseBody()); if (!smsResponse.messages[0].status.equals("0")) { log.error(smsResponse.messages[0].error); } } return response; } }); }
Example #2
Source File: ClickHouseClient.java From clickhouse-client-java with Apache License 2.0 | 4 votes |
public ClickHouseClient setOptionalParams(Map<String, String> params) { params.entrySet().forEach(e -> optParams.add(new Param(e.getKey(), e.getValue()))); return this; }
Example #3
Source File: SlaManager.java From attic-aurora with Apache License 2.0 | 4 votes |
private boolean coordinatorAllows( IScheduledTask task, String taskKey, ICoordinatorSlaPolicy slaPolicy, Map<String, String> params) throws InterruptedException, ExecutionException, TException { LOG.info("Checking coordinator: {} for task: {}", slaPolicy.getCoordinatorUrl(), taskKey); String taskConfig = new TSerializer(new TSimpleJSONProtocol.Factory()) .toString(task.newBuilder()); JsonObject jsonBody = new JsonObject(); jsonBody.add("taskConfig", new JsonParser().parse(taskConfig)); jsonBody.addProperty(TASK_PARAM, taskKey); params.forEach(jsonBody::addProperty); Response response = httpClient.preparePost(slaPolicy.getCoordinatorUrl()) .setQueryParams(ImmutableList.of(new Param(TASK_PARAM, taskKey))) .setBody(new Gson().toJson(jsonBody)) .execute() .get(); if (response.getStatusCode() != HttpConstants.ResponseStatusCodes.OK_200) { LOG.error("Request failed to coordinator: {} for task: {}. Response: {}", slaPolicy.getCoordinatorUrl(), taskKey, response.getStatusCode()); incrementErrorCount(USER_ERRORS_STAT_NAME, taskKey); return false; } successCounter.incrementAndGet(); String json = response.getResponseBody(); LOG.info("Got response: {} from {} for task: {}", json, slaPolicy.getCoordinatorUrl(), taskKey); Map<String, Boolean> result = new Gson().fromJson( json, new TypeReference<Map<String, Boolean>>() { }.getType()); return result.get(slaPolicy.isSetStatusKey() ? slaPolicy.getStatusKey() : "drain"); }