Hi,

Does ignite support distributed transaction in case of collocate
computation?

I started two ignite nodes and then pushed the data to cache using
following code. Please check code as given below.  In this code I am
rolling back the transaction at the end of compute affinity run. But after
doing rollback the values in the map are not getting restored to previous
version.

Can anyone please help? Am I doing something wrong?


*public static void *main(String[] args) *throws *Exception {
    Ignition.*setClientMode*(*true*);

    *try*( Ignite ignite = Ignition.*start*(*"ignite-configuration.xml"*)){
            IgniteCache<Integer, String> cache =
ignite.getOrCreateCache(*"ipcache1"*);

        *for *(*int *i = 0; i < 10; i++)
            cache.put(i, Integer.*toString*(i));

        *for *(*int *i = 0; i < 10; i++)
            System.*out*.println(*"Got [key=" *+ i + *", val=" *+
cache.get(i) + *']'*);

        System.*out*.println(*"Node Started"*);

        *final *IgniteCache<Integer, String> cache1 =
ignite.cache(*"ipcache1"*);
        IgniteTransactions transactions = ignite.transactions();
        *Transaction tx = transactions.txStart(TransactionConcurrency.*
*OPTIMISTIC,
                TransactionIsolation.SERIALIZABLE**);*

        *for *(*int *i = 0; i < 10; i++) {
            *int *key = i;


       ignite.compute().affinityRun(*"ipcache1"*, key,
                    () -> {
                            System.*out*.println(*"Co-located using
affinityRun [key= " *+ key + *", value=" *+ cache1.localPeek(key) +
*']'*);

                        String s = cache1.get(key);
                        s = s+*"#Modified"*;
                        cache1.put(key,s);
                    }
            );
        }
        *tx.rollback();*
        System.*out*.println(*"RolledBack..."*);
        *for *(*int *i = 0; i < 10; i++)
            System.*out*.println(*"Got [key=" *+ i + *", val=" *+
cache.get(i) + *']'*);
    }

}



Thanks,
Prasad

Reply via email to