@Test public void testCollectLogs() throws Exception { Map<String,byte[]> map = AgentUtils.collectLogs( null ); Assert.assertEquals( 0, map.size()); File karafData = this.folder.newFolder(); map = AgentUtils.collectLogs( karafData.getAbsolutePath()); Assert.assertEquals( 0, map.size()); File karafLog = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/karaf.log" ); Assert.assertTrue( karafLog.getParentFile().mkdir()); Assert.assertTrue( karafLog.createNewFile()); map = AgentUtils.collectLogs( karafData.getAbsolutePath()); Assert.assertEquals( 1, map.size()); Assert.assertTrue( map.containsKey( "karaf.log" )); String[] names = { "roboconf", "roboconf2", "whatever" }; for( String s : names ) { karafLog = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + s + ".log" ); Assert.assertTrue( karafLog.createNewFile()); } map = AgentUtils.collectLogs( karafData.getAbsolutePath()); Assert.assertEquals( 2, map.size()); Assert.assertTrue( map.containsKey( "karaf.log" )); Assert.assertTrue( map.containsKey( "roboconf.log" )); }
public static Map<String,byte[]> collectLogs( String karafData ) throws IOException { Map<String,byte[]> logFiles = new HashMap<>( 2 ); if( ! Utils.isEmptyOrWhitespaces( karafData )) { String[] names = { "karaf.log", "roboconf.log" }; for( String name : names ) { File log = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + name ); if( ! log.exists()) continue; String content = Utils.readFileContent( log ); logFiles.put( name, content.getBytes( StandardCharsets.UTF_8 )); } } return logFiles; }
AgentUtils { public static Map<String,byte[]> collectLogs( String karafData ) throws IOException { Map<String,byte[]> logFiles = new HashMap<>( 2 ); if( ! Utils.isEmptyOrWhitespaces( karafData )) { String[] names = { "karaf.log", "roboconf.log" }; for( String name : names ) { File log = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + name ); if( ! log.exists()) continue; String content = Utils.readFileContent( log ); logFiles.put( name, content.getBytes( StandardCharsets.UTF_8 )); } } return logFiles; } }
AgentUtils { public static Map<String,byte[]> collectLogs( String karafData ) throws IOException { Map<String,byte[]> logFiles = new HashMap<>( 2 ); if( ! Utils.isEmptyOrWhitespaces( karafData )) { String[] names = { "karaf.log", "roboconf.log" }; for( String name : names ) { File log = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + name ); if( ! log.exists()) continue; String content = Utils.readFileContent( log ); logFiles.put( name, content.getBytes( StandardCharsets.UTF_8 )); } } return logFiles; } private  AgentUtils(); }
AgentUtils { public static Map<String,byte[]> collectLogs( String karafData ) throws IOException { Map<String,byte[]> logFiles = new HashMap<>( 2 ); if( ! Utils.isEmptyOrWhitespaces( karafData )) { String[] names = { "karaf.log", "roboconf.log" }; for( String name : names ) { File log = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + name ); if( ! log.exists()) continue; String content = Utils.readFileContent( log ); logFiles.put( name, content.getBytes( StandardCharsets.UTF_8 )); } } return logFiles; } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); }
AgentUtils { public static Map<String,byte[]> collectLogs( String karafData ) throws IOException { Map<String,byte[]> logFiles = new HashMap<>( 2 ); if( ! Utils.isEmptyOrWhitespaces( karafData )) { String[] names = { "karaf.log", "roboconf.log" }; for( String name : names ) { File log = new File( karafData, AgentConstants.KARAF_LOGS_DIRECTORY + "/" + name ); if( ! log.exists()) continue; String content = Utils.readFileContent( log ); logFiles.put( name, content.getBytes( StandardCharsets.UTF_8 )); } } return logFiles; } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); static final String INJECTED_CONFIGS_DIR; }