Re: Does IgniteCache.containsKey lock the key in a Transaction?
Yohan, IgniteCache#containsKey(...) <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/IgniteCache.html#containsKey-K-> locks a key under pessimistic transactions with REPEATABLE_READ isolation level, just like a get(). And it doesn’t make servers send values back to a requesting node, so basically it does what you need. Denis > On 19 Aug 2019, at 14:08, Yohan Fernando wrote: > > Hi Nattapon, > > Unfortunately explicit locks cannot be used within transactions and an > exception will be thrown. > > It seems the only way is to rely on implicit locks using calls like get() and > containsKey(). I looked through the ignite source for these methods and it > does appear like containsKey delegates to the same call as get() but has a > flag about whether to serialize or not so I assume that containsKey might > avoid serialization. However I’m not an expert on the Ignite codebase so it > would be good if someone can confirm that this is indeed the case. > > Thanks > > Yohan > > From: nattapon mailto:wrong...@gmail.com>> > Sent: 19 August 2019 08:00 > To: user@ignite.apache.org <mailto:user@ignite.apache.org> > Subject: Re: Does IgniteCache.containsKey lock the key in a Transaction? > > Caution: This email originated from outside of Tudor. > > Hi Yohan, > > There is IgniteCache.lock(key) method described in > https://apacheignite.readme.io/docs/distributed-locks > <https://urldefense.proofpoint.com/v2/url?u=https-3A__apacheignite.readme.io_docs_distributed-2Dlocks=DwMFaQ=lcVbikor4usg5Rj5OmznbA=m3tOHOhTDmqyOCq26PYainXMtahLsVWUQ4sqnN5broM=OI_UZ3gny3V8V5LQLeGQxF_GFdCwvZRHvxcHXzZ9tno=Bi2hfO-Sdhxidc_h2QGpmMRSfsEapHSmgLg9BH0nNbo=> > . Is it suited your requirement? > > IgniteCache cache = ignite.cache("myCache"); > > // Create a lock for the given key > Lock lock = cache.lock("keyLock"); > try { > // Acquire the lock > lock.lock(); > > cache.put("Hello", 11); > cache.put("World", 22); > } > finally { > // Release the lock > lock.unlock(); > } > > Regards, > Nattapon > > On Fri, Aug 16, 2019 at 5:23 PM Yohan Fernando <mailto:yohan.ferna...@tudor.com>> wrote: > Hi All, Does IgniteCache.containsKey() lock the key in a Transaction similar > to IgniteCache.get() ? Basically I want a lightweight call to lock the key > without having to Serialize objects from each node within a Transaction. > > > _ > > This email, its contents, and any attachments transmitted with it are > intended only for the addressee(s) and may be confidential and legally > privileged. We do not waive any confidentiality by misdelivery. If you have > received this email in error, please notify the sender immediately and delete > it. You should not copy it, forward it or otherwise use the contents, > attachments or information in any way. Any liability for viruses is excluded > to the fullest extent permitted by law. > > Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial > Conduct Authority (the FCA). TCE is registered as a limited liability > partnership in England and Wales No: OC340673 with its registered office at > 10 New Burlington Street, London, W1S 3BE, United Kingdom > > _ > > This email, its contents, and any attachments transmitted with it are > intended only for the addressee(s) and may be confidential and legally > privileged. We do not waive any confidentiality by misdelivery. If you have > received this email in error, please notify the sender immediately and delete > it. You should not copy it, forward it or otherwise use the contents, > attachments or information in any way. Any liability for viruses is excluded > to the fullest extent permitted by law. > > Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial > Conduct Authority (the FCA). TCE is registered as a limited liability > partnership in England and Wales No: OC340673 with its registered office at > 10 New Burlington Street, London, W1S 3BE, United Kingdom >
RE: Does IgniteCache.containsKey lock the key in a Transaction?
Hi Nattapon, Unfortunately explicit locks cannot be used within transactions and an exception will be thrown. It seems the only way is to rely on implicit locks using calls like get() and containsKey(). I looked through the ignite source for these methods and it does appear like containsKey delegates to the same call as get() but has a flag about whether to serialize or not so I assume that containsKey might avoid serialization. However I’m not an expert on the Ignite codebase so it would be good if someone can confirm that this is indeed the case. Thanks Yohan From: nattapon Sent: 19 August 2019 08:00 To: user@ignite.apache.org Subject: Re: Does IgniteCache.containsKey lock the key in a Transaction? Caution: This email originated from outside of Tudor. Hi Yohan, There is IgniteCache.lock(key) method described in https://apacheignite.readme.io/docs/distributed-locks<https://urldefense.proofpoint.com/v2/url?u=https-3A__apacheignite.readme.io_docs_distributed-2Dlocks=DwMFaQ=lcVbikor4usg5Rj5OmznbA=m3tOHOhTDmqyOCq26PYainXMtahLsVWUQ4sqnN5broM=OI_UZ3gny3V8V5LQLeGQxF_GFdCwvZRHvxcHXzZ9tno=Bi2hfO-Sdhxidc_h2QGpmMRSfsEapHSmgLg9BH0nNbo=> . Is it suited your requirement? IgniteCache cache = ignite.cache("myCache"); // Create a lock for the given key Lock lock = cache.lock("keyLock"); try { // Acquire the lock lock.lock(); cache.put("Hello", 11); cache.put("World", 22); } finally { // Release the lock lock.unlock(); } Regards, Nattapon On Fri, Aug 16, 2019 at 5:23 PM Yohan Fernando mailto:yohan.ferna...@tudor.com>> wrote: Hi All, Does IgniteCache.containsKey() lock the key in a Transaction similar to IgniteCache.get() ? Basically I want a lightweight call to lock the key without having to Serialize objects from each node within a Transaction. _ This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law. Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom _ This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law. Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom
Re: Does IgniteCache.containsKey lock the key in a Transaction?
Hi Yohan, There is IgniteCache.lock(key) method described in https://apacheignite.readme.io/docs/distributed-locks . Is it suited your requirement? IgniteCache cache = ignite.cache("myCache"); // Create a lock for the given key Lock lock = cache.lock("keyLock"); try { // Acquire the lock lock.lock(); cache.put("Hello", 11); cache.put("World", 22); } finally { // Release the lock lock.unlock(); } Regards, Nattapon On Fri, Aug 16, 2019 at 5:23 PM Yohan Fernando wrote: > Hi All, Does IgniteCache.containsKey() lock the key in a Transaction > similar to IgniteCache.get() ? Basically I want a lightweight call to lock > the key without having to Serialize objects from each node within a > Transaction. > > > > > > _ > > This email, its contents, and any attachments transmitted with it are > intended only for the addressee(s) and may be confidential and legally > privileged. We do not waive any confidentiality by misdelivery. If you have > received this email in error, please notify the sender immediately and > delete it. You should not copy it, forward it or otherwise use the > contents, attachments or information in any way. Any liability for viruses > is excluded to the fullest extent permitted by law. > > Tudor Capital Europe LLP (TCE) is authorised and regulated by The > Financial Conduct Authority (the FCA). TCE is registered as a limited > liability partnership in England and Wales No: OC340673 with its registered > office at 10 New Burlington Street, London, W1S 3BE, United Kingdom >
Does IgniteCache.containsKey lock the key in a Transaction?
Hi All, Does IgniteCache.containsKey() lock the key in a Transaction similar to IgniteCache.get() ? Basically I want a lightweight call to lock the key without having to Serialize objects from each node within a Transaction. _ This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law. Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom