Search in sources :

Example 1 with VacuumListener

use of com.enonic.xp.vacuum.VacuumListener 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());
}
Also used : VacuumTaskResult(com.enonic.xp.vacuum.VacuumTaskResult) VacuumListener(com.enonic.xp.vacuum.VacuumListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VacuumTask(com.enonic.xp.repo.impl.vacuum.VacuumTask)

Aggregations

VacuumTask (com.enonic.xp.repo.impl.vacuum.VacuumTask)1 VacuumListener (com.enonic.xp.vacuum.VacuumListener)1 VacuumTaskResult (com.enonic.xp.vacuum.VacuumTaskResult)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1