List of usage examples for org.apache.commons.io.input Tailer Tailer
public Tailer(File file, TailerListener listener)
From source file:de.slackspace.wfail2ban.logfile.impl.ContinuousLogfileReader.java
@Override protected void doParsing(Filter filter, FilterResultHandler callback) { TailerListener listener = new ContinuousTailerListener(filter, callback); Tailer tailer = new Tailer(new File(filter.getLogfilePath()), listener); ExecutorService executor = Executors.newFixedThreadPool(1); executor.submit(tailer);//ww w . j av a 2s.c o m }
From source file:org.apache.karaf.decanter.collector.file.DecanterTailerListener.java
@SuppressWarnings("unchecked") @Activate/* ww w. j av a 2 s .c o m*/ public void activate(ComponentContext context) throws ConfigurationException { properties = context.getProperties(); if (properties.get("type") == null) { throw new ConfigurationException("type", "type property is mandatory"); } String type = (String) properties.get("type"); if (properties.get("path") == null) { throw new ConfigurationException("path", "path property is mandatory"); } String path = (String) properties.get("path"); LOGGER.debug("Starting tail on {}", path); tailer = new Tailer(new File(path), this); Thread thread = new Thread(tailer, "Log Tailer for " + path); thread.start(); this.type = type; this.path = path; }
From source file:org.wso2.carbon.event.input.adaptor.file.FileEventAdaptorType.java
private void createFileAdaptorListener( InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorListener inputEventAdaptorListener, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId) {/* w w w . j a v a2s . com*/ log.info("New subscriber added for " + inputEventAdaptorConfiguration.getName()); ConcurrentHashMap<String, FileTailerManager> tailerManagerConcurrentHashMap = tailerMap .get(inputEventAdaptorConfiguration.getName()); if (tailerManagerConcurrentHashMap == null) { tailerManagerConcurrentHashMap = new ConcurrentHashMap<String, FileTailerManager>(); if (null != tailerMap.putIfAbsent(inputEventAdaptorConfiguration.getName(), tailerManagerConcurrentHashMap)) { tailerManagerConcurrentHashMap = tailerMap.get(inputEventAdaptorConfiguration.getName()); } } String filepath = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(FileEventAdaptorConstants.EVENT_ADAPTOR_CONF_FILEPATH); FileTailerManager fileTailerManager = tailerManagerConcurrentHashMap.get(filepath); if (fileTailerManager == null) { FileTailerListener listener = new FileTailerListener(new File(filepath).getName()); Tailer tailer = new Tailer(new File(filepath), listener); fileTailerManager = new FileTailerManager(tailer, listener); listener.addListener(subscriptionId, inputEventAdaptorListener); tailerManagerConcurrentHashMap.put(filepath, fileTailerManager); threadPoolExecutor.execute(tailer); } else { fileTailerManager.getListener().addListener(subscriptionId, inputEventAdaptorListener); } }