Search in sources :

Example 86 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class MemoryPolicyInitializationTest method testCustomConfigNoDefault.

/**
 * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
 * with non-default custom MemoryPolicy.
 */
public void testCustomConfigNoDefault() throws Exception {
    prepareCustomNoDefaultConfig();
    IgniteEx ignite = startGrid(0);
    Collection<DataRegion> allMemPlcs = ignite.context().cache().context().database().dataRegions();
    assertTrue(allMemPlcs.size() == 3);
    verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
    assertTrue("Custom non-default memory policy is not presented", isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

Example 87 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class IgnitePdsPageEvictionDuringPartitionClearTest method testPageEvictionOnNodeStart.

/**
 * @throws Exception if failed.
 */
public void testPageEvictionOnNodeStart() throws Exception {
    for (int r = 0; r < 3; r++) {
        cleanPersistenceDir();
        startGrids(2);
        try {
            Ignite ig = ignite(0);
            ig.active(true);
            IgniteDataStreamer<Object, Object> streamer = ig.dataStreamer(CACHE_NAME);
            for (int i = 0; i < 300_000; i++) {
                streamer.addData(i, new TestValue(i));
                if (i > 0 && i % 10_000 == 0)
                    info("Done: " + i);
            }
            streamer.flush();
            IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {

                @Override
                public Object call() throws Exception {
                    IgniteEx ig = startGrid(2);
                    info(">>>>>>>>>>>");
                    info(">>>>>>>>>>>");
                    info(">>>>>>>>>>>");
                    return ig;
                }
            });
            for (int i = 500_000; i < 1_000_000; i++) {
                streamer.addData(i, new TestValue(i));
                if (i > 0 && i % 10_000 == 0) {
                    info("Done: " + i);
                    U.sleep(1000);
                }
            }
            streamer.close();
            fut.get();
        } finally {
            stopAllGrids();
            cleanPersistenceDir();
        }
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite)

Example 88 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class IgnitePdsPageEvictionTest method testPageEvictionSql.

/**
 * @throws Exception if failed.
 */
public void testPageEvictionSql() throws Exception {
    IgniteEx ig = grid(0);
    ig.active(true);
    try (IgniteDataStreamer<DbKey, DbValue> streamer = ig.dataStreamer(CACHE_NAME)) {
        for (int i = 0; i < ENTRY_CNT; i++) {
            streamer.addData(new DbKey(i), new DbValue(i, "value-" + i, Long.MAX_VALUE - i));
            if (i > 0 && i % 10_000 == 0)
                info("Done put: " + i);
        }
    }
    IgniteCache<DbKey, DbValue> cache = ignite(0).cache(CACHE_NAME);
    for (int i = 0; i < ENTRY_CNT; i++) {
        assertEquals(Long.MAX_VALUE - i, cache.get(new DbKey(i)).lVal);
        if (i > 0 && i % 10_000 == 0)
            info("Done get: " + i);
    }
    for (int i = 0; i < ENTRY_CNT; i++) {
        List<List<?>> rows = cache.query(new SqlFieldsQuery("select lVal from DbValue where iVal=?").setArgs(i)).getAll();
        assertEquals(1, rows.size());
        assertEquals(Long.MAX_VALUE - i, rows.get(0).get(0));
        if (i > 0 && i % 10_000 == 0)
            info("Done SQL query: " + i);
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Example 89 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class IgniteMassLoadSandboxTest method testPutRemoveMultithreaded.

/**
 * Runs multithreaded put-remove scenario (no data streamer). Load is generated to WAL log mostly.
 * Most of entries generated will be removed before first checkpoint.
 *
 * @throws Exception if failed.
 */
public void testPutRemoveMultithreaded() throws Exception {
    setWalArchAndWorkToSameVal = false;
    customWalMode = WALMode.LOG_ONLY;
    try {
        final IgniteEx ignite = startGrid(1);
        ignite.active(true);
        checkpointFrequency = 20 * 1000;
        final IgniteCache<Object, HugeIndexedObject> cache = ignite.cache(CACHE_NAME);
        int totalRecs = 400_000;
        final int threads = 10;
        final int recsPerThread = totalRecs / threads;
        final Collection<Callable<?>> tasks = new ArrayList<>();
        final ProgressWatchdog watchdog = new ProgressWatchdog(ignite, "put", PUT_THREAD);
        for (int j = 0; j < threads; j++) {
            final int finalJ = j;
            tasks.add(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    final Collection<Integer> toRmvLaterList = new ArrayList<>();
                    for (int id = finalJ * recsPerThread; id < ((finalJ + 1) * recsPerThread); id++) {
                        HugeIndexedObject v = new HugeIndexedObject(id);
                        cache.put(id, v);
                        toRmvLaterList.add(id);
                        watchdog.reportProgress(1);
                        if (toRmvLaterList.size() > 100) {
                            for (Integer toRemoveId : toRmvLaterList) {
                                if (keepInDb(toRemoveId))
                                    continue;
                                boolean rmv = cache.remove(toRemoveId);
                                assert rmv : "Expected to remove object from cache " + toRemoveId;
                            }
                            toRmvLaterList.clear();
                        }
                    }
                    return null;
                }
            });
        }
        watchdog.start();
        GridTestUtils.runMultiThreaded(tasks, PUT_THREAD);
        watchdog.stop();
        stopGrid(1);
        final Ignite restartedIgnite = startGrid(1);
        restartedIgnite.active(true);
        final IgniteCache<Object, HugeIndexedObject> restartedCache = restartedIgnite.cache(CACHE_NAME);
        for (int i = 0; i < recsPerThread * threads; i++) {
            if (keepInDb(i)) {
                final HugeIndexedObject obj = restartedCache.get(i);
                TestCase.assertNotNull(obj);
                TestCase.assertEquals(i, obj.iVal);
            }
            if (i % 1000 == 0)
                X.print(" V: " + i);
        }
    } finally {
        stopAllGrids();
    }
}
Also used : ArrayList(java.util.ArrayList) Callable(java.util.concurrent.Callable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) Collection(java.util.Collection) Ignite(org.apache.ignite.Ignite)

Example 90 with IgniteEx

use of org.apache.ignite.internal.IgniteEx in project ignite by apache.

the class IgnitePdsCacheIntegrationTest method testPutGetSimple.

/**
 * @throws Exception if failed.
 */
public void testPutGetSimple() throws Exception {
    startGrids(GRID_CNT);
    try {
        IgniteEx ig = grid(0);
        ig.active(true);
        checkPutGetSql(ig, true);
    } finally {
        stopAllGrids();
    }
    info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    startGrids(GRID_CNT);
    try {
        IgniteEx ig = grid(0);
        ig.active(true);
        checkPutGetSql(ig, false);
    } finally {
        stopAllGrids();
    }
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx)

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