0

I am using infinispan 7.2.5 version to make in memory cache. to access that cache I am using Hotrod. So I have hotrod server running on cluster mode and that multiple client who can access server using hotrod client.

I am doing a putAll operation to put data into cache. now I have a requirement where we want to put everything or nothing in cache so what I mean here either putAll should be able to put all the data into cache or if it fail nothing should be added into cache. I was going through the documentation of the infinispan to check if putAll is atomic but as per the documentation it is not.

So my question is :

  • How to make putAlll atomic to achieve requirement?

I was also thinking to make transactionMode cache but not sure if it solve my problem without impacting much on performance?

Any suggestion here will be appreciated.

Sanjay
  • 1,078
  • 11
  • 15
  • 1
    _""I was also thinking to make transactionMode cache but not sure if it solve my problem without impacting much on performance?_ Everything in software development involves tradeoffs. If you want an atomic `putAll()` you will have to decide if the performance hit of using transactions is more important than atomicity here. There is no free lunch. – Jim Garrison Feb 27 '18 at 06:29
  • Thanks @JimGarrison got your point, can you give me sample code link or some doc how to implement as a reference it as I don't have much idea about that. – Sanjay Feb 27 '18 at 07:19
  • No, that's not how StackOverflow works. YOU are expected to do the research and learning. Asking for sample code or external links is explicitly off-topic. Please visit the [help] and read [ask]. Study the manual, write some code, and then ask a _specific_ question if there's something that behaves unexpectedly. – Jim Garrison Feb 27 '18 at 07:20
  • Ok I will give a try to that part... but do we have any other way apart from transactionMode cache to achieve atomic put? – Sanjay Feb 27 '18 at 07:33
  • No, there is no other way: a transaction ensures that multiple operations appear as one to other operations/participants. As @JimGarrison says, you cannot get a free lunch. – Tristan Tarrant Feb 27 '18 at 10:48

1 Answers1

1

Infinispan does not support transactions over Hot Rod(*), and putAll is not atomic. It is not atomic in non-transactional embedded mode either.

The best workaround would be running with transactions, and starting the transaction manually from script execution.

(*) Server-side support is already in but the client-side has not been implemented yet. Client implementation is on the roadmap for 9.3 or 9.4 (subject to change).

Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
  • Is it applicable for infinispan version 7.2.5.Final? – Sanjay Mar 01 '18 at 07:49
  • do you know if putAll wait to insert all the data to cache, because I am getting size less then what we have put in .. and after few milliseconds I am getting actual size. – Sanjay Mar 01 '18 at 12:59
  • Scripts are supported in 7.2. PutAll is a synchronous operation, it does not return until all entries are stored (on all owners), as long as the cache is synchronous. There were changes in the way size() is handled, I don't recall if it could be lagging in 7.2 – Radim Vansa Mar 07 '18 at 14:46