Search in sources :

Example 66 with GridCacheEntryEx

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

the class GridCacheNearOneNodeSelfTest method testOptimisticTxWriteThrough.

/**
     * Test Optimistic repeatable read write-through.
     *
     * @throws Exception If failed.
     */
@SuppressWarnings({ "ConstantConditions" })
public void testOptimisticTxWriteThrough() throws Exception {
    IgniteCache<Object, Object> near = jcache();
    GridCacheAdapter<Integer, String> dht = dht();
    try (Transaction tx = grid().transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) {
        near.put(2, "2");
        near.put(3, "3");
        assert "2".equals(near.get(2));
        assert "3".equals(near.get(3));
        GridCacheEntryEx entry = dht.peekEx(2);
        assert entry == null || entry.rawGet() == null : "Invalid entry: " + entry;
        tx.commit();
    }
    assert "2".equals(near.get(2));
    assert "3".equals(near.get(3));
    assert "2".equals(dht.get(2));
    assert "3".equals(dht.get(3));
    assertEquals(2, near.size());
    assertEquals(2, near.size());
    assertEquals(2, dht.size());
    assertEquals(2, dht.size());
}
Also used : GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) Transaction(org.apache.ignite.transactions.Transaction)

Aggregations

GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)66 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)38 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)31 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)30 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)25 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)22 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)15 IgniteTxEntry (org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry)14 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 IgniteKernal (org.apache.ignite.internal.IgniteKernal)10 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)10 EntryGetResult (org.apache.ignite.internal.processors.cache.EntryGetResult)10 GridDhtInvalidPartitionException (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)8 UUID (java.util.UUID)8 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)8 IgniteException (org.apache.ignite.IgniteException)7 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)7 IgniteTxKey (org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey)7