Re: Design help implementing custom counter on ignite

2018-02-06 Thread dkarachentsev
Hi,

Transaction here might be a not optimal solution, as it by default
optimistic and may throw optimistic transaction exception. I believe the
best solution would be to use EntryProcessor [1], it will atomically modify
entry as on TRANSACTIONAL as on ATOMIC cache on affinity data node (that
actually keep this entry).

[1] https://apacheignite.readme.io/docs/jcache#entryprocessor

Thanks!
-Dmitry



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Design help implementing custom counter on ignite

2018-02-05 Thread Mansur.Ashraf
Hey guys,

I am new to Ignite and trying to implement a custom counter. I read the
document and it seems like I can implement my counter in three different
ways so need some help figuring out which approach to take.

//business logic in pseudo code

Ignite ignite = Ignition.ignite();
IgniteTransactions transactions = ignite.transactions();
try (Transaction tx = transactions.txStart()) {
Account account = cache.get(accNbr);
   long amount =account.getAmount()
account.updatedAmount(amount+10)
cache.put(accNbr,account);
tx.commit();
}

// end code

As far as I can tell, I can run this code

1) on the client side (maybe slow due to transaction?)
2) I can run it as IgniteCompute.affinityCall(...) on the grid itself. (I am
assuming I can start tx inside affinityCall)
3) Run this code as a Cluster Singleton behind a service

Please note that there could be multiple clients on different machines,
trying to update the same account so transaction locking is important. I am
leaning toward using affinityCall to implement this but was wondering
whether this is the correct approach?

Thanks




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/