Search in sources :

Example 1 with GridCacheInternalKey

use of org.apache.ignite.internal.processors.datastructures.GridCacheInternalKey in project ignite by apache.

the class GridCachePartitionedNodeRestartTxSelfTest method checkCustom.

/**
     * Test {@link GridCacheInternalKey}/{@link GridCacheAtomicLongValue}.
     * @param name Name.
     * @throws Exception If failed.
     */
private void checkCustom(String name) throws Exception {
    for (int i = INIT_GRID_NUM; i < 20; i++) {
        startGrid(i);
        assert PARTITIONED == grid(i).cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode();
        try (Transaction tx = grid(i).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
            GridCacheInternalKey key = new GridCacheInternalKeyImpl(name);
            GridCacheAtomicLongValue atomicVal = ((GridCacheAtomicLongValue) grid(i).cache(DEFAULT_CACHE_NAME).get(key));
            assertNotNull(atomicVal);
            assertEquals("Custom check failed for node: " + i, (long) i, atomicVal.get());
            atomicVal.set(i + 1);
            grid(i).cache(DEFAULT_CACHE_NAME).put(key, atomicVal);
            tx.commit();
        }
        stopGrid(i);
    }
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) GridCacheAtomicLongValue(org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue) GridCacheInternalKeyImpl(org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl) GridCacheInternalKey(org.apache.ignite.internal.processors.datastructures.GridCacheInternalKey)

Aggregations

GridCacheAtomicLongValue (org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue)1 GridCacheInternalKey (org.apache.ignite.internal.processors.datastructures.GridCacheInternalKey)1 GridCacheInternalKeyImpl (org.apache.ignite.internal.processors.datastructures.GridCacheInternalKeyImpl)1 Transaction (org.apache.ignite.transactions.Transaction)1