Well. Consider transaction started in one node, and continued in another
one.
The following test describes my idea:

Ignite ignite1 = ignite(0);

IgniteTransactions transactions = ignite1.transactions();

IgniteCache<String, Integer> cache = ignite1.getOrCreateCache("testCache");

Transaction tx = transactions.txStart(concurrency, isolation);

cache.put("key1", 1);

cache.put("key2", 2);

tx.stop();

IgniteInternalFuture<Boolean> fut = GridTestUtils.runAsync(() -> {
    IgniteTransactions ts = ignite(1).transactions();
    Assert.assertNull(ts.tx());
    Assert.assertEquals(TransactionState.STOPPED, tx.state());
    ts.txStart(tx);
    Assert.assertEquals(TransactionState.ACTIVE, tx.state());
    cache.put("key3", 3);
    Assert.assertTrue(cache.remove("key2"));
    tx.commit();
    return true;
});

fut.get();

Assert.assertEquals(TransactionState.COMMITTED, tx.state());
Assert.assertEquals((long)1, (long)cache.get("key1"));
Assert.assertEquals((long)3, (long)cache.get("key3"));
Assert.assertFalse(cache.containsKey("key2"));

In method *ts.txStart(...)* we just rebind *tx* to current thread:

public void txStart(Transaction tx) {
    TransactionProxyImpl transactionProxy = (TransactionProxyImpl)tx;
    cctx.tm().reopenTx(transactionProxy.tx());
    transactionProxy.bindToCurrentThread();
}

In method *reopenTx* we alter *threadMap* so that it binds transaction
to current thread.

How do u think about it ?


вт, 7 мар. 2017 г. в 22:38, Denis Magda <dma...@apache.org>:

> Hi Alexey,
>
> Please share the rational behind this and the thoughts, design ideas you
> have in mind.
>
> —
> Denis
>
> > On Mar 7, 2017, at 3:19 AM, ALEKSEY KUZNETSOV <alkuznetsov...@gmail.com>
> wrote:
> >
> > Hi all! Im designing distributed transaction which can be started at one
> > node, and continued at other one. Has anybody thoughts on it ?
> > --
> >
> > *Best Regards,*
> >
> > *Kuznetsov Aleksey*
>
> --

*Best Regards,*

*Kuznetsov Aleksey*

Reply via email to