Search in sources :

Example 46 with IgniteEx

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);
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) JdbcConnection(org.h2.jdbc.JdbcConnection) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)

Example 47 with IgniteEx

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));
}
Also used : ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Callable(java.util.concurrent.Callable) CyclicBarrier(java.util.concurrent.CyclicBarrier) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) IgniteEx(org.apache.ignite.internal.IgniteEx) BeanFactory(org.springframework.beans.factory.BeanFactory) Ignite(org.apache.ignite.Ignite) IgniteProcessProxy(org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy)

Example 48 with IgniteEx

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");
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException)

Example 49 with IgniteEx

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));
    }
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryObject(org.apache.ignite.binary.BinaryObject)

Example 50 with IgniteEx

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();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

IgniteEx (org.apache.ignite.internal.IgniteEx)396 Ignite (org.apache.ignite.Ignite)85 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)64 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)60 IgniteException (org.apache.ignite.IgniteException)46 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)37 Transaction (org.apache.ignite.transactions.Transaction)34 ArrayList (java.util.ArrayList)31 HashMap (java.util.HashMap)31 CountDownLatch (java.util.concurrent.CountDownLatch)28 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)27 IgniteCache (org.apache.ignite.IgniteCache)25 Map (java.util.Map)24 ClusterNode (org.apache.ignite.cluster.ClusterNode)20 CacheException (javax.cache.CacheException)19 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)19 UUID (java.util.UUID)18 Callable (java.util.concurrent.Callable)17 List (java.util.List)16 Random (java.util.Random)16