@Override public void resynchronizeAgents( ManagedApplication ma ) throws IOException { this.messagingMngr.checkMessagingConfiguration(); this.logger.fine( "Resynchronizing agents in " + ma.getName() + "..." ); for( Instance rootInstance : ma.getApplication().getRootInstances()) { if( rootInstance.getStatus() == InstanceStatus.DEPLOYED_STARTED ) this.messagingMngr.sendMessageDirectly( ma, rootInstance, new MsgCmdResynchronize()); } this.logger.fine( "Requests were sent to resynchronize agents in " + ma.getName() + "." ); }
@Test public void testMessage_resynchronize() throws Exception { MsgCmdResynchronize msg = new MsgCmdResynchronize(); checkBasics( msg, MsgCmdResynchronize.class ); }
@Test public void testPublish() throws Exception { TestClient client = new TestClient(); MessagingContext ctx = new MessagingContext( RecipientKind.DM, "domain", "app1" ); Assert.assertEquals( 0, client.ctxToMessages.size()); client.publish( ctx, new MsgCmdSendInstances()); client.publish( ctx, new MsgCmdSendInstances()); Assert.assertEquals( 1, client.ctxToMessages.size()); List<Message> messages = client.ctxToMessages.get( ctx ); Assert.assertEquals( 2, client.messagesForTheDm.size()); Assert.assertEquals( 2, messages.size()); Assert.assertEquals( MsgCmdSendInstances.class, messages.get( 0 ).getClass()); Assert.assertEquals( MsgCmdSendInstances.class, messages.get( 1 ).getClass()); Assert.assertEquals( 0, client.messagesForAgents.size()); ctx = new MessagingContext( RecipientKind.AGENTS, "domain", "app1" ); client.publish( ctx, new MsgCmdResynchronize()); Assert.assertEquals( 1, client.messagesForAgents.size()); Assert.assertEquals( MsgCmdResynchronize.class, client.messagesForAgents.get( 0 ).getClass()); }
@Test public void testProcessing() throws Exception { // The message is processed... this.processor.start(); this.processor.storeMessage( new MsgCmdResynchronize()); Thread.sleep( 1000 ); this.processor.stopProcessor(); Assert.assertEquals( 0, this.processor.getMessageQueue().size()); }
@Test public void testToString() { MsgCmdRemoveInstance msg1 = new MsgCmdRemoveInstance( "/path" ); Assert.assertEquals( "MsgCmdRemoveInstance", msg1.toString()); MsgCmdResynchronize msg2 = new MsgCmdResynchronize(); Assert.assertEquals( "MsgCmdResynchronize", msg2.toString()); } }