com.google.apphosting.api.DeadlineExceededException Java Examples
The following examples show how to use
com.google.apphosting.api.DeadlineExceededException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NordnUploadAction.java From nomulus with Apache License 2.0 | 6 votes |
/** Leases and returns all tasks from the queue with the specified tag tld, in batches. */ List<TaskHandle> loadAllTasks(Queue queue, String tld) { ImmutableList.Builder<TaskHandle> allTasks = new ImmutableList.Builder<>(); while (true) { List<TaskHandle> tasks = retrier.callWithRetry( () -> queue.leaseTasks( LeaseOptions.Builder.withTag(tld) .leasePeriod(LEASE_PERIOD.getMillis(), TimeUnit.MILLISECONDS) .countLimit(TaskQueueUtils.getBatchSize())), TransientFailureException.class, DeadlineExceededException.class); if (tasks.isEmpty()) { return allTasks.build(); } allTasks.addAll(tasks); } }
Example #2
Source File: AutomatedActionExceptionTestAction.java From teammates with GNU General Public License v2.0 | 6 votes |
@Override @SuppressWarnings("PMD.AvoidThrowingNullPointerException") // deliberately done for testing public void execute() { String error = getNonNullRequestParamValue(Const.ParamsNames.ERROR); if (error.equals(AssertionError.class.getSimpleName())) { throw new AssertionError("AssertionError testing"); } if (error.equals(NullPointerException.class.getSimpleName())) { throw new NullPointerException("NullPointerException testing"); } if (error.equals(DeadlineExceededException.class.getSimpleName())) { throw new DeadlineExceededException("DeadlineExceededException testing"); } if (error.equals(DatastoreTimeoutException.class.getSimpleName())) { throw new DatastoreTimeoutException("DatastoreTimeoutException testing"); } if (error.equals(InvalidHttpParameterException.class.getSimpleName())) { throw new InvalidHttpParameterException("InvalidHttpParameterException testing"); } }
Example #3
Source File: DnsQueue.java From nomulus with Apache License 2.0 | 5 votes |
/** Returns handles for a batch of tasks, leased for the specified duration. */ public List<TaskHandle> leaseTasks(Duration leaseDuration) { try { rateLimiter.acquire(); int numTasks = queue.fetchStatistics().getNumTasks(); logger.at((numTasks >= leaseTasksBatchSize) ? Level.WARNING : Level.INFO).log( "There are %d tasks in the DNS queue '%s'.", numTasks, DNS_PULL_QUEUE_NAME); return queue.leaseTasks(leaseDuration.getMillis(), MILLISECONDS, leaseTasksBatchSize); } catch (TransientFailureException | DeadlineExceededException e) { logger.atSevere().withCause(e).log("Failed leasing tasks too fast"); return ImmutableList.of(); } }
Example #4
Source File: DnsQueue.java From nomulus with Apache License 2.0 | 5 votes |
/** Delete a list of tasks, removing them from the queue permanently. */ public void deleteTasks(List<TaskHandle> tasks) { try { queue.deleteTask(tasks); } catch (TransientFailureException | DeadlineExceededException e) { logger.atSevere().withCause(e).log("Failed deleting tasks too fast"); } }
Example #5
Source File: NordnUploadActionTest.java From nomulus with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void test_loadAllTasks_retryLogic_thirdTrysTheCharm() { Queue queue = mock(Queue.class); TaskHandle task = new TaskHandle(TaskOptions.Builder.withTaskName("blah"), "blah"); when(queue.leaseTasks(any(LeaseOptions.class))) .thenThrow(TransientFailureException.class) .thenThrow(DeadlineExceededException.class) .thenReturn(ImmutableList.of(task), ImmutableList.of()); assertThat(action.loadAllTasks(queue, "tld")).containsExactly(task); }
Example #6
Source File: AdminExceptionTestAction.java From teammates with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("PMD.AvoidThrowingNullPointerException") // deliberately done for testing public JsonResult execute() { String error = getNonNullRequestParamValue(Const.ParamsNames.ERROR); if (error.equals(AssertionError.class.getSimpleName())) { throw new AssertionError("AssertionError testing"); } if (error.equals(NullPointerException.class.getSimpleName())) { throw new NullPointerException("NullPointerException testing"); } if (error.equals(DeadlineExceededException.class.getSimpleName())) { throw new DeadlineExceededException("DeadlineExceededException testing"); } if (error.equals(DatastoreTimeoutException.class.getSimpleName())) { throw new DatastoreTimeoutException("DatastoreTimeoutException testing"); } if (error.equals(InvalidHttpParameterException.class.getSimpleName())) { throw new InvalidHttpParameterException("InvalidHttpParameterException testing"); } if (error.equals(UnauthorizedAccessException.class.getSimpleName())) { throw new UnauthorizedAccessException("UnauthorizedAccessException testing"); } if (error.equals(EntityNotFoundException.class.getSimpleName())) { throw new EntityNotFoundException(new EntityDoesNotExistException("EntityNotFoundException testing")); } return new JsonResult("Test output"); }
Example #7
Source File: SystemErrorEmailReportE2ETest.java From teammates with GNU General Public License v2.0 | 3 votes |
private void testDeadlineExceededException() { ______TS("DeadlineExceededException testing"); String url = createUrl(Const.ResourceURIs.EXCEPTION) .withParam(Const.ParamsNames.ERROR, DeadlineExceededException.class.getSimpleName()) .toString(); BackDoor.executeGetRequest(url, null); print("DeadlineExceededException triggered, please check your crash report at " + Config.SUPPORT_EMAIL); }
Example #8
Source File: WebApiServletTest.java From teammates with GNU General Public License v2.0 | 2 votes |
@Test public void allTests() throws Exception { ______TS("Typical case: valid action mapping"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, "NoException"); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_OK, mockResponse.getStatus()); ______TS("Failure case: invalid action mapping"); setupMocks(HttpGet.METHOD_NAME, "nonexistent"); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_NOT_FOUND, mockResponse.getStatus()); setupMocks(HttpPost.METHOD_NAME, Const.ResourceURIs.EXCEPTION); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, mockResponse.getStatus()); ______TS("Failure case: NullHttpParameterException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_BAD_REQUEST, mockResponse.getStatus()); ______TS("Failure case: InvalidHttpParameterException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, InvalidHttpParameterException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_BAD_REQUEST, mockResponse.getStatus()); ______TS("Failure case: DeadlineExceededException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, DeadlineExceededException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT, mockResponse.getStatus()); ______TS("Failure case: DatastoreTimeoutException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, DatastoreTimeoutException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT, mockResponse.getStatus()); ______TS("Failure case: UnauthorizedAccessException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, UnauthorizedAccessException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_FORBIDDEN, mockResponse.getStatus()); ______TS("Failure case: EntityNotFoundException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, EntityNotFoundException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_NOT_FOUND, mockResponse.getStatus()); ______TS("Failure case: NullPointerException"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, NullPointerException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, mockResponse.getStatus()); ______TS("Failure case: AssertionError"); setupMocks(HttpGet.METHOD_NAME, Const.ResourceURIs.EXCEPTION); mockRequest.addParam(Const.ParamsNames.ERROR, AssertionError.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, mockResponse.getStatus()); }
Example #9
Source File: AutomatedServletTest.java From teammates with GNU General Public License v2.0 | 2 votes |
@Test public void allTests() { ______TS("Typical case: valid action mapping"); setupMocks(Const.CronJobURIs.AUTOMATED_FEEDBACK_OPENING_REMINDERS); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_OK, mockResponse.getStatus()); ______TS("\"Successful\" case: invalid action mapping"); setupMocks("/auto/mappingDoesNotExist"); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_OK, mockResponse.getStatus()); ______TS("\"Successful\" case: NullHttpParameterException"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_OK, mockResponse.getStatus()); ______TS("\"Successful\" case: InvalidHttpParameterException"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); mockRequest.addParam(Const.ParamsNames.ERROR, InvalidHttpParameterException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_OK, mockResponse.getStatus()); ______TS("Failure case: DeadlineExceededException"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); mockRequest.addParam(Const.ParamsNames.ERROR, DeadlineExceededException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT, mockResponse.getStatus()); ______TS("Failure case: DatastoreTimeoutException"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); mockRequest.addParam(Const.ParamsNames.ERROR, DatastoreTimeoutException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT, mockResponse.getStatus()); ______TS("Failure case: NullPointerException"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); mockRequest.addParam(Const.ParamsNames.ERROR, NullPointerException.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, mockResponse.getStatus()); ______TS("Failure case: AssertionError"); setupMocks(Const.CronJobURIs.AUTOMATED_EXCEPTION_TEST); mockRequest.addParam(Const.ParamsNames.ERROR, AssertionError.class.getSimpleName()); SERVLET.doGet(mockRequest, mockResponse); assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, mockResponse.getStatus()); }