private InputStream createInputStream(FileInfo info) throws IOException { if (info.getLocalFile().endsWith("gz")) { return new GZIPInputStream(new FileInputStream(new File(info.getLocalFile()))); } else { return new FileInputStream(new File(info.getLocalFile())); } }
private void importFiles(List<FileInfo> infos) { for (FileInfo info : infos) { try { LOGGER.info("Importing log " + info.getLocalFile() + " from host " + info.getHostName()); this.importer.importLogInBatchMode( new OriginLogFile( new OriginHost(info.getHostName(), "127.0.0.1"), info.getRemoteFile()), new Log4jLogParser(createInputStream(info))); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }
private void ensureLocalParentFoldersExist(List<FileInfo> infos) { for (FileInfo info : infos) { new File(info.getLocalFile()).getParentFile().mkdirs(); } }