@Test public void testOnMembershipEvent() throws Exception { final Sequence callSeq = jmock.sequence("call-seq"); final Set<String> existingLocks = new TreeSet<String>(); existingLocks.add("one"); existingLocks.add("two"); final IntentEntry entry = new IntentEntry(InetSocketAddress.createUnresolved("localhost",1111), LockMode.EXCLUSIVE,15L,15L); final ClusterLockManager.MultiplexedLockMessage multiplexedMessage = new ClusterLockManager.MultiplexedLockMessage(lockName,entry); final MembershipView builtView = new SimpleMembershipView(); jmock.checking(new Expectations() {{ atLeast(1).of(memberTracker).getMembershipView();will(returnValue(builtView)); atLeast(1).of(clusterMembershipLock).writeLock();will(returnValue(writeLock));inSequence(callSeq); oneOf(writeLock).lock();inSequence(callSeq); oneOf(currentLocks).keySet();will(returnValue(existingLocks)); oneOf(currentLocks).binding("one");will(returnValue(mapStoredState));inSequence(callSeq); oneOf(lockFactoryBinder).createFactory("one");will(returnValue(boundLockFactory));inSequence(callSeq); oneOf(clusterMembershipLock).readLock();will(returnValue(readLock));inSequence(callSeq); oneOf(mapStoredState).get();will(returnValue(factoryGeneratedState));inSequence(callSeq); oneOf(factoryGeneratedState).onMembershipChange(builtView);inSequence(callSeq); oneOf(currentLocks).binding("two");will(returnValue(mapStoredState));inSequence(callSeq); oneOf(lockFactoryBinder).createFactory("two");will(returnValue(boundLockFactory));inSequence(callSeq); oneOf(clusterMembershipLock).readLock();will(returnValue(readLock));inSequence(callSeq); oneOf(mapStoredState).get();will(returnValue(factoryGeneratedState));inSequence(callSeq); oneOf(factoryGeneratedState).onMembershipChange(builtView);inSequence(callSeq); oneOf(writeLock).unlock();inSequence(callSeq); }}); mgr.onMembershipEvent(GroupMembershipListener.MembershipEventType.MEMBER_ADDED, InetSocketAddress.createUnresolved("localhost", 1111)); }
@Override public void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress) { clusterMembershipLock.writeLock().lock(); try{ if (memberTracker instanceof GroupMembershipListener){ GroupMembershipListener gml = (GroupMembershipListener)memberTracker; gml.onMembershipEvent(eventType, inetSocketAddress); } Set<String> keySet = currentLocks.keySet(); for (String namedLock : keySet){ ClusterLock oneShot = generateLockEngine(namedLock); oneShot.onMembershipChange(memberTracker.getMembershipView()); } } finally { clusterMembershipLock.writeLock().unlock(); } }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress) { clusterMembershipLock.writeLock().lock(); try{ if (memberTracker instanceof GroupMembershipListener){ GroupMembershipListener gml = (GroupMembershipListener)memberTracker; gml.onMembershipEvent(eventType, inetSocketAddress); } Set<String> keySet = currentLocks.keySet(); for (String namedLock : keySet){ ClusterLock oneShot = generateLockEngine(namedLock); oneShot.onMembershipChange(memberTracker.getMembershipView()); } } finally { clusterMembershipLock.writeLock().unlock(); } } }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress) { clusterMembershipLock.writeLock().lock(); try{ if (memberTracker instanceof GroupMembershipListener){ GroupMembershipListener gml = (GroupMembershipListener)memberTracker; gml.onMembershipEvent(eventType, inetSocketAddress); } Set<String> keySet = currentLocks.keySet(); for (String namedLock : keySet){ ClusterLock oneShot = generateLockEngine(namedLock); oneShot.onMembershipChange(memberTracker.getMembershipView()); } } finally { clusterMembershipLock.writeLock().unlock(); } } ClusterLockManager(CoordinationServices memberTracker);  ClusterLockManager(MonotonicLongClock clock, MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic);   ClusterLockManager(MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic, LockFactoryBinder<ClusterLock> lockFactoryBinder, ReadWriteLock clusterMembershipLock, ConcurrentReferenceMap<String, ClusterLock> currentLocks); }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress) { clusterMembershipLock.writeLock().lock(); try{ if (memberTracker instanceof GroupMembershipListener){ GroupMembershipListener gml = (GroupMembershipListener)memberTracker; gml.onMembershipEvent(eventType, inetSocketAddress); } Set<String> keySet = currentLocks.keySet(); for (String namedLock : keySet){ ClusterLock oneShot = generateLockEngine(namedLock); oneShot.onMembershipChange(memberTracker.getMembershipView()); } } finally { clusterMembershipLock.writeLock().unlock(); } } ClusterLockManager(CoordinationServices memberTracker);  ClusterLockManager(MonotonicLongClock clock, MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic);   ClusterLockManager(MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic, LockFactoryBinder<ClusterLock> lockFactoryBinder, ReadWriteLock clusterMembershipLock, ConcurrentReferenceMap<String, ClusterLock> currentLocks); void onStart(); ClusterLock getClusterLock(String lockName); ReadWriteLock getReadWriteLock(final String lockName); @Override void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress); @Override void onMessage(ClusterLockMessage message); @Override AcquiredLock acquire(LockClient client, LockSpecification spec, LockType type); @Override void release(AcquiredLock al); @Override String assertNoLocks(); @Override IntermediateResultSet showState(); void shutdown(); }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress) { clusterMembershipLock.writeLock().lock(); try{ if (memberTracker instanceof GroupMembershipListener){ GroupMembershipListener gml = (GroupMembershipListener)memberTracker; gml.onMembershipEvent(eventType, inetSocketAddress); } Set<String> keySet = currentLocks.keySet(); for (String namedLock : keySet){ ClusterLock oneShot = generateLockEngine(namedLock); oneShot.onMembershipChange(memberTracker.getMembershipView()); } } finally { clusterMembershipLock.writeLock().unlock(); } } ClusterLockManager(CoordinationServices memberTracker);  ClusterLockManager(MonotonicLongClock clock, MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic);   ClusterLockManager(MembershipViewSource memberTracker, GroupTopic<ClusterLockMessage> topic, LockFactoryBinder<ClusterLock> lockFactoryBinder, ReadWriteLock clusterMembershipLock, ConcurrentReferenceMap<String, ClusterLock> currentLocks); void onStart(); ClusterLock getClusterLock(String lockName); ReadWriteLock getReadWriteLock(final String lockName); @Override void onMembershipEvent(MembershipEventType eventType, InetSocketAddress inetSocketAddress); @Override void onMessage(ClusterLockMessage message); @Override AcquiredLock acquire(LockClient client, LockSpecification spec, LockType type); @Override void release(AcquiredLock al); @Override String assertNoLocks(); @Override IntermediateResultSet showState(); void shutdown();  }