use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class GridQueryParsingTest method connection.
/**
*/
private JdbcConnection connection() throws Exception {
GridKernalContext ctx = ((IgniteEx) ignite).context();
GridQueryProcessor qryProcessor = ctx.query();
IgniteH2Indexing idx = U.field(qryProcessor, "idx");
String schemaName = idx.schema(DEFAULT_CACHE_NAME);
return (JdbcConnection) idx.connectionForSchema(schemaName);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class GridSpringCacheManagerMultiJvmSelfTest method testSyncCache.
/**
* @throws Exception If failed.
*/
public void testSyncCache() throws Exception {
IgniteEx loc = startGrid(0);
final int threads = 4;
final int entries = 100_000;
final int remoteNum = 2;
final CountDownLatch latch = new CountDownLatch(1);
List<IgniteInternalFuture<Integer>> futures = new ArrayList<>(remoteNum);
for (int i = 0; i < remoteNum; i++) {
final int gridIdx = i + 1;
final IgniteEx remote = startGrid(gridIdx);
IgniteInternalFuture<Integer> calledCntFut = GridTestUtils.runAsync(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
latch.await();
return executeRemotely((IgniteProcessProxy) remote, new TestIgniteCallable<Integer>() {
@Override
public Integer call(Ignite ignite) throws Exception {
BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/ignite/cache/spring/spring-caching" + gridIdx + ".xml");
final GridSpringDynamicCacheTestService dynamicSvc = (GridSpringDynamicCacheTestService) factory.getBean("dynamicTestService");
final CyclicBarrier barrier = new CyclicBarrier(threads);
GridTestUtils.runMultiThreaded(new Callable() {
@Override
public Object call() throws Exception {
for (int i = 0; i < entries; i++) {
barrier.await();
assertEquals("value" + i, dynamicSvc.cacheableSync(i));
assertEquals("value" + i, dynamicSvc.cacheableSync(i));
}
return null;
}
}, threads, "get-sync");
return dynamicSvc.called();
}
});
}
});
futures.add(calledCntFut);
}
latch.countDown();
int totalCalledCnt = 0;
for (IgniteInternalFuture<Integer> future : futures) totalCalledCnt += future.get();
IgniteCache<Object, Object> cache = loc.cache("dynamicCache");
assertEquals(entries, cache.size());
assertEquals(entries, totalCalledCnt);
for (int i = 0; i < entries; i++) assertEquals("value" + i, cache.get(i));
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class CacheDataRegionConfigurationTest method testTooSmallDataRegion.
/**
* Verifies that {@link IgniteOutOfMemoryException} is thrown when cache is configured with too small DataRegion.
*/
public void testTooSmallDataRegion() throws Exception {
memCfg = new DataStorageConfiguration();
DataRegionConfiguration dfltPlcCfg = new DataRegionConfiguration();
dfltPlcCfg.setName("dfltPlc");
dfltPlcCfg.setInitialSize(10 * 1024 * 1024);
dfltPlcCfg.setMaxSize(10 * 1024 * 1024);
DataRegionConfiguration bigPlcCfg = new DataRegionConfiguration();
bigPlcCfg.setName("bigPlc");
bigPlcCfg.setMaxSize(1024 * 1024 * 1024);
memCfg.setDataRegionConfigurations(bigPlcCfg);
memCfg.setDefaultDataRegionConfiguration(dfltPlcCfg);
ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
IgniteEx ignite0 = startGrid(0);
IgniteCache<Object, Object> cache = ignite0.cache(DEFAULT_CACHE_NAME);
boolean oomeThrown = false;
try {
for (int i = 0; i < 500_000; i++) cache.put(i, "abc");
} catch (Exception e) {
Throwable cause = e;
do {
if (cause instanceof IgniteOutOfMemoryException) {
oomeThrown = true;
break;
}
if (cause == null)
break;
if (cause.getSuppressed() == null || cause.getSuppressed().length == 0)
cause = cause.getCause();
else
cause = cause.getSuppressed()[0];
} while (true);
}
if (!oomeThrown)
fail("OutOfMemoryException hasn't been thrown");
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class CacheKeepBinaryTransactionTest method testBinaryContains.
/**
* @throws Exception If failed.
*/
public void testBinaryContains() throws Exception {
IgniteEx ignite = grid(0);
IgniteCache<Object, Object> cache = ignite.cache("tx-cache").withKeepBinary();
try (Transaction tx = ignite.transactions().txStart()) {
BinaryObject key = ignite.binary().builder("test2").setField("id", 1).build();
assertFalse(cache.containsKey(key));
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class ConcurrentCacheStartTest method test.
/**
* @throws Exception If failed.
*/
public void test() throws Exception {
try {
final IgniteEx ignite = (IgniteEx) startGrids(4);
for (int k = 0; k < 100; k++) {
final String cacheName = "cache" + k;
GridTestUtils.runMultiThreaded(new Runnable() {
@Override
public void run() {
try {
ignite.context().cache().dynamicStartCache(new CacheConfiguration().setName(cacheName), cacheName, null, false, false, false).get();
assertNotNull(ignite.context().cache().cache(cacheName));
} catch (IgniteCheckedException ex) {
throw new IgniteException(ex);
}
}
}, 10, "cache-start");
}
} finally {
stopAllGrids();
}
}
Aggregations