Hi Mansoor,

in general, there're two approaches:

1. get data to a client, update and send it back
2. send code to data and make the update there

Both can work, which one is faster depends on your case, it depends on data
model size, backup count, your network speed.
So this is something that you should benchmark:)

Thanks,
Mike.


2018-02-05 14:20 GMT-08:00 M Mansur Ashraf <[email protected]>:

> 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
>

Reply via email to