Search in sources :

Example 31 with IgniteInternalCache

use of org.apache.ignite.internal.processors.cache.IgniteInternalCache in project ignite by apache.

the class GridCacheCommandHandler method executeCommand.

/**
 * Executes command on flagged cache projection. Checks {@code destId} to find if command could be performed locally
 * or routed to a remote node.
 *
 * @param destId Target node Id for the operation. If {@code null} - operation could be executed anywhere.
 * @param cacheName Cache name.
 * @param cacheFlags Cache flags.
 * @param key Key to set affinity mapping in the response.
 * @param op Operation to perform.
 * @return Operation result in future.
 * @throws IgniteCheckedException If failed
 */
private IgniteInternalFuture<GridRestResponse> executeCommand(@Nullable UUID destId, final String cacheName, final Set<GridClientCacheFlag> cacheFlags, final Object key, final CacheProjectionCommand op) throws IgniteCheckedException {
    final boolean locExec = destId == null || destId.equals(ctx.localNodeId()) || replicatedCacheAvailable(cacheName);
    if (locExec) {
        IgniteInternalCache<?, ?> prj = localCache(cacheName).setSkipStore(cacheFlags.contains(SKIP_STORE));
        if (cacheFlags.contains(KEEP_BINARIES))
            prj = prj.keepBinary();
        return op.apply((IgniteInternalCache<Object, Object>) prj, ctx).chain(resultWrapper((IgniteInternalCache<Object, Object>) prj, key));
    } else {
        ClusterGroup prj = ctx.grid().cluster().forPredicate(F.nodeForNodeId(destId));
        ctx.task().setThreadContext(TC_NO_FAILOVER, true);
        return ctx.closure().callAsync(BALANCE, new FlaggedCacheOperationCallable(cacheName, cacheFlags, op, key), prj.nodes());
    }
}
Also used : IgniteInternalCache(org.apache.ignite.internal.processors.cache.IgniteInternalCache) ClusterGroup(org.apache.ignite.cluster.ClusterGroup)

Example 32 with IgniteInternalCache

use of org.apache.ignite.internal.processors.cache.IgniteInternalCache in project ignite by apache.

the class GridIndexRebuildSelfTest method testIndexRebuild.

/**
 * Do test.
 * <p>
 * Steps are as follows:
 * <ul>
 *     <li>Put some data;</li>
 *     <li>Stop the node;</li>
 *     <li>Remove index file;</li>
 *     <li>Restart the node and block index rebuild;</li>
 *     <li>For half of the keys do cache puts <b>before</b> corresponding key
 *     has been processed during index rebuild;</li>
 *     <li>Check that:
 *         <ul>
 *             <li>For MVCC case: some keys have all versions that existed before restart, while those
 *             updated concurrently have only put version (one with mark value -1)
 *             and latest version present before node restart;</li>
 *             <li>For non MVCC case: keys updated concurrently must have mark values of -1 despite that
 *             index rebuild for them has happened after put.</li>
 *         </ul>
 *     </li>
 * </ul></p>
 * @throws Exception if failed.
 */
@Test
public void testIndexRebuild() throws Exception {
    IgniteEx srv = startServer();
    IgniteInternalCache cc = createAndFillTableWithIndex(srv);
    checkDataState(srv, false);
    File idxPath = indexFile(cc);
    stopAllGrids();
    assertTrue(delete(idxPath));
    srv = startServer();
    putData(srv, true);
    checkDataState(srv, true);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteInternalCache(org.apache.ignite.internal.processors.cache.IgniteInternalCache) File(java.io.File) DynamicIndexAbstractSelfTest(org.apache.ignite.internal.processors.cache.index.DynamicIndexAbstractSelfTest) Test(org.junit.Test)

Aggregations

IgniteInternalCache (org.apache.ignite.internal.processors.cache.IgniteInternalCache)32 IgniteEx (org.apache.ignite.internal.IgniteEx)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 Test (org.junit.Test)8 Ignite (org.apache.ignite.Ignite)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 IgniteKernal (org.apache.ignite.internal.IgniteKernal)6 ArrayList (java.util.ArrayList)5 IgniteCache (org.apache.ignite.IgniteCache)5 File (java.io.File)4 Cache (javax.cache.Cache)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 List (java.util.List)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)3 IgniteCacheOffheapManager (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager)3 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)3