@Test public void canRetryUploadAndRecoverWhenServerError() throws IOException, StorageException { REQUESTED_PUT_FAILURES.set(2); when(_mockPropertiesUtil.getHttpStorageUploadRetryCount()) .thenReturn(2); Path filePath = getTestFileCopy(); JsonOutputObject outputObject = mock(JsonOutputObject.class); when(outputObject.getJobProperties()) .thenReturn(getS3Properties()); when(_mockLocalStorageBackend.store(outputObject)) .thenReturn(filePath.toUri()); URI remoteUri = _s3StorageBackend.store(outputObject); assertEquals(EXPECTED_URI, remoteUri); assertFalse(Files.exists(filePath)); assertEquals(3, OBJECTS_POSTED.size()); String expectedObject = RESULTS_BUCKET + '/' + EXPECTED_OBJECT_KEY; boolean allCorrectObject = OBJECTS_POSTED.stream() .allMatch(expectedObject::equals); assertTrue(allCorrectObject); }
@Override public URI store(JsonOutputObject outputObject) throws StorageException, IOException { URI localUri = _localStorageBackend.store(outputObject); return putInS3IfAbsent(Paths.get(localUri), outputObject.getJobProperties()::get); }
S3StorageBackend implements StorageBackend { @Override public URI store(JsonOutputObject outputObject) throws StorageException, IOException { URI localUri = _localStorageBackend.store(outputObject); return putInS3IfAbsent(Paths.get(localUri), outputObject.getJobProperties()::get); } }
S3StorageBackend implements StorageBackend { @Override public URI store(JsonOutputObject outputObject) throws StorageException, IOException { URI localUri = _localStorageBackend.store(outputObject); return putInS3IfAbsent(Paths.get(localUri), outputObject.getJobProperties()::get); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); }
S3StorageBackend implements StorageBackend { @Override public URI store(JsonOutputObject outputObject) throws StorageException, IOException { URI localUri = _localStorageBackend.store(outputObject); return putInS3IfAbsent(Paths.get(localUri), outputObject.getJobProperties()::get); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); @Override boolean canStore(JsonOutputObject outputObject); @Override URI store(JsonOutputObject outputObject); @Override boolean canStore(ArtifactExtractionRequest request); @Override Table<Integer, Integer, URI> storeArtifacts(ArtifactExtractionRequest request); @Override boolean canStore(MarkupResult markupResult); @Override void store(MarkupResult markupResult); static void validateS3Properties(Function<String, String> properties); static boolean requiresS3MediaDownload(Function<String, String> properties); static boolean requiresS3ResultUpload(Function<String, String> properties); void downloadFromS3(Media media, Function<String, String> combinedProperties); S3Object getFromS3(String uri, Function<String, String> properties); }
S3StorageBackend implements StorageBackend { @Override public URI store(JsonOutputObject outputObject) throws StorageException, IOException { URI localUri = _localStorageBackend.store(outputObject); return putInS3IfAbsent(Paths.get(localUri), outputObject.getJobProperties()::get); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); @Override boolean canStore(JsonOutputObject outputObject); @Override URI store(JsonOutputObject outputObject); @Override boolean canStore(ArtifactExtractionRequest request); @Override Table<Integer, Integer, URI> storeArtifacts(ArtifactExtractionRequest request); @Override boolean canStore(MarkupResult markupResult); @Override void store(MarkupResult markupResult); static void validateS3Properties(Function<String, String> properties); static boolean requiresS3MediaDownload(Function<String, String> properties); static boolean requiresS3ResultUpload(Function<String, String> properties); void downloadFromS3(Media media, Function<String, String> combinedProperties); S3Object getFromS3(String uri, Function<String, String> properties);  }