@Test(expected = FideliusException.class) public void scanDynamoDBFailsAfterIntervalReaches60SecondsWhenRetryingOnThrottlingException() { when(fakeMapper.scan(any(), any())).thenThrow(new ProvisionedThroughputExceededException("test")); dynamoDBService.scanDynamoDB(new DynamoDBScanExpression(), Object.class, fakeMapper); }
public <T> List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper) { logger.info("Scanning DynamoDB table..."); List<T> queryResults = null; long startTime = System.currentTimeMillis(); try { PaginatedScanList<T> scanResults = mapper.scan(clazz, scanExp); queryResults = new ArrayList<>(scanResults); } catch (ProvisionedThroughputExceededException pte) { logger.error("Provisioned Throughput Exceeded. ", pte); } catch (ResourceNotFoundException rnf) { String message = "Credential table not found!"; logger.error(message, rnf); throw new FideliusException(message, HttpStatus.NOT_FOUND); } if (queryResults == null) { logger.error("Throttling rate exceeded!"); throw new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT); } else { logger.info(String.format("Scan completed in %.3f seconds", (System.currentTimeMillis() - startTime) / 1000.0)); } return queryResults; }
DynamoDBService { public <T> List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper) { logger.info("Scanning DynamoDB table..."); List<T> queryResults = null; long startTime = System.currentTimeMillis(); try { PaginatedScanList<T> scanResults = mapper.scan(clazz, scanExp); queryResults = new ArrayList<>(scanResults); } catch (ProvisionedThroughputExceededException pte) { logger.error("Provisioned Throughput Exceeded. ", pte); } catch (ResourceNotFoundException rnf) { String message = "Credential table not found!"; logger.error(message, rnf); throw new FideliusException(message, HttpStatus.NOT_FOUND); } if (queryResults == null) { logger.error("Throttling rate exceeded!"); throw new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT); } else { logger.info(String.format("Scan completed in %.3f seconds", (System.currentTimeMillis() - startTime) / 1000.0)); } return queryResults; } }
DynamoDBService { public <T> List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper) { logger.info("Scanning DynamoDB table..."); List<T> queryResults = null; long startTime = System.currentTimeMillis(); try { PaginatedScanList<T> scanResults = mapper.scan(clazz, scanExp); queryResults = new ArrayList<>(scanResults); } catch (ProvisionedThroughputExceededException pte) { logger.error("Provisioned Throughput Exceeded. ", pte); } catch (ResourceNotFoundException rnf) { String message = "Credential table not found!"; logger.error(message, rnf); throw new FideliusException(message, HttpStatus.NOT_FOUND); } if (queryResults == null) { logger.error("Throttling rate exceeded!"); throw new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT); } else { logger.info(String.format("Scan completed in %.3f seconds", (System.currentTimeMillis() - startTime) / 1000.0)); } return queryResults; }  }
DynamoDBService { public <T> List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper) { logger.info("Scanning DynamoDB table..."); List<T> queryResults = null; long startTime = System.currentTimeMillis(); try { PaginatedScanList<T> scanResults = mapper.scan(clazz, scanExp); queryResults = new ArrayList<>(scanResults); } catch (ProvisionedThroughputExceededException pte) { logger.error("Provisioned Throughput Exceeded. ", pte); } catch (ResourceNotFoundException rnf) { String message = "Credential table not found!"; logger.error(message, rnf); throw new FideliusException(message, HttpStatus.NOT_FOUND); } if (queryResults == null) { logger.error("Throttling rate exceeded!"); throw new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT); } else { logger.info(String.format("Scan completed in %.3f seconds", (System.currentTimeMillis() - startTime) / 1000.0)); } return queryResults; }  List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper); List<T> queryDynamoDB(DynamoDBQueryExpression queryRequest, Class<T> clazz, DynamoDBMapper dynamoDBMapper); DynamoDBMapper createMapper(String account, String region, String tableName); }
DynamoDBService { public <T> List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper) { logger.info("Scanning DynamoDB table..."); List<T> queryResults = null; long startTime = System.currentTimeMillis(); try { PaginatedScanList<T> scanResults = mapper.scan(clazz, scanExp); queryResults = new ArrayList<>(scanResults); } catch (ProvisionedThroughputExceededException pte) { logger.error("Provisioned Throughput Exceeded. ", pte); } catch (ResourceNotFoundException rnf) { String message = "Credential table not found!"; logger.error(message, rnf); throw new FideliusException(message, HttpStatus.NOT_FOUND); } if (queryResults == null) { logger.error("Throttling rate exceeded!"); throw new FideliusException("Throttling rate exceeded!", HttpStatus.REQUEST_TIMEOUT); } else { logger.info(String.format("Scan completed in %.3f seconds", (System.currentTimeMillis() - startTime) / 1000.0)); } return queryResults; }  List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper); List<T> queryDynamoDB(DynamoDBQueryExpression queryRequest, Class<T> clazz, DynamoDBMapper dynamoDBMapper); DynamoDBMapper createMapper(String account, String region, String tableName);  }