public class FooTest extends GridCacheAbstractSelfTest {

    @Override
    protected void afterTestsStopped() throws Exception {
        super.afterTestsStopped();
        stopAllGrids();
    }

    @Override
    protected int gridCount() {
        return 3;
    }

    @Override
    protected CacheMode cacheMode() {
        return CacheMode.PARTITIONED;
    }

    @Override
    protected CacheAtomicityMode atomicityMode() {
        return CacheAtomicityMode.TRANSACTIONAL;
    }

    public void testLoggingTransactions() throws InterruptedException {
        Ignite ignite0 = ignite(0);
        IgniteTransactions transactions = ignite0.transactions();
        IgniteCache<String, String> cache =
ignite0.getOrCreateCache("testCache");
        Object monitor = new Object();

        GridTestUtils.runAsync(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                synchronized (monitor){
                    doInTransaction(ignite(1), new Callable<Object>() {
                        @Override
                        public Object call() throws Exception {
                            cache.put("key1", "val1");
                            monitor.wait();
                            System.out.println("continue first transaction");
                            return null;
                        }
                    });
                }
                return null;
            }
        });

        Transaction tx =
transactions.txStart(TransactionConcurrency.OPTIMISTIC,
TransactionIsolation.READ_COMMITTED);
        cache.put("key1", "val1");
        cache.put("key2", "val2");
        cache.put("key3", "val3");
        tx.commit();

    }
}


чт, 30 мар. 2017 г. в 11:55, Alexey Goncharuk <alexey.goncha...@gmail.com>:

> Can you please paste the full example?
>
> 2017-03-30 11:50 GMT+03:00 ALEKSEY KUZNETSOV <alkuznetsov...@gmail.com>:
>
> > But i managed to read dirty. That is my example :
> >
> > Ignite ignite0 = ignite(0);
> > IgniteTransactions transactions = ignite0.transactions();
> > IgniteCache<String, String> cache =
> ignite0.getOrCreateCache("testCache");
> > Object monitor = new Object();
> >
> > GridTestUtils.runAsync(new Callable<Object>() {
> >     @Override
> >     public Object call() throws Exception {
> >         synchronized (monitor){
> >             doInTransaction(ignite(1), new Callable<Object>() {
> >                 @Override
> >                 public Object call() throws Exception {
> >                     cache.put("key1", "val1");
> >                     monitor.wait();
> >                     return null;
> >                 }
> >             });
> >         }
> >         return null;
> >     }
> > });
> >
> > Transaction tx =
> > transactions.txStart(TransactionConcurrency.OPTIMISTIC,
> > TransactionIsolation.READ_COMMITTED);
> > cache.put("key1", "val1");
> >
> > And through debugging cache.put() method i can see in method
> > *org.apache.ignite.internal.processors.cache.distributed.
> > near.GridNearTxLocal#enlistWriteEntry*
> > that "key1" already *EXISTS *in internal cache :
> cacheCtx.cache().entryEx()
> > returns not null.
> >
> > ср, 29 мар. 2017 г. в 20:11, Alexander Fedotov <
> > alexander.fedot...@gmail.com
> > >:
> >
> > Hello Aleksey,
> >
> > No, the enlisted entry won't be visible for other transactions. Dirty
> reads
> > are not allowed in Ignite.
> >
> > Kind regards,
> > Alex
> >
> > 29 марта 2017 г. 7:36 PM пользователь "ALEKSEY KUZNETSOV" <
> > alkuznetsov...@gmail.com> написал:
> >
> > Hello, Igniters! I have one more question to you. Will appreciate any
> help.
> > Consider cache with near , dht configured not null.
> > When we start commit transaction , in method
> > *org.apache.ignite.internal.processors.cache.distributed.
> > near.GridNearTxLocal#enlistWriteEntry*
> > we put newly created entry into cache by executing entryEx().
> > I wonder if this entry will became visible for other transactions!?
> > --
> >
> > *Best Regards,*
> >
> > *Kuznetsov Aleksey*
> >
> > --
> >
> > *Best Regards,*
> >
> > *Kuznetsov Aleksey*
> >
>
-- 

*Best Regards,*

*Kuznetsov Aleksey*

Reply via email to