Source:
public void testStaledMessage() throws InterruptedException { System.out.println("START TestHelixTaskExecutor.testStaledMessage()"); HelixTaskExecutor executor = new HelixTaskExecutor(); HelixManager manager = new MockClusterManager(); HelixDataAccessor dataAccessor = manager.getHelixDataAccessor(); PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder(); TestStateTransitionHandlerFactory stateTransitionFactory = new TestStateTransitionHandlerFactory(Message.MessageType.STATE_TRANSITION.name(), 1000); executor.registerMessageHandlerFactory(Message.MessageType.STATE_TRANSITION.name(), stateTransitionFactory); NotificationContext changeContext = new NotificationContext(manager); List<Message> msgList = new ArrayList<Message>(); int nMsgs = 1; String instanceName = manager.getInstanceName(); for (int i = 0; i < nMsgs; i++) { Message msg = new Message(Message.MessageType.STATE_TRANSITION.name(), UUID.randomUUID().toString()); msg.setTgtSessionId(manager.getSessionId()); msg.setCreateTimeStamp((long) i); msg.setTgtName("Localhost_1123"); msg.setSrcName("127.101.1.23_2234"); msg.setPartitionName("Partition"); msg.setResourceName("testStaledMessageResource"); msg.setStateModelDef("DummyMasterSlave"); msg.setFromState("SLAVE"); msg.setToState("MASTER"); dataAccessor.setProperty(msg.getKey(keyBuilder, instanceName), msg); msgList.add(msg); } Assert.assertEquals(dataAccessor.getChildValues(keyBuilder.messages(instanceName), true).size(), nMsgs); changeContext.setChangeType(HelixConstants.ChangeType.MESSAGE); executor.onMessage(instanceName, msgList, changeContext); Thread.sleep(200); Assert.assertEquals(dataAccessor.getChildValues(keyBuilder.messages(instanceName), true).size(), 0); System.out.println("END TestHelixTaskExecutor.testDuplicatedMessage()"); }

Target:
public void testStaledMessage() throws InterruptedException { System.out.println("START TestHelixTaskExecutor.testStaledMessage()"); HelixTaskExecutor executor = new HelixTaskExecutor(); HelixManager manager = new MockClusterManager(); HelixDataAccessor dataAccessor = manager.getHelixDataAccessor(); PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder(); TestStateTransitionHandlerFactory stateTransitionFactory = new TestStateTransitionHandlerFactory(Message.MessageType.STATE_TRANSITION.name(), 1000); executor.registerMessageHandlerFactory(Message.MessageType.STATE_TRANSITION.name(), stateTransitionFactory); NotificationContext changeContext = new NotificationContext(manager); List<Message> msgList = new ArrayList<Message>(); int nMsgs = 1; String instanceName = manager.getInstanceName(); for (int i = 0; i < nMsgs; i++) { Message msg = new Message(Message.MessageType.STATE_TRANSITION.name(), UUID.randomUUID().toString()); msg.setTgtSessionId(manager.getSessionId()); msg.setCreateTimeStamp((long) i); msg.setTgtName("Localhost_1123"); msg.setSrcName("127.101.1.23_2234"); msg.setPartitionName("Partition"); msg.setResourceName("testStaledMessageResource"); msg.setStateModelDef("DummyMasterSlave"); msg.setFromState("SLAVE"); msg.setToState("MASTER"); dataAccessor.setProperty(msg.getKey(keyBuilder, instanceName), msg); msgList.add(msg); } Assert.assertEquals(dataAccessor.getChildValues(keyBuilder.messages(instanceName), true).size(), nMsgs); changeContext.setChangeType(HelixConstants.ChangeType.MESSAGE); executor.onMessage(instanceName, msgList, changeContext); Thread.sleep(200); Assert.assertEquals(dataAccessor.getChildValues(keyBuilder.messages(instanceName), true).size(), 0); System.out.println("END TestHelixTaskExecutor.testStaledMessage()"); }