On Fri, Mar 8, 2013 at 9:02 AM,
<gise...@yachay.net> wrote:
Hello,
On using ILock,
. hazelcast confifguration: I do not see any specific entries for this type of object. E.g., locks being destroyed after not being locked for a certain time (idle?)
. let's say, I choose String as the object to lock.
. If I somehow use the lock to lock on a key for some time, but then I do not want to have this object stay in the hazelcast cache, how do I get rid of it?
call ILock.destroy()???
Yes, you need to destroy it. Otherwise it will remain in the memory. However if you use lock on IMap and not use the entry for any other purpose, after the unlock, it will be destroyed automatically.
Imap.lock("mylock");
Imap.unlock("mylock");
. I created a JMX class function to view the locks that are being used, when they are in locked state,
Collection<Instance> instances = hazelcastInstance.getInstances();
Set<LockInfo<String>> locks = new HashSet<LockInfo<String>>();
for (Instance inst : instances) {
if (inst.getInstanceType().equals(Instance.InstanceType.LOCK)) {
ILock lock = (ILock) inst;
if (lock.isLocked()) {
LockInfo<String> lockInfo = getLockInfo(lock);
locks.add(lockInfo);
}
}
}
1. The code above I believe will only get the locks that my local instance is seeing,or that the code has invoked by calling hazelcastInstance.getLock(lockName), correct?
It will get all the locks that are locked in the system. Doesn't matter where they are created. Actually there is no way of getting the locks that are created in specific member. Actually it want tell you the locks on the IMap. It will return only the locks that are created as hazelcastInstance.getLock("");
2. If I want to see all the locks in the system, I might have to use Hazelcast.getAllInstances(), and then apply the loop above, ??
Yes, except the locks on the IMap.
3. The class LocalLockStats, as the name says, would only have information about locks used in the local node?
It will show you the statistics that is gathered from local node. But you can apply it to any Lock. That is the lock can be anywhere, but the statistics is just about the local node. Ex: How many locks per second is this local node is doing on this distributed ILock.
4. periodStart and PeriodEnd, are these related to lock creation or last time being locked?
These are related only to the statistics. The information on LocalLockStat is relevant to that timeframe.
5. Is it a good idea to hold on an ILock once I create a lock in a node, or should it be better to just call hazelcastInstance.getLock(lockName) all the time and the apply the desired lock
operation?
It doesn't matter. It is the same proxy and you can save from one CHM lookup by just holding the ILock.
The reason I am asking this, is that if another node, e.g., node2, is later locking the same lock that node1 create, locked, and unlocked.
Then node2 after it finishes de3cides to destroy the lock.
Will node1, which has got a hold of the ILock, when it first created the lock, if it tries to lock again, get an exception, since the lock was destroyed??
Even if it is destroyed, when node1 does an operation on it, Hazelcast will silently create that lock.
I would appreciate any feedback regarding these questions.
Thanks.
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.