use of org.apache.ignite.internal.visor.misc.VisorWalTaskArg in project ignite by apache.
the class GridInternalTaskUnusedWalSegmentsTest method testCorrectnessOfDeletionTaskSegments.
/**
* Tests correctness of {@link VisorWalTaskOperation}.
*
* @throws Exception if failed.
*/
@Test
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
public void testCorrectnessOfDeletionTaskSegments() throws Exception {
try {
IgniteEx ig0 = (IgniteEx) startGrids(4);
ig0.cluster().active(true);
try (IgniteDataStreamer streamer = ig0.dataStreamer(DEFAULT_CACHE_NAME)) {
for (int k = 0; k < 10_000; k++) streamer.addData(k, new byte[1024]);
}
forceCheckpoint();
try (IgniteDataStreamer streamer = ig0.dataStreamer(DEFAULT_CACHE_NAME)) {
for (int k = 0; k < 1_000; k++) streamer.addData(k, new byte[1024]);
}
forceCheckpoint();
VisorWalTaskResult printRes = ig0.compute().execute(VisorWalTask.class, new VisorTaskArgument<>(ig0.cluster().node().id(), new VisorWalTaskArg(VisorWalTaskOperation.PRINT_UNUSED_WAL_SEGMENTS), false));
assertEquals("Check that print task finished without exceptions", printRes.results().size(), 4);
List<File> walArchives = new ArrayList<>();
for (Collection<String> pathsPerNode : printRes.results().values()) {
for (String path : pathsPerNode) walArchives.add(Paths.get(path).toFile());
}
VisorWalTaskResult delRes = ig0.compute().execute(VisorWalTask.class, new VisorTaskArgument<>(ig0.cluster().node().id(), new VisorWalTaskArg(VisorWalTaskOperation.DELETE_UNUSED_WAL_SEGMENTS), false));
assertEquals("Check that delete task finished with no exceptions", delRes.results().size(), 4);
List<File> walDeletedArchives = new ArrayList<>();
for (Collection<String> pathsPerNode : delRes.results().values()) {
for (String path : pathsPerNode) walDeletedArchives.add(Paths.get(path).toFile());
}
for (File f : walDeletedArchives) assertTrue("Checking existing of deleted WAL archived segments: " + f.getAbsolutePath(), !f.exists());
for (File f : walArchives) assertTrue("Checking existing of WAL archived segments from print task after delete: " + f.getAbsolutePath(), !f.exists());
} finally {
stopAllGrids();
}
}
Aggregations