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());
}
}
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);
}
Aggregations