Search in sources :

Example 1 with InternalFailureException

use of com.google.appengine.api.taskqueue.InternalFailureException in project appengine-java-standard by GoogleCloudPlatform.

the class LocalTaskQueue method add.

@LatencyPercentiles(latency50th = 4)
public TaskQueueAddResponse add(Status status, TaskQueueAddRequest addRequest) {
    TaskQueueBulkAddRequest.Builder bulkRequest = TaskQueueBulkAddRequest.newBuilder();
    bulkRequest.addAddRequestBuilder().mergeFrom(addRequest);
    TaskQueueAddResponse.Builder addResponse = TaskQueueAddResponse.newBuilder();
    TaskQueueBulkAddResponse bulkResponse = bulkAdd(status, bulkRequest.build());
    if (bulkResponse.getTaskResultCount() != 1) {
        throw new InternalFailureException(String.format("expected 1 result from BulkAdd(), got %d", bulkResponse.getTaskResultCount()));
    }
    int result = bulkResponse.getTaskResult(0).getResult().getNumber();
    if (result != ErrorCode.OK_VALUE) {
        throw new ApiProxy.ApplicationException(result);
    } else if (bulkResponse.getTaskResult(0).hasChosenTaskName()) {
        addResponse.setChosenTaskName(bulkResponse.getTaskResult(0).getChosenTaskName());
    }
    return addResponse.build();
}
Also used : InternalFailureException(com.google.appengine.api.taskqueue.InternalFailureException) TaskQueueAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse) TaskQueueBulkAddRequest(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest) TaskQueueBulkAddResponse(com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse) LatencyPercentiles(com.google.appengine.tools.development.LatencyPercentiles)

Aggregations

InternalFailureException (com.google.appengine.api.taskqueue.InternalFailureException)1 TaskQueueAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueAddResponse)1 TaskQueueBulkAddRequest (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddRequest)1 TaskQueueBulkAddResponse (com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueBulkAddResponse)1 LatencyPercentiles (com.google.appengine.tools.development.LatencyPercentiles)1