use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VersionTableVacuumTaskTest method delete_node_deletes_versions.
@Test
void delete_node_deletes_versions() {
final int updates = 10_000;
// to make sure nodes fetched in batches
final int versionsBatchSize = updates / 2;
final int expectedVersionCount = updates + 1;
final Node node1 = createNode(NodePath.ROOT, "node1");
updateNode(node1.id(), updates);
doDeleteNode(node1.id());
assertVersions(node1.id(), expectedVersionCount);
final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(NEGATIVE_AGE_THRESHOLD_MILLIS).versionsBatchSize(versionsBatchSize).build()));
refresh();
assertEquals(updates + 12, result.getProcessed());
// Old version of CMS repository entry is also delete. Remove +1 when config to specify repository is implemented
assertEquals(expectedVersionCount + 1, result.getDeleted());
assertVersions(node1.id(), 0);
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VersionTableVacuumTaskTest method version_not_deleted_in_all_branches.
@Test
void version_not_deleted_in_all_branches() {
final Node node1 = createNode(NodePath.ROOT, "node1");
pushNodes(NodeIds.from(node1.id()), WS_OTHER);
refresh();
this.nodeService.deleteById(node1.id());
refresh();
assertVersions(node1.id(), 1);
final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(NEGATIVE_AGE_THRESHOLD_MILLIS).build()));
refresh();
assertEquals(12, result.getProcessed());
// Old version of CMS repository entry is also delete. Set to 0 when config to specify repository is implemented
assertEquals(1, result.getDeleted());
assertVersions(node1.id(), 1);
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VersionTableVacuumTaskTest method version_deleted_in_all_branches.
@Test
void version_deleted_in_all_branches() {
final Node node1 = createNode(NodePath.ROOT, "node1");
pushNodes(NodeIds.from(node1.id()), WS_OTHER);
refresh();
this.nodeService.deleteById(node1.id());
ctxOther().runWith(() -> this.nodeService.deleteById(node1.id()));
refresh();
assertVersions(node1.id(), 1);
final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(NEGATIVE_AGE_THRESHOLD_MILLIS).build()));
refresh();
assertEquals(12, result.getProcessed());
// Old version of CMS repository entry is also delete. Set to 1 when config to specify repository is implemented
assertEquals(2, result.getDeleted());
assertVersions(node1.id(), 0);
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VersionTableVacuumTaskTest method age_threshold.
@Test
void age_threshold() {
final Node node1 = createNode(NodePath.ROOT, "node1");
updateNode(node1.id(), 2);
doDeleteNode(node1.id());
refresh();
assertVersions(node1.id(), 3);
final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(Duration.of(1, ChronoUnit.HOURS).toMillis()).build()));
refresh();
assertEquals(0, result.getProcessed());
assertEquals(0, result.getDeleted());
assertVersions(node1.id(), 3);
}
use of com.enonic.xp.vacuum.VacuumTaskResult in project xp by enonic.
the class VacuumServiceImpl method doVacuum.
private VacuumResult doVacuum(final VacuumParameters params) {
// Retrieves the tasks to execute
VacuumTasks tasks = getTasks(params);
LOG.info("Starting vacuum. Running " + tasks.size() + " tasks...");
if (params.getVacuumListener() != null) {
params.getVacuumListener().vacuumBegin(tasks.size());
}
final VacuumResult.Builder taskResults = VacuumResult.create();
for (final VacuumTask task : tasks) {
LOG.info("Running vacuum task [" + task.name() + "]...");
final VacuumTaskParams taskParams = VacuumTaskParams.create().listener(params.getVacuumListener()).ageThreshold(getAgeThresholdMs(params)).versionsBatchSize(config.versionsBatchSize()).build();
final VacuumTaskResult taskResult = task.execute(taskParams);
LOG.info(task.name() + " : " + taskResult.toString());
taskResults.add(taskResult);
LOG.info("Vacuum task [" + task.name() + "] done");
}
LOG.info("Vacuum done");
return taskResults.build();
}
Aggregations