@Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { getMessagingClient().setMessageQueue( messageQueue ); }
@Override public void deleteMessagingServerArtifacts( Application application ) throws IOException { getMessagingClient().deleteMessagingServerArtifacts( application ); }
@Override public void listenToAgentMessages( Application application, ListenerCommand command ) throws IOException { listenToAgentMessages( getMessagingClient(), application, command ); }
@Override public void deleteMessagingServerArtifacts( Application application ) throws IOException { getMessagingClient().deleteMessagingServerArtifacts( application ); }
@Override public void openConnection() throws IOException { getMessagingClient().openConnection(); }
@Override public boolean isConnected() { return getMessagingClient().isConnected(); }
@Override public void listenToAgentMessages( Application application, ListenerCommand command ) throws IOException { listenToAgentMessages( getMessagingClient(), application, command ); }
@Override public void setMessageQueue( RoboconfMessageQueue messageQueue ) { getMessagingClient().setMessageQueue( messageQueue ); }
@Override public boolean isConnected() { return getMessagingClient().isConnected(); }
@Override public void openConnection() throws IOException { getMessagingClient().openConnection(); }
@Override public void listenToTheDm( ListenerCommand command ) throws IOException { MessagingContext ctx = new MessagingContext( RecipientKind.DM, this.domain, null ); if( command == ListenerCommand.STOP ) getMessagingClient().unsubscribe( ctx ); else getMessagingClient().subscribe( ctx ); }
@Override public void listenToTheDm( ListenerCommand command ) throws IOException { MessagingContext ctx = new MessagingContext( RecipientKind.DM, this.domain, null ); if( command == ListenerCommand.STOP ) getMessagingClient().unsubscribe( ctx ); else getMessagingClient().subscribe( ctx ); }
@Override public void sendMessageToTheDm( Message msg ) throws IOException { MessagingContext ctx = new MessagingContext( RecipientKind.DM, this.domain, null ); getMessagingClient().publish( ctx, msg ); }
@Override public void sendMessageToTheDm( Message msg ) throws IOException { MessagingContext ctx = new MessagingContext( RecipientKind.DM, this.domain, null ); getMessagingClient().publish( ctx, msg ); }
@Override public void sendMessageToAgent( Application application, Instance instance, Message message ) throws IOException { // The context match the one used by agents to listen to messages sent by the DM. String topicName = MessagingUtils.buildTopicNameForAgent( instance ); MessagingContext ctx = new MessagingContext( RecipientKind.AGENTS, this.domain, topicName, application.getName()); getMessagingClient().publish( ctx, message ); }
@Override public void sendMessageToAgent( Application application, Instance instance, Message message ) throws IOException { // The context match the one used by agents to listen to messages sent by the DM. String topicName = MessagingUtils.buildTopicNameForAgent( instance ); MessagingContext ctx = new MessagingContext( RecipientKind.AGENTS, this.domain, topicName, application.getName()); getMessagingClient().publish( ctx, message ); }
@Override public void propagateAgentTermination( Application application, Instance rootInstance ) throws IOException { // Start with the deepest instances List<Instance> instances = InstanceHelpers.buildHierarchicalList( rootInstance ); Collections.reverse( instances ); // Roughly, we unpublish all the variables for all the instances that were on the agent's machine. // This code is VERY similar to ...ClientAgent#unpublishExports // The messages will go through JUST like if they were coming from other agents. this.logger.fine( "The DM is un-publishing exports related to agent of " + rootInstance + " (termination propagation)." ); for( Instance instance : instances ) { for( MessagingContext ctx : MessagingContext.forExportedVariables( this.domain, application.getName(), instance, application.getExternalExports(), ThoseThat.IMPORT )) { MsgCmdRemoveImport message = new MsgCmdRemoveImport( application.getName(), ctx.getComponentOrFacetName(), InstanceHelpers.computeInstancePath( instance )); // FIXME: external exports are not handled here!!!! getMessagingClient().publish( ctx, message ); } } }
@Override public void propagateAgentTermination( Application application, Instance rootInstance ) throws IOException { // Start with the deepest instances List<Instance> instances = InstanceHelpers.buildHierarchicalList( rootInstance ); Collections.reverse( instances ); // Roughly, we unpublish all the variables for all the instances that were on the agent's machine. // This code is VERY similar to ...ClientAgent#unpublishExports // The messages will go through JUST like if they were coming from other agents. this.logger.fine( "The DM is un-publishing exports related to agent of " + rootInstance + " (termination propagation)." ); for( Instance instance : instances ) { for( MessagingContext ctx : MessagingContext.forExportedVariables( this.domain, application.getName(), instance, application.getExternalExports(), ThoseThat.IMPORT )) { MsgCmdRemoveImport message = new MsgCmdRemoveImport( application.getName(), ctx.getComponentOrFacetName(), InstanceHelpers.computeInstancePath( instance )); // FIXME: external exports are not handled here!!!! getMessagingClient().publish( ctx, message ); } } }
Assert.assertEquals( JmxWrapperForMessagingClient.class, client.getMessagingClient().getClass()); Assert.assertTrue(((JmxWrapperForMessagingClient) client.getMessagingClient()).isDismissClient()); Assert.assertEquals( JmxWrapperForMessagingClient.class, client.getMessagingClient().getClass()); Assert.assertFalse(((JmxWrapperForMessagingClient) client.getMessagingClient()).isDismissClient()); (client.getMessagingClient()), "messagingClient", IMessagingClient.class ); Assert.assertEquals( JmxWrapperForMessagingClient.class, client.getMessagingClient().getClass()); Assert.assertTrue(((JmxWrapperForMessagingClient) client.getMessagingClient()).isDismissClient());
@Test public void testDm() throws Exception { // The messaging client is never null ReconfigurableClientDm client = new ReconfigurableClientDm(); Assert.assertNotNull( client.getMessagingClient()); // Invoke other method, no matter in which order client.setMessageQueue( new RoboconfMessageQueue()); Assert.assertFalse( client.hasValidClient()); Assert.assertFalse( client.isConnected()); client.deleteMessagingServerArtifacts( new Application( "app", new ApplicationTemplate())); client.propagateAgentTermination( null, null ); }