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();
}
Aggregations