use of org.apache.gobblin.restli.throttling.PermitAllocation in project incubator-gobblin by apache.
the class BatchedPermitsRequesterTest method satisfyRequest.
@Builder(builderMethodName = "satisfyRequestBuilder", buildMethodName = "satisfy")
public static void satisfyRequest(RequestAndCallback requestAndCallback, long expiration) {
PermitAllocation allocation = new PermitAllocation();
allocation.setPermits(requestAndCallback.getRequest().getPermits());
allocation.setExpiration(expiration > 0 ? expiration : Long.MAX_VALUE);
Response<PermitAllocation> response = Mockito.mock(Response.class);
Mockito.when(response.getEntity()).thenReturn(allocation);
requestAndCallback.getCallback().onSuccess(response);
}
use of org.apache.gobblin.restli.throttling.PermitAllocation in project incubator-gobblin by apache.
the class RestClientRequestSender method sendRequest.
@Override
public void sendRequest(PermitRequest request, Callback<Response<PermitAllocation>> callback) {
PermitsGetRequestBuilder getBuilder = new PermitsRequestBuilders().get();
Request<PermitAllocation> fullRequest = getBuilder.id(new ComplexResourceKey<>(request, new EmptyRecord())).build();
getRestClient().sendRequest(fullRequest, decorateCallback(request, callback));
}
Aggregations