use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VacuumServiceImplTest method runTasks.
@Test
public void runTasks() throws Exception {
final VacuumServiceImpl service = new VacuumServiceImpl();
service.activate(mock(VacuumConfig.class, i -> i.getMethod().getDefaultValue()));
service.addTask(new VacuumTask() {
@Override
public VacuumTaskResult execute(final VacuumTaskParams params) {
return VacuumTaskResult.create().processed().build();
}
@Override
public int order() {
return 10;
}
@Override
public String name() {
return "ATask";
}
});
service.addTask(new VacuumTask() {
@Override
public VacuumTaskResult execute(final VacuumTaskParams params) {
return VacuumTaskResult.create().failed().build();
}
@Override
public int order() {
return 0;
}
@Override
public String name() {
return "AnotherTask";
}
});
final VacuumResult result = NodeHelper.runAsAdmin(() -> service.vacuum(VacuumParameters.create().build()));
assertEquals(2, result.getResults().size());
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class AbstractBlobVacuumTaskTest method age_threshold.
public void age_threshold() throws Exception {
this.blobStore.addRecord(segment, createBlobRecord('a'));
final VacuumTask task = createTask();
final VacuumTaskResult result = task.execute(VacuumTaskParams.create().build());
assertEquals(0, result.getProcessed());
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class SegmentVacuumTaskTest method test.
@Test
public void test() {
final BlobRecord record = blobStore.addRecord(segment, ByteSource.wrap("hello".getBytes()));
final BlobRecord record2 = blobStore.addRecord(segment2, ByteSource.wrap("hello".getBytes()));
assertEquals(2, blobStore.listSegments().count());
blobStore.removeRecord(segment, record2.getKey());
assertEquals(2, blobStore.listSegments().count());
final SegmentVacuumTask task = new SegmentVacuumTask();
task.setBlobStore(blobStore);
task.setRepositoryService(repositoryService);
task.setNodeService(nodeService);
final VacuumTaskParams vacuumParameters = VacuumTaskParams.create().build();
final VacuumTaskResult result = task.execute(vacuumParameters);
assertEquals(2, result.getProcessed());
assertEquals(1, result.getDeleted());
assertEquals(1, result.getInUse());
assertEquals(1, blobStore.listSegments().count());
assertEquals(segment, blobStore.listSegments().findFirst().get());
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class AbstractBlobVacuumTaskTest method test_progress_report.
public void test_progress_report() throws Exception {
this.blobStore.addRecord(segment, createBlobRecord('a'));
this.blobStore.addRecord(segment, createBlobRecord('b'));
this.blobStore.addRecord(segment, createBlobRecord('c'));
final VacuumTask task = createTask();
AtomicInteger blobReportCount = new AtomicInteger(0);
final VacuumListener progressListener = new VacuumListener() {
@Override
public void vacuumBegin(final long taskCount) {
}
@Override
public void taskBegin(final String task, final Long stepCount) {
}
@Override
public void stepBegin(final String stepName, final Long toProcessCount) {
}
@Override
public void processed(final long count) {
blobReportCount.incrementAndGet();
}
};
final VacuumTaskResult result = task.execute(VacuumTaskParams.create().ageThreshold(0).listener(progressListener).build());
assertEquals(3, result.getProcessed());
assertEquals(2, result.getDeleted());
assertEquals(1, result.getInUse());
assertEquals(3, blobReportCount.get());
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class AbstractBlobVacuumTaskTest method test_delete_unused.
public void test_delete_unused() throws Exception {
this.blobStore.addRecord(segment, createBlobRecord('a'));
this.blobStore.addRecord(segment, createBlobRecord('b'));
this.blobStore.addRecord(segment, createBlobRecord('c'));
final VacuumTask task = createTask();
final VacuumTaskResult result = task.execute(VacuumTaskParams.create().ageThreshold(0).build());
assertEquals(3, result.getProcessed());
assertEquals(2, result.getDeleted());
assertEquals(1, result.getInUse());
}
Aggregations