Created
April 2, 2015 14:58
-
-
Save jsanda/702b82b06222ded41aad to your computer and use it in GitHub Desktop.
add data end point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void addDataForMetric( | |
@Suspended final AsyncResponse asyncResponse, | |
@PathParam("tenantId") final String tenantId, @PathParam("id") String id, | |
@ApiParam(value = "List of datapoints containing timestamp and value", required = true) | |
List<NumericData> data | |
) { | |
Callable<Response> callable = () -> { | |
// long sleep = random.nextLong() % SLEEP; | |
// if (sleep > 0) { | |
// try { | |
// Thread.sleep(sleep); | |
// } catch (InterruptedException e) { | |
// } | |
// } | |
return Response.status(Status.OK).build(); | |
}; | |
ListenableFuture<Response> future = threadPool.submit(callable); | |
Futures.addCallback(future, new FutureCallback<Response>() { | |
@Override | |
public void onSuccess(Response response) { | |
asyncResponse.resume(response); | |
} | |
@Override | |
public void onFailure(Throwable t) { | |
String msg = "Failed to perform operation due to an error: " + Throwables.getRootCause(t).getMessage(); | |
asyncResponse.resume(Response.serverError().entity(new ApiError(msg)).build()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment