use of org.apache.ignite.client.Person in project ignite by apache.
the class RenameIndexTreeTest method findIndexRoots.
/**
* Finding index root pages.
*
* @param cache Cache.
* @param treeName Index tree name.
* @param segments Segment count.
* @return Mapping: segment number -> index root page.
* @throws Exception If failed.
*/
private Map<Integer, RootPage> findIndexRoots(IgniteCache<Integer, Person> cache, String treeName, int segments) throws Exception {
GridCacheContext<Integer, Person> cacheCtx = cacheContext(cache);
Map<Integer, RootPage> rootPages = new HashMap<>();
for (int i = 0; i < segments; i++) {
RootPage rootPage = cacheCtx.offheap().findRootPageForIndex(cacheCtx.cacheId(), treeName, i);
if (rootPage != null)
rootPages.put(i, rootPage);
}
return rootPages;
}
use of org.apache.ignite.client.Person in project ignite by apache.
the class StopNodeOnRebuildIndexFailureTest method startBuildIndexAndThrowExceptionTest.
/**
*/
private void startBuildIndexAndThrowExceptionTest(Supplier<? extends Throwable> throwableSupplier) throws Exception {
errorSupplier = throwableSupplier;
Throwable t = throwableSupplier.get();
if (t instanceof Exception && !(t instanceof RuntimeException || t instanceof IgniteCheckedException))
throw new IllegalArgumentException("Invalid throwable class " + t.getClass());
IgniteEx ignite = startGrid(0);
ignite.cluster().active(true);
assertEquals(1, G.allGrids().size());
ignite.cache(CACHE_NAME).put(0, new Person(0, "name"));
// noinspection ThrowableNotThrown
GridTestUtils.assertThrows(log, () -> ignite.cache(CACHE_NAME).query(new SqlFieldsQuery(CREATE_INDEX_SQL)).getAll(), CacheException.class, null);
assertTrue(exceptionWasThrown.get());
// Node must be stopped by failure handler.
assertTrue(GridTestUtils.waitForCondition(() -> G.allGrids().isEmpty(), 5_000));
}
use of org.apache.ignite.client.Person in project ignite by apache.
the class IndexPagesMetricsPageDisplacementTest method testPageDisplacement.
/**
* Inserts data into the cache as long as it fills enough for some data pages to get dumped to the
* storage. Since index page metrics should reflect the number of in-memory pages, the metric value is expected to
* go down.
*/
@Test
public void testPageDisplacement() throws IgniteCheckedException {
int grpId = grid.cachex(TEST_CACHE_NAME).context().groupId();
DataRegion dataRegion = grid.context().cache().context().database().dataRegion(null);
PageMetrics pageMetrics = dataRegion.metrics().cacheGrpPageMetrics(grpId);
int personId = 0;
long idxPagesOnDisk;
long idxPagesInMemory;
do {
// insert data into the cache until some index pages get displaced to the storage
for (int i = 0; i < 100; i++, personId++) cache.put(personId, new Person(personId, "foobar"));
forceCheckpoint(grid);
idxPagesOnDisk = getIdxPagesOnDisk(grpId).size();
idxPagesInMemory = idxPageCounter.countIdxPagesInMemory(grpId);
assertThat(pageMetrics.indexPages().value(), is(idxPagesInMemory));
} while (idxPagesOnDisk <= idxPagesInMemory);
// load pages back into memory and check that the metric value has increased
touchIdxPages(grpId);
long allIdxPagesInMemory = idxPageCounter.countIdxPagesInMemory(grpId);
assertThat(allIdxPagesInMemory, greaterThan(idxPagesInMemory));
assertThat(pageMetrics.indexPages().value(), is(allIdxPagesInMemory));
}
use of org.apache.ignite.client.Person in project ignite by apache.
the class JavaThinCompatibilityTest method testCacheApi.
/**
*/
private void testCacheApi() throws Exception {
X.println(">>>> Testing cache API");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
ClientCache<Object, Object> cache = client.getOrCreateCache("testCacheApi");
cache.put(1, 1);
assertEquals(1, cache.get(1));
Person person = new Person(2, "name");
cache.put(2, person);
assertEquals(person, cache.get(2));
}
}
use of org.apache.ignite.client.Person in project ignite by apache.
the class ComputeTaskTest method testExecuteWithCustomUserType.
/**
* Test that custom user type can be returned by task.
*/
@Test
public void testExecuteWithCustomUserType() throws Exception {
try (IgniteClient client = startClient(0)) {
Person val = client.compute().execute(TestTaskCustomType.class.getName(), "person");
assertEquals("person", val.getName());
}
}
Aggregations