Search in sources :

Example 1 with VacuumTask

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

Example 2 with VacuumTask

use of com.enonic.xp.repo.impl.vacuum.VacuumTask 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)

Example 3 with VacuumTask

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

Aggregations

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