/** * @param concurrency Concurrency. * @param isolation Isolation. * @throws GridException If test failed. */ private void checkTransactionTimeout( GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation) throws Exception { boolean wasEx = false; GridCacheTx tx = null; try { GridCache<Integer, String> cache = grid.cache(null); tx = cache.txStart(concurrency, isolation, 50, 0); cache.put(1, "1"); Thread.sleep(100); cache.put(1, "2"); tx.commit(); } catch (GridCacheTxOptimisticException e) { info("Received expected optimistic exception: " + e.getMessage()); wasEx = true; tx.rollback(); } catch (GridCacheTxTimeoutException e) { info("Received expected timeout exception: " + e.getMessage()); wasEx = true; tx.rollback(); } assert wasEx; }
/** @throws Exception If failed. */ public void testKeyMappingOnComputeNode() throws Exception { try { cache = true; for (int i = 0; i < 4; i++) { nearOnly = i == 0; startGrid(i); } cache = false; Grid compute = startGrid(4); for (int i = 0; i < 100; i++) { GridNode node = compute.mapKeyToNode(null, i); assertFalse("For key: " + i, node.id().equals(compute.localNode().id())); assertFalse("For key: " + i, node.id().equals(grid(0).localNode().id())); } } finally { stopAllGrids(); } }