@Test @RunWithCustomExecutor public void synchronizeEmptyOffer() throws Exception { OfferSyncProcess instance = new OfferSyncProcess(restoreOfferBackupService, distribution, 10, 1, 1, 1); instance .synchronize(executorService, SOURCE, TARGET, VitamConfiguration.getDefaultStrategy(), DATA_CATEGORY, null); assertThat(targetDataFiles).isEqualTo(sourceDataFiles); verifySynchronizationStatus(instance, null, null); verify(distribution, never()).storeDataInOffers(anyString(), anyString(), any(), any(), any(), any()); verify(distribution, never()).deleteObjectInOffers(any(), any(), any()); }
public void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId, DataCategory dataCategory, Long startOffset) { this.offerSyncStatus = new OfferSyncStatus( VitamThreadUtils.getVitamSession().getRequestId(), StatusCode.UNKNOWN, getCurrentDate(), null, sourceOffer, targetOffer, dataCategory.getCollectionName(), startOffset, null); try { LOGGER.info(String.format( "Start the synchronization process of the target offer {%s} from the source offer {%s} for category {%s}.", targetOffer, sourceOffer, dataCategory)); Long offset = startOffset; while (true) { List<OfferLog> rawOfferLogs = restoreOfferBackupService.getListing( strategyId, sourceOffer, dataCategory, offset, bulkSize, Order.ASC); if (rawOfferLogs.isEmpty()) { break; } long lastSequence = synchronizeOfferLogs(executor, sourceOffer, targetOffer, strategyId, dataCategory, rawOfferLogs, offset); this.offerSyncStatus.setCurrentOffset(lastSequence); offset = lastSequence + 1; LOGGER .info(String.format("Offer synchronization safe point offset : %s (from %s to %s for category %s)", offset, sourceOffer, targetOffer, dataCategory)); if (rawOfferLogs.size() < bulkSize) { break; } } LOGGER.info(String.format("The offers synchronization completed successfully. from %d to %d", startOffset, offset)); this.offerSyncStatus.setStatusCode(StatusCode.OK); } catch (Exception e) { this.offerSyncStatus.setStatusCode(StatusCode.KO); LOGGER.error(String.format( "[OfferSync]: An exception has been thrown when synchronizing {%s} offer from {%s} source offer with {%s} offset.", targetOffer, sourceOffer, startOffset), e); } finally { this.offerSyncStatus.setEndDate(getCurrentDate()); } }
OfferSyncProcess { public void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId, DataCategory dataCategory, Long startOffset) { this.offerSyncStatus = new OfferSyncStatus( VitamThreadUtils.getVitamSession().getRequestId(), StatusCode.UNKNOWN, getCurrentDate(), null, sourceOffer, targetOffer, dataCategory.getCollectionName(), startOffset, null); try { LOGGER.info(String.format( "Start the synchronization process of the target offer {%s} from the source offer {%s} for category {%s}.", targetOffer, sourceOffer, dataCategory)); Long offset = startOffset; while (true) { List<OfferLog> rawOfferLogs = restoreOfferBackupService.getListing( strategyId, sourceOffer, dataCategory, offset, bulkSize, Order.ASC); if (rawOfferLogs.isEmpty()) { break; } long lastSequence = synchronizeOfferLogs(executor, sourceOffer, targetOffer, strategyId, dataCategory, rawOfferLogs, offset); this.offerSyncStatus.setCurrentOffset(lastSequence); offset = lastSequence + 1; LOGGER .info(String.format("Offer synchronization safe point offset : %s (from %s to %s for category %s)", offset, sourceOffer, targetOffer, dataCategory)); if (rawOfferLogs.size() < bulkSize) { break; } } LOGGER.info(String.format("The offers synchronization completed successfully. from %d to %d", startOffset, offset)); this.offerSyncStatus.setStatusCode(StatusCode.OK); } catch (Exception e) { this.offerSyncStatus.setStatusCode(StatusCode.KO); LOGGER.error(String.format( "[OfferSync]: An exception has been thrown when synchronizing {%s} offer from {%s} source offer with {%s} offset.", targetOffer, sourceOffer, startOffset), e); } finally { this.offerSyncStatus.setEndDate(getCurrentDate()); } } }
OfferSyncProcess { public void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId, DataCategory dataCategory, Long startOffset) { this.offerSyncStatus = new OfferSyncStatus( VitamThreadUtils.getVitamSession().getRequestId(), StatusCode.UNKNOWN, getCurrentDate(), null, sourceOffer, targetOffer, dataCategory.getCollectionName(), startOffset, null); try { LOGGER.info(String.format( "Start the synchronization process of the target offer {%s} from the source offer {%s} for category {%s}.", targetOffer, sourceOffer, dataCategory)); Long offset = startOffset; while (true) { List<OfferLog> rawOfferLogs = restoreOfferBackupService.getListing( strategyId, sourceOffer, dataCategory, offset, bulkSize, Order.ASC); if (rawOfferLogs.isEmpty()) { break; } long lastSequence = synchronizeOfferLogs(executor, sourceOffer, targetOffer, strategyId, dataCategory, rawOfferLogs, offset); this.offerSyncStatus.setCurrentOffset(lastSequence); offset = lastSequence + 1; LOGGER .info(String.format("Offer synchronization safe point offset : %s (from %s to %s for category %s)", offset, sourceOffer, targetOffer, dataCategory)); if (rawOfferLogs.size() < bulkSize) { break; } } LOGGER.info(String.format("The offers synchronization completed successfully. from %d to %d", startOffset, offset)); this.offerSyncStatus.setStatusCode(StatusCode.OK); } catch (Exception e) { this.offerSyncStatus.setStatusCode(StatusCode.KO); LOGGER.error(String.format( "[OfferSync]: An exception has been thrown when synchronizing {%s} offer from {%s} source offer with {%s} offset.", targetOffer, sourceOffer, startOffset), e); } finally { this.offerSyncStatus.setEndDate(getCurrentDate()); } } OfferSyncProcess(RestoreOfferBackupService restoreOfferBackupService, StorageDistribution distribution,
        int bulkSize, int offerSyncNumberOfRetries, int offerSyncFirstAttemptWaitingTime,
        int offerSyncWaitingTime); }
OfferSyncProcess { public void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId, DataCategory dataCategory, Long startOffset) { this.offerSyncStatus = new OfferSyncStatus( VitamThreadUtils.getVitamSession().getRequestId(), StatusCode.UNKNOWN, getCurrentDate(), null, sourceOffer, targetOffer, dataCategory.getCollectionName(), startOffset, null); try { LOGGER.info(String.format( "Start the synchronization process of the target offer {%s} from the source offer {%s} for category {%s}.", targetOffer, sourceOffer, dataCategory)); Long offset = startOffset; while (true) { List<OfferLog> rawOfferLogs = restoreOfferBackupService.getListing( strategyId, sourceOffer, dataCategory, offset, bulkSize, Order.ASC); if (rawOfferLogs.isEmpty()) { break; } long lastSequence = synchronizeOfferLogs(executor, sourceOffer, targetOffer, strategyId, dataCategory, rawOfferLogs, offset); this.offerSyncStatus.setCurrentOffset(lastSequence); offset = lastSequence + 1; LOGGER .info(String.format("Offer synchronization safe point offset : %s (from %s to %s for category %s)", offset, sourceOffer, targetOffer, dataCategory)); if (rawOfferLogs.size() < bulkSize) { break; } } LOGGER.info(String.format("The offers synchronization completed successfully. from %d to %d", startOffset, offset)); this.offerSyncStatus.setStatusCode(StatusCode.OK); } catch (Exception e) { this.offerSyncStatus.setStatusCode(StatusCode.KO); LOGGER.error(String.format( "[OfferSync]: An exception has been thrown when synchronizing {%s} offer from {%s} source offer with {%s} offset.", targetOffer, sourceOffer, startOffset), e); } finally { this.offerSyncStatus.setEndDate(getCurrentDate()); } } OfferSyncProcess(RestoreOfferBackupService restoreOfferBackupService, StorageDistribution distribution,
        int bulkSize, int offerSyncNumberOfRetries, int offerSyncFirstAttemptWaitingTime,
        int offerSyncWaitingTime); void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId,
        DataCategory dataCategory, Long startOffset); boolean isRunning(); OfferSyncStatus getOfferSyncStatus(); void synchronize(Executor executor, String sourceOffer, String targetOffer, String strategyId,
        List<OfferPartialSyncItem> items); }
OfferSyncProcess { public void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId, DataCategory dataCategory, Long startOffset) { this.offerSyncStatus = new OfferSyncStatus( VitamThreadUtils.getVitamSession().getRequestId(), StatusCode.UNKNOWN, getCurrentDate(), null, sourceOffer, targetOffer, dataCategory.getCollectionName(), startOffset, null); try { LOGGER.info(String.format( "Start the synchronization process of the target offer {%s} from the source offer {%s} for category {%s}.", targetOffer, sourceOffer, dataCategory)); Long offset = startOffset; while (true) { List<OfferLog> rawOfferLogs = restoreOfferBackupService.getListing( strategyId, sourceOffer, dataCategory, offset, bulkSize, Order.ASC); if (rawOfferLogs.isEmpty()) { break; } long lastSequence = synchronizeOfferLogs(executor, sourceOffer, targetOffer, strategyId, dataCategory, rawOfferLogs, offset); this.offerSyncStatus.setCurrentOffset(lastSequence); offset = lastSequence + 1; LOGGER .info(String.format("Offer synchronization safe point offset : %s (from %s to %s for category %s)", offset, sourceOffer, targetOffer, dataCategory)); if (rawOfferLogs.size() < bulkSize) { break; } } LOGGER.info(String.format("The offers synchronization completed successfully. from %d to %d", startOffset, offset)); this.offerSyncStatus.setStatusCode(StatusCode.OK); } catch (Exception e) { this.offerSyncStatus.setStatusCode(StatusCode.KO); LOGGER.error(String.format( "[OfferSync]: An exception has been thrown when synchronizing {%s} offer from {%s} source offer with {%s} offset.", targetOffer, sourceOffer, startOffset), e); } finally { this.offerSyncStatus.setEndDate(getCurrentDate()); } } OfferSyncProcess(RestoreOfferBackupService restoreOfferBackupService, StorageDistribution distribution,
        int bulkSize, int offerSyncNumberOfRetries, int offerSyncFirstAttemptWaitingTime,
        int offerSyncWaitingTime); void synchronize(ExecutorService executor, String sourceOffer, String targetOffer, String strategyId,
        DataCategory dataCategory, Long startOffset); boolean isRunning(); OfferSyncStatus getOfferSyncStatus(); void synchronize(Executor executor, String sourceOffer, String targetOffer, String strategyId,
        List<OfferPartialSyncItem> items);  }