@Test public void testExecute_valid_withSpecifiedInstance_notDeployed() throws Exception { this.gl.applicationName = this.app.getName(); this.gl.scopedInstancePath = InstanceHelpers.computeInstancePath( this.app.getTomcatVm()); this.gl.logger.setLevel( Level.FINE ); ByteArrayOutputStream os = new ByteArrayOutputStream(); this.gl.out = new PrintStream( os, true, "UTF-8" ); this.gl.execute(); Mockito.verify( this.applicationMngr, Mockito.times( 1 )).findManagedApplicationByName( this.gl.applicationName ); Mockito.verifyZeroInteractions( this.messagingMngr ); String s = os.toString( "UTF-8" ).trim(); Assert.assertTrue( s.startsWith( "No message will be sent to " )); Assert.assertTrue( s.contains( "On reception" )); Assert.assertTrue( s.endsWith( "/roboconf-logs..." )); }
@Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); for( Instance inst : info.getScopedInstances()) { if( inst.getStatus() == InstanceStatus.NOT_DEPLOYED ) { StringBuilder sb = new StringBuilder( "No message will be sent to " ); sb.append( this.scopedInstancePath ); sb.append( ", the associated agent is not marked as deployed." ); this.out.println( sb.toString()); continue; } if( this.logger.isLoggable( Level.FINE )) { StringBuilder sb = new StringBuilder( "Sending a request to gather the logs from " ); sb.append( this.scopedInstancePath ); sb.append( " @ " ); sb.append( this.applicationName ); this.logger.fine( sb.toString()); } MsgCmdGatherLogs message = new MsgCmdGatherLogs(); this.manager.messagingMngr().sendMessageSafely( info.getManagedApplication(), inst, message ); } File dumpFile = new File( System.getProperty( "java.io.tmpdir" ), "roboconf-logs" ); this.out.println( "On reception, logs will be stored under " + dumpFile.getAbsolutePath() + "..." ); return null; }
GatherLogsCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); for( Instance inst : info.getScopedInstances()) { if( inst.getStatus() == InstanceStatus.NOT_DEPLOYED ) { StringBuilder sb = new StringBuilder( "No message will be sent to " ); sb.append( this.scopedInstancePath ); sb.append( ", the associated agent is not marked as deployed." ); this.out.println( sb.toString()); continue; } if( this.logger.isLoggable( Level.FINE )) { StringBuilder sb = new StringBuilder( "Sending a request to gather the logs from " ); sb.append( this.scopedInstancePath ); sb.append( " @ " ); sb.append( this.applicationName ); this.logger.fine( sb.toString()); } MsgCmdGatherLogs message = new MsgCmdGatherLogs(); this.manager.messagingMngr().sendMessageSafely( info.getManagedApplication(), inst, message ); } File dumpFile = new File( System.getProperty( "java.io.tmpdir" ), "roboconf-logs" ); this.out.println( "On reception, logs will be stored under " + dumpFile.getAbsolutePath() + "..." ); return null; } }
GatherLogsCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); for( Instance inst : info.getScopedInstances()) { if( inst.getStatus() == InstanceStatus.NOT_DEPLOYED ) { StringBuilder sb = new StringBuilder( "No message will be sent to " ); sb.append( this.scopedInstancePath ); sb.append( ", the associated agent is not marked as deployed." ); this.out.println( sb.toString()); continue; } if( this.logger.isLoggable( Level.FINE )) { StringBuilder sb = new StringBuilder( "Sending a request to gather the logs from " ); sb.append( this.scopedInstancePath ); sb.append( " @ " ); sb.append( this.applicationName ); this.logger.fine( sb.toString()); } MsgCmdGatherLogs message = new MsgCmdGatherLogs(); this.manager.messagingMngr().sendMessageSafely( info.getManagedApplication(), inst, message ); } File dumpFile = new File( System.getProperty( "java.io.tmpdir" ), "roboconf-logs" ); this.out.println( "On reception, logs will be stored under " + dumpFile.getAbsolutePath() + "..." ); return null; }  }
GatherLogsCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); for( Instance inst : info.getScopedInstances()) { if( inst.getStatus() == InstanceStatus.NOT_DEPLOYED ) { StringBuilder sb = new StringBuilder( "No message will be sent to " ); sb.append( this.scopedInstancePath ); sb.append( ", the associated agent is not marked as deployed." ); this.out.println( sb.toString()); continue; } if( this.logger.isLoggable( Level.FINE )) { StringBuilder sb = new StringBuilder( "Sending a request to gather the logs from " ); sb.append( this.scopedInstancePath ); sb.append( " @ " ); sb.append( this.applicationName ); this.logger.fine( sb.toString()); } MsgCmdGatherLogs message = new MsgCmdGatherLogs(); this.manager.messagingMngr().sendMessageSafely( info.getManagedApplication(), inst, message ); } File dumpFile = new File( System.getProperty( "java.io.tmpdir" ), "roboconf-logs" ); this.out.println( "On reception, logs will be stored under " + dumpFile.getAbsolutePath() + "..." ); return null; }  @Override Object execute(); }
GatherLogsCommand implements Action { @Override public Object execute() throws Exception { RbcfInfo info = KarafDmCommandsUtils.findInstances( this.manager, this.applicationName, this.scopedInstancePath, this.out ); for( Instance inst : info.getScopedInstances()) { if( inst.getStatus() == InstanceStatus.NOT_DEPLOYED ) { StringBuilder sb = new StringBuilder( "No message will be sent to " ); sb.append( this.scopedInstancePath ); sb.append( ", the associated agent is not marked as deployed." ); this.out.println( sb.toString()); continue; } if( this.logger.isLoggable( Level.FINE )) { StringBuilder sb = new StringBuilder( "Sending a request to gather the logs from " ); sb.append( this.scopedInstancePath ); sb.append( " @ " ); sb.append( this.applicationName ); this.logger.fine( sb.toString()); } MsgCmdGatherLogs message = new MsgCmdGatherLogs(); this.manager.messagingMngr().sendMessageSafely( info.getManagedApplication(), inst, message ); } File dumpFile = new File( System.getProperty( "java.io.tmpdir" ), "roboconf-logs" ); this.out.println( "On reception, logs will be stored under " + dumpFile.getAbsolutePath() + "..." ); return null; }  @Override Object execute();  }