@Test public void batchSuccessCompletesDeletion() throws Exception { when(deleteProgress.isFailed()).thenReturn(false); DeletionProgress deleteComponentsProgress = underTest.deleteComponents(entityIds, () -> false, 1); assertThat(deleteComponentsProgress.isFailed(), is(false)); verify(deleteProgress, times(2)).getCount(); }
@Override public DeletionProgress deleteComponents(final Iterable<EntityId> components, final BooleanSupplier cancelledCheck, final int batchSize) { checkNotNull(components); checkNotNull(cancelledCheck); UnitOfWork.beginBatch(getRepository().facet(StorageFacet.class).txSupplier()); DeletionProgress deletionProgress = new DeletionProgress(); try { Iterable<List<EntityId>> split = partition(components, batchSize); for (List<EntityId> entityIds : split) { if (cancelledCheck.getAsBoolean()) { break; } DeletionProgress batchDeletion = doBatchDelete(entityIds, cancelledCheck); deletionProgress.addCount(batchDeletion.getCount()); if (batchDeletion.isFailed()) { deletionProgress.setFailed(true); break; } } } finally { UnitOfWork.end(); } tryAfter(); return deletionProgress; }
DefaultComponentMaintenanceImpl extends FacetSupport implements ComponentMaintenance { @Override public DeletionProgress deleteComponents(final Iterable<EntityId> components, final BooleanSupplier cancelledCheck, final int batchSize) { checkNotNull(components); checkNotNull(cancelledCheck); UnitOfWork.beginBatch(getRepository().facet(StorageFacet.class).txSupplier()); DeletionProgress deletionProgress = new DeletionProgress(); try { Iterable<List<EntityId>> split = partition(components, batchSize); for (List<EntityId> entityIds : split) { if (cancelledCheck.getAsBoolean()) { break; } DeletionProgress batchDeletion = doBatchDelete(entityIds, cancelledCheck); deletionProgress.addCount(batchDeletion.getCount()); if (batchDeletion.isFailed()) { deletionProgress.setFailed(true); break; } } } finally { UnitOfWork.end(); } tryAfter(); return deletionProgress; } }
DefaultComponentMaintenanceImpl extends FacetSupport implements ComponentMaintenance { @Override public DeletionProgress deleteComponents(final Iterable<EntityId> components, final BooleanSupplier cancelledCheck, final int batchSize) { checkNotNull(components); checkNotNull(cancelledCheck); UnitOfWork.beginBatch(getRepository().facet(StorageFacet.class).txSupplier()); DeletionProgress deletionProgress = new DeletionProgress(); try { Iterable<List<EntityId>> split = partition(components, batchSize); for (List<EntityId> entityIds : split) { if (cancelledCheck.getAsBoolean()) { break; } DeletionProgress batchDeletion = doBatchDelete(entityIds, cancelledCheck); deletionProgress.addCount(batchDeletion.getCount()); if (batchDeletion.isFailed()) { deletionProgress.setFailed(true); break; } } } finally { UnitOfWork.end(); } tryAfter(); return deletionProgress; }  }
DefaultComponentMaintenanceImpl extends FacetSupport implements ComponentMaintenance { @Override public DeletionProgress deleteComponents(final Iterable<EntityId> components, final BooleanSupplier cancelledCheck, final int batchSize) { checkNotNull(components); checkNotNull(cancelledCheck); UnitOfWork.beginBatch(getRepository().facet(StorageFacet.class).txSupplier()); DeletionProgress deletionProgress = new DeletionProgress(); try { Iterable<List<EntityId>> split = partition(components, batchSize); for (List<EntityId> entityIds : split) { if (cancelledCheck.getAsBoolean()) { break; } DeletionProgress batchDeletion = doBatchDelete(entityIds, cancelledCheck); deletionProgress.addCount(batchDeletion.getCount()); if (batchDeletion.isFailed()) { deletionProgress.setFailed(true); break; } } } finally { UnitOfWork.end(); } tryAfter(); return deletionProgress; }  @Override Set<String> deleteComponent(final EntityId componentId); @Override Set<String> deleteComponent(final EntityId componentId, final boolean deleteBlobs); @Override @Guarded(by = STARTED) Set<String> deleteAsset(final EntityId assetId); @Override @Guarded(by = STARTED) Set<String> deleteAsset(final EntityId assetId, final boolean deleteBlob); @Override DeletionProgress deleteComponents(final Iterable<EntityId> components,
                                           final BooleanSupplier cancelledCheck,
                                           final int batchSize); @Override void after(); }
DefaultComponentMaintenanceImpl extends FacetSupport implements ComponentMaintenance { @Override public DeletionProgress deleteComponents(final Iterable<EntityId> components, final BooleanSupplier cancelledCheck, final int batchSize) { checkNotNull(components); checkNotNull(cancelledCheck); UnitOfWork.beginBatch(getRepository().facet(StorageFacet.class).txSupplier()); DeletionProgress deletionProgress = new DeletionProgress(); try { Iterable<List<EntityId>> split = partition(components, batchSize); for (List<EntityId> entityIds : split) { if (cancelledCheck.getAsBoolean()) { break; } DeletionProgress batchDeletion = doBatchDelete(entityIds, cancelledCheck); deletionProgress.addCount(batchDeletion.getCount()); if (batchDeletion.isFailed()) { deletionProgress.setFailed(true); break; } } } finally { UnitOfWork.end(); } tryAfter(); return deletionProgress; }  @Override Set<String> deleteComponent(final EntityId componentId); @Override Set<String> deleteComponent(final EntityId componentId, final boolean deleteBlobs); @Override @Guarded(by = STARTED) Set<String> deleteAsset(final EntityId assetId); @Override @Guarded(by = STARTED) Set<String> deleteAsset(final EntityId assetId, final boolean deleteBlob); @Override DeletionProgress deleteComponents(final Iterable<EntityId> components,
                                           final BooleanSupplier cancelledCheck,
                                           final int batchSize); @Override void after();  }