Search in sources :

Example 1 with PermitAllocation

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);
}
Also used : PermitAllocation(org.apache.gobblin.restli.throttling.PermitAllocation) Builder(lombok.Builder)

Example 2 with PermitAllocation

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));
}
Also used : EmptyRecord(com.linkedin.restli.common.EmptyRecord) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) PermitsGetRequestBuilder(org.apache.gobblin.restli.throttling.PermitsGetRequestBuilder) PermitsRequestBuilders(org.apache.gobblin.restli.throttling.PermitsRequestBuilders) PermitAllocation(org.apache.gobblin.restli.throttling.PermitAllocation)

Aggregations

PermitAllocation (org.apache.gobblin.restli.throttling.PermitAllocation)2 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)1 EmptyRecord (com.linkedin.restli.common.EmptyRecord)1 Builder (lombok.Builder)1 PermitsGetRequestBuilder (org.apache.gobblin.restli.throttling.PermitsGetRequestBuilder)1 PermitsRequestBuilders (org.apache.gobblin.restli.throttling.PermitsRequestBuilders)1