use of org.apache.pulsar.functions.worker.request.ServiceRequestInfo in project incubator-pulsar by apache.
the class FunctionMetaDataManager method submit.
@VisibleForTesting
CompletableFuture<RequestResult> submit(Request.ServiceRequest serviceRequest) {
ServiceRequestInfo serviceRequestInfo = ServiceRequestInfo.of(serviceRequest);
CompletableFuture<MessageId> messageIdCompletableFuture = this.serviceRequestManager.submitRequest(serviceRequest);
serviceRequestInfo.setCompletableFutureRequestMessageId(messageIdCompletableFuture);
CompletableFuture<RequestResult> requestResultCompletableFuture = new CompletableFuture<>();
serviceRequestInfo.setRequestResultCompletableFuture(requestResultCompletableFuture);
this.pendingServiceRequests.put(serviceRequestInfo.getServiceRequest().getRequestId(), serviceRequestInfo);
return requestResultCompletableFuture;
}
use of org.apache.pulsar.functions.worker.request.ServiceRequestInfo in project incubator-pulsar by apache.
the class FunctionMetaDataManager method completeRequest.
/**
* Complete requests that this worker has pending
* @param serviceRequest
* @param isSuccess
* @param message
*/
private void completeRequest(Request.ServiceRequest serviceRequest, boolean isSuccess, String message) {
ServiceRequestInfo pendingServiceRequestInfo = this.pendingServiceRequests.getOrDefault(serviceRequest.getRequestId(), null);
if (pendingServiceRequestInfo != null) {
RequestResult requestResult = new RequestResult();
requestResult.setSuccess(isSuccess);
requestResult.setMessage(message);
pendingServiceRequestInfo.getRequestResultCompletableFuture().complete(requestResult);
}
}
Aggregations