use of org.apache.ignite.IgniteDataStreamer in project ignite by apache.
the class LazyOnDmlTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
super.beforeTest();
IgniteCache<Long, Long> c = grid(0).createCache(new CacheConfiguration<Long, Long>().setName("test").setSqlSchema("TEST").setAtomicityMode(atomicityMode).setCacheMode(cacheMode).setQueryEntities(Collections.singleton(new QueryEntity(Long.class.getName(), "testVal").setTableName("test").addQueryField("id", Long.class.getName(), null).addQueryField("val0", Long.class.getName(), null).addQueryField("val1", Long.class.getName(), null).addQueryField("val2", Long.class.getName(), null).setKeyFieldName("id").setIndexes(Collections.singletonList(new QueryIndex(Arrays.asList("val0", "val1"), QueryIndexType.SORTED))))).setBackups(1).setAffinity(new RendezvousAffinityFunction(false, 10)));
try (IgniteDataStreamer streamer = grid(0).dataStreamer("test")) {
for (long i = 0; i < KEY_CNT; ++i) {
BinaryObjectBuilder bob = grid(0).binary().builder("testVal");
bob.setField("val0", i);
bob.setField("val1", i);
bob.setField("val2", i);
streamer.addData(i, bob.build());
}
}
sql("CREATE TABLE table1 (id INT PRIMARY KEY, col0 INT, col1 VARCHAR (100))");
sql("INSERT INTO table1 (id, col0, col1) " + "SELECT 1, 11, 'FIRST' " + "UNION ALL " + "SELECT 11,12, 'SECOND' " + "UNION ALL " + "SELECT 21, 13, 'THIRD' " + "UNION ALL " + "SELECT 31, 14, 'FOURTH'");
sql("CREATE TABLE table2 (id INT PRIMARY KEY, col0 INT, col1 VARCHAR (100))");
sql("INSERT INTO table2 (id, col0, col1) " + "SELECT 1, 21, 'TWO-ONE' " + "UNION ALL " + "SELECT 11, 22, 'TWO-TWO' " + "UNION ALL " + "SELECT 21, 23, 'TWO-THREE' " + "UNION ALL " + "SELECT 31, 24, 'TWO-FOUR'");
}
use of org.apache.ignite.IgniteDataStreamer 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