@Test public void initializeRecoverTmpTarFiles() throws Exception { Path fileBucketFolder1 = inputTarStorageFolder.resolve(FILE_BUCKET_1); Path fileBucketFolder2 = inputTarStorageFolder.resolve(FILE_BUCKET_2); Files.createDirectories(fileBucketFolder1); Files.createDirectories(fileBucketFolder2); String tarId1 = createTarId(LocalDateUtil.parseMongoFormattedDate("2019-01-01T01:23:45.678")); String tarId2 = createTarId(LocalDateUtil.parseMongoFormattedDate("2020-02-01T01:23:45.678")); Path tmpFile1 = fileBucketFolder1.resolve(tarId1 + LocalFileUtils.TMP_EXTENSION); Path tmpFile2 = fileBucketFolder2.resolve(tarId2 + LocalFileUtils.TMP_EXTENSION); Files.createFile(tmpFile1); Files.createFile(tmpFile2); TarFileRapairer.DigestWithSize digestWithSize1 = new TarFileRapairer.DigestWithSize(10L, "digest1"); TarFileRapairer.DigestWithSize digestWithSize2 = new TarFileRapairer.DigestWithSize(12L, "digest2"); doReturn(digestWithSize1).when(tarFileRapairer).repairAndVerifyTarArchive(any(), any(), eq(tarId1)); doReturn(digestWithSize2).when(tarFileRapairer).repairAndVerifyTarArchive(any(), any(), eq(tarId2)); writeOrderCreatorBootstrapRecovery.initializeOnBootstrap(); verify(bucketTopologyHelper).listFileBuckets(); verify(tarFileRapairer, times(2)).repairAndVerifyTarArchive(any(), any(), any()); verify(bucketTopologyHelper, times(2)).getBucketFromFileBucket(any()); ArgumentCaptor<WriteOrder> writeOrderArgCaptor = ArgumentCaptor.forClass(WriteOrder.class); verify(writeOrderCreator, times(2)).sendMessageToQueue(writeOrderArgCaptor.capture()); assertThat(writeOrderArgCaptor.getAllValues()).extracting( WriteOrder::getArchiveId, WriteOrder::getBucket, WriteOrder::getDigest, WriteOrder::getSize, WriteOrder::getFilePath) .containsExactly( tuple(tarId1, BUCKED_ID, "digest1", 10L, archiveFileNameRelativeToInputArchiveStorageFolder(FILE_BUCKET_1, tarId1)), tuple(tarId2, BUCKED_ID, "digest2", 12L, archiveFileNameRelativeToInputArchiveStorageFolder(FILE_BUCKET_2, tarId2)) ); Path targetFile1 = fileBucketFolder1.resolve(tarId1); Path targetFile2 = fileBucketFolder2.resolve(tarId2); assertThat(tmpFile1).doesNotExist(); assertThat(tmpFile2).doesNotExist(); assertThat(targetFile1).exists(); assertThat(targetFile2).exists(); verifyNoMoreInteractions(bucketTopologyHelper, archiveReferentialRepository, writeOrderCreator, tarFileRapairer); }
public void initializeOnBootstrap() { try { Path fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(BucketTopologyHelper.BACKUP_FILE_BUCKET); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(BucketTopologyHelper.BACKUP_FILE_BUCKET, fileBucketTarStoragePath); } for (String fileBucket : bucketTopologyHelper.listFileBuckets()) { fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(fileBucket); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(fileBucket, fileBucketTarStoragePath); } } } catch (Exception e) { throw new VitamRuntimeException("Could not reschedule tar files to copy on tape", e); } }
WriteOrderCreatorBootstrapRecovery { public void initializeOnBootstrap() { try { Path fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(BucketTopologyHelper.BACKUP_FILE_BUCKET); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(BucketTopologyHelper.BACKUP_FILE_BUCKET, fileBucketTarStoragePath); } for (String fileBucket : bucketTopologyHelper.listFileBuckets()) { fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(fileBucket); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(fileBucket, fileBucketTarStoragePath); } } } catch (Exception e) { throw new VitamRuntimeException("Could not reschedule tar files to copy on tape", e); } } }
WriteOrderCreatorBootstrapRecovery { public void initializeOnBootstrap() { try { Path fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(BucketTopologyHelper.BACKUP_FILE_BUCKET); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(BucketTopologyHelper.BACKUP_FILE_BUCKET, fileBucketTarStoragePath); } for (String fileBucket : bucketTopologyHelper.listFileBuckets()) { fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(fileBucket); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(fileBucket, fileBucketTarStoragePath); } } } catch (Exception e) { throw new VitamRuntimeException("Could not reschedule tar files to copy on tape", e); } } WriteOrderCreatorBootstrapRecovery(
        String inputTarStorageFolder,
        ArchiveReferentialRepository archiveReferentialRepository,
        BucketTopologyHelper bucketTopologyHelper,
        WriteOrderCreator writeOrderCreator, TarFileRapairer tarFileRapairer); }
WriteOrderCreatorBootstrapRecovery { public void initializeOnBootstrap() { try { Path fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(BucketTopologyHelper.BACKUP_FILE_BUCKET); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(BucketTopologyHelper.BACKUP_FILE_BUCKET, fileBucketTarStoragePath); } for (String fileBucket : bucketTopologyHelper.listFileBuckets()) { fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(fileBucket); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(fileBucket, fileBucketTarStoragePath); } } } catch (Exception e) { throw new VitamRuntimeException("Could not reschedule tar files to copy on tape", e); } } WriteOrderCreatorBootstrapRecovery(
        String inputTarStorageFolder,
        ArchiveReferentialRepository archiveReferentialRepository,
        BucketTopologyHelper bucketTopologyHelper,
        WriteOrderCreator writeOrderCreator, TarFileRapairer tarFileRapairer); void initializeOnBootstrap(); }
WriteOrderCreatorBootstrapRecovery { public void initializeOnBootstrap() { try { Path fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(BucketTopologyHelper.BACKUP_FILE_BUCKET); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(BucketTopologyHelper.BACKUP_FILE_BUCKET, fileBucketTarStoragePath); } for (String fileBucket : bucketTopologyHelper.listFileBuckets()) { fileBucketTarStoragePath = Paths.get(inputTarStorageFolder).resolve(fileBucket); if (fileBucketTarStoragePath.toFile().exists()) { recoverFileBucket(fileBucket, fileBucketTarStoragePath); } } } catch (Exception e) { throw new VitamRuntimeException("Could not reschedule tar files to copy on tape", e); } } WriteOrderCreatorBootstrapRecovery(
        String inputTarStorageFolder,
        ArchiveReferentialRepository archiveReferentialRepository,
        BucketTopologyHelper bucketTopologyHelper,
        WriteOrderCreator writeOrderCreator, TarFileRapairer tarFileRapairer); void initializeOnBootstrap();  }