@Test public void initializeOnBootstrapWithInvalidFileStorageId() throws Exception { String storageId1 = this.basicFileStorage.writeFile(UNIT_CONTAINER, FILE_1, new NullInputStream(10), 10); doReturn(singletonList(new TapeObjectReferentialEntity( new TapeLibraryObjectReferentialId(UNIT_CONTAINER, FILE_1), 10, DIGEST_TYPE, "digest", "ANOTHER-STORAGE-ID", null, null, null ))) .when(objectReferentialRepository).bulkFind(UNIT_CONTAINER, ImmutableSet.of(FILE_1)); fileBucketTarCreatorBootstrapRecovery.initializeOnBootstrap( FILE_BUCKET_ID, fileBucketTarCreator, bucketTopologyHelper); verify(objectReferentialRepository).bulkFind(UNIT_CONTAINER, ImmutableSet.of(FILE_1)); verifyNoMoreInteractions(objectReferentialRepository); verifyNoMoreInteractions(fileBucketTarCreator); verify(basicFileStorage).writeFile(any(), any(), any(), anyLong()); verify(basicFileStorage).listStorageIdsByContainerName(UNIT_CONTAINER); verify(basicFileStorage).listStorageIdsByContainerName(OBJECT_GROUP_CONTAINER); verify(basicFileStorage).deleteFile(UNIT_CONTAINER, storageId1); verifyNoMoreInteractions(basicFileStorage); }
public void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator, BucketTopologyHelper bucketTopologyHelper) { Set<String> containerNames = bucketTopologyHelper.listContainerNames(fileBucketId); try { for (String containerName : containerNames) { try (Stream<String> storageIdsStream = this.basicFileStorage .listStorageIdsByContainerName(containerName)) { Iterator<List<String>> bulkIterator = Iterators.partition( storageIdsStream.iterator(), VitamConfiguration.getBatchSize()); while (bulkIterator.hasNext()) { List<String> storageIds = bulkIterator.next(); try { recoverBulkStorageIds(containerName, storageIds, fileBucketTarCreator); } catch (ObjectReferentialException e) { throw new VitamRuntimeException("Could not initialize service to container " + containerName + " files " + storageIds, e); } } } } } catch (IOException e) { throw new VitamRuntimeException( "Could not recover file bucket tar creator on bootstrap for fileBucket " + fileBucketId, e); } }
FileBucketTarCreatorBootstrapRecovery { public void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator, BucketTopologyHelper bucketTopologyHelper) { Set<String> containerNames = bucketTopologyHelper.listContainerNames(fileBucketId); try { for (String containerName : containerNames) { try (Stream<String> storageIdsStream = this.basicFileStorage .listStorageIdsByContainerName(containerName)) { Iterator<List<String>> bulkIterator = Iterators.partition( storageIdsStream.iterator(), VitamConfiguration.getBatchSize()); while (bulkIterator.hasNext()) { List<String> storageIds = bulkIterator.next(); try { recoverBulkStorageIds(containerName, storageIds, fileBucketTarCreator); } catch (ObjectReferentialException e) { throw new VitamRuntimeException("Could not initialize service to container " + containerName + " files " + storageIds, e); } } } } } catch (IOException e) { throw new VitamRuntimeException( "Could not recover file bucket tar creator on bootstrap for fileBucket " + fileBucketId, e); } } }
FileBucketTarCreatorBootstrapRecovery { public void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator, BucketTopologyHelper bucketTopologyHelper) { Set<String> containerNames = bucketTopologyHelper.listContainerNames(fileBucketId); try { for (String containerName : containerNames) { try (Stream<String> storageIdsStream = this.basicFileStorage .listStorageIdsByContainerName(containerName)) { Iterator<List<String>> bulkIterator = Iterators.partition( storageIdsStream.iterator(), VitamConfiguration.getBatchSize()); while (bulkIterator.hasNext()) { List<String> storageIds = bulkIterator.next(); try { recoverBulkStorageIds(containerName, storageIds, fileBucketTarCreator); } catch (ObjectReferentialException e) { throw new VitamRuntimeException("Could not initialize service to container " + containerName + " files " + storageIds, e); } } } } } catch (IOException e) { throw new VitamRuntimeException( "Could not recover file bucket tar creator on bootstrap for fileBucket " + fileBucketId, e); } } FileBucketTarCreatorBootstrapRecovery(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository); }
FileBucketTarCreatorBootstrapRecovery { public void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator, BucketTopologyHelper bucketTopologyHelper) { Set<String> containerNames = bucketTopologyHelper.listContainerNames(fileBucketId); try { for (String containerName : containerNames) { try (Stream<String> storageIdsStream = this.basicFileStorage .listStorageIdsByContainerName(containerName)) { Iterator<List<String>> bulkIterator = Iterators.partition( storageIdsStream.iterator(), VitamConfiguration.getBatchSize()); while (bulkIterator.hasNext()) { List<String> storageIds = bulkIterator.next(); try { recoverBulkStorageIds(containerName, storageIds, fileBucketTarCreator); } catch (ObjectReferentialException e) { throw new VitamRuntimeException("Could not initialize service to container " + containerName + " files " + storageIds, e); } } } } } catch (IOException e) { throw new VitamRuntimeException( "Could not recover file bucket tar creator on bootstrap for fileBucket " + fileBucketId, e); } } FileBucketTarCreatorBootstrapRecovery(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository); void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator,
        BucketTopologyHelper bucketTopologyHelper); }
FileBucketTarCreatorBootstrapRecovery { public void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator, BucketTopologyHelper bucketTopologyHelper) { Set<String> containerNames = bucketTopologyHelper.listContainerNames(fileBucketId); try { for (String containerName : containerNames) { try (Stream<String> storageIdsStream = this.basicFileStorage .listStorageIdsByContainerName(containerName)) { Iterator<List<String>> bulkIterator = Iterators.partition( storageIdsStream.iterator(), VitamConfiguration.getBatchSize()); while (bulkIterator.hasNext()) { List<String> storageIds = bulkIterator.next(); try { recoverBulkStorageIds(containerName, storageIds, fileBucketTarCreator); } catch (ObjectReferentialException e) { throw new VitamRuntimeException("Could not initialize service to container " + containerName + " files " + storageIds, e); } } } } } catch (IOException e) { throw new VitamRuntimeException( "Could not recover file bucket tar creator on bootstrap for fileBucket " + fileBucketId, e); } } FileBucketTarCreatorBootstrapRecovery(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository); void initializeOnBootstrap(String fileBucketId, FileBucketTarCreator fileBucketTarCreator,
        BucketTopologyHelper bucketTopologyHelper);  }