@Test public void testOnMessage() throws Exception { final Sequence callSeq = jmock.sequence("call-seq"); final IntentEntry entry = new IntentEntry(InetSocketAddress.createUnresolved("localhost",1111),LockMode.EXCLUSIVE,15L,15L); final ClusterLockManager.MultiplexedLockMessage multiplexedMessage = new ClusterLockManager.MultiplexedLockMessage(lockName,entry); jmock.checking(new Expectations() {{ oneOf(currentLocks).binding(lockName);will(returnValue(mapStoredState));inSequence(callSeq); oneOf(lockFactoryBinder).createFactory(lockName);will(returnValue(boundLockFactory));inSequence(callSeq); oneOf(clusterMembershipLock).readLock();will(returnValue(readLock));inSequence(callSeq); oneOf(mapStoredState).get();will(returnValue(factoryGeneratedState));inSequence(callSeq); oneOf(factoryGeneratedState).onMessage(entry);inSequence(callSeq); }}); mgr.onMessage(multiplexedMessage); }
@Override public void onMessage(ClusterLockMessage message) { if (message instanceof MultiplexedLockMessage){ MultiplexedLockMessage multi = (MultiplexedLockMessage)message; ClusterLock oneShot = generateLockEngine(multi.lockName); oneShot.onMessage(multi.entry); } else if (message instanceof LockInitMessage){ LockInitMessage initMessage = (LockInitMessage)message; onMembershipEvent(MembershipEventType.MEMBER_ACTIVE, initMessage.address); } else { log.warn("Ignoring unknown message type, "+message.getClass().getName()); } }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMessage(ClusterLockMessage message) { if (message instanceof MultiplexedLockMessage){ MultiplexedLockMessage multi = (MultiplexedLockMessage)message; ClusterLock oneShot = generateLockEngine(multi.lockName); oneShot.onMessage(multi.entry); } else if (message instanceof LockInitMessage){ LockInitMessage initMessage = (LockInitMessage)message; onMembershipEvent(MembershipEventType.MEMBER_ACTIVE, initMessage.address); } else { log.warn("Ignoring unknown message type, "+message.getClass().getName()); } } }
ClusterLockManager implements GroupTopicListener<ClusterLockManager.ClusterLockMessage>, GroupMembershipListener, LockManager { @Override public void onMessage(ClusterLockMessage message) { if (message instanceof MultiplexedLockMessage){ MultiplexedLockMessage multi = (MultiplexedLockMessage)message; ClusterLock oneShot = generateLockEngine(multi.lockName); oneShot.onMessage(multi.entry); } else if (message instanceof LockInitMessage){ LockInitMessage initMessage = (LockInitMessage)message; onMembershipEvent(MembershipEventType.MEMBER_ACTIVE, initMessage.address); } else { log.warn("Ignoring unknown message type, "+message.getClass().getName()); } } 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 onMessage(ClusterLockMessage message) { if (message instanceof MultiplexedLockMessage){ MultiplexedLockMessage multi = (MultiplexedLockMessage)message; ClusterLock oneShot = generateLockEngine(multi.lockName); oneShot.onMessage(multi.entry); } else if (message instanceof LockInitMessage){ LockInitMessage initMessage = (LockInitMessage)message; onMembershipEvent(MembershipEventType.MEMBER_ACTIVE, initMessage.address); } else { log.warn("Ignoring unknown message type, "+message.getClass().getName()); } } 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 onMessage(ClusterLockMessage message) { if (message instanceof MultiplexedLockMessage){ MultiplexedLockMessage multi = (MultiplexedLockMessage)message; ClusterLock oneShot = generateLockEngine(multi.lockName); oneShot.onMessage(multi.entry); } else if (message instanceof LockInitMessage){ LockInitMessage initMessage = (LockInitMessage)message; onMembershipEvent(MembershipEventType.MEMBER_ACTIVE, initMessage.address); } else { log.warn("Ignoring unknown message type, "+message.getClass().getName()); } } 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();  }