List of usage examples for org.apache.commons.io.input Tailer Tailer
public Tailer(File file, TailerListener listener, long delay, boolean end)
From source file:flens.input.GrepInput.java
public GrepInput(String name, Tagger tagger, String file, String regex, boolean tail) { super(name, tagger); this.file = file; tailer = new Tailer(new File(file), this, delay, tail); this.regex = Pattern.compile(regex); this.tailFromEnd = tail; }
From source file:com.betfair.testing.utils.cougar.manager.LogTailer.java
protected LogTailer(File toRead, long timeForFileToBeCreated) throws IOException { long requiredTime = System.currentTimeMillis() + timeForFileToBeCreated; while ((System.currentTimeMillis() < requiredTime) && !(toRead.exists() && toRead.canRead())) { try {/*from ww w.ja v a 2s . co m*/ Thread.sleep(10); } catch (InterruptedException e) { // ignore } } if (!toRead.exists() || !toRead.canRead()) { throw new IllegalStateException( "Couldn't read " + toRead.getCanonicalPath() + " in the configured timeout"); } logger.debug("Initialising Tailer for " + toRead.getCanonicalPath()); tailer = new Tailer(toRead, this, DELAY, false); }
From source file:io.narayana.nta.LogMonitorBean.java
/** * Starts asynchronously monitoring the logfile which must have been set by invoking the * setFile method. This method is non-blocking and control will be returned immediately to * the invoking method. The method will run continuously until the stop() method is invoked. * * @throws IllegalStateException if setFile has not been previous invoked to set the file to monitor *///from ww w . j a va 2s. co m @Asynchronous public void start() throws IllegalStateException { if (logFile == null) throw new IllegalStateException("setFile must be called before invoking start()"); if (tailer == null) { try { tailer = new Tailer(logFile, logParser, Configuration.LOGFILE_POLL_INTERVAL, end); tailer.disable_reset_file_position(); tailer.run(); } catch (Exception e) { logger.error("Unhandled exception, shutting down...", e); // Not shutting down can cause problems when trying to undeploy the application if the // unhandled exception cannot be recovered from simply catching it, which appears to // be a large majority of cases. The stop method should be invoked through the // containers proxies. sessionContext.getBusinessObject(LogMonitorBean.class).stop(); // Attempt to restart the logger. startupServiceBean.startLogParser(); } } }
From source file:io.github.importre.android.chromeadb.ChromeAdbService.java
private void startTailer() { try {// w w w . j a v a 2 s . c om if (mEventFile.exists()) { mEventFile.delete(); } mEventFile.createNewFile(); } catch (IOException e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); return; } if (mTailer != null) { mTailer.stop(); } mTailer = new Tailer(mEventFile, this, 10, true); Thread thread = new Thread(mTailer); thread.start(); }
From source file:org.jboss.additional.testsuite.jdkall.present.messaging.jms.deployment.PooledCFAvailableOnStartupTestCase.java
@Test public void test() { ServerLogPatternListener listener = new ServerLogPatternListener(Pattern.compile(".*WFLYCTL0030.*")); Tailer serverLogTailer = new Tailer(SERVER_LOG, listener, 100, true); Thread tailerThread = new Thread(serverLogTailer); tailerThread.start();// w w w .j a v a 2s . co m ServerReload.executeReloadAndWaitForCompletion(mc.getControllerClient()); serverLogTailer.stop(); Assert.assertTrue("Server log contains error messages caused by missing resource definitions!", listener.getMatchedLines().isEmpty()); }
From source file:org.syncany.operations.daemon.ControlServer.java
public ControlServer() { this.controlFile = new File(UserConfig.getUserConfigDir(), CONTROL_FILE); this.controlFileTailer = new Tailer(controlFile, this, 1000, true); this.eventBus = LocalEventBus.getInstance(); }
From source file:org.syncany.operations.daemon.DaemonControlServer.java
public DaemonControlServer(DaemonControlListener controlListener) { this.controlFile = new File(UserConfig.getUserConfigDir(), CONTROL_FILE); this.controlFileTailer = new Tailer(controlFile, this, 1000, true); this.controlListener = controlListener; }
From source file:org.wso2.carbon.event.input.adapter.filetail.FileTailEventAdapter.java
private void createFileAdapterListener() { if (log.isDebugEnabled()) { log.debug("New subscriber added for " + eventAdapterConfiguration.getName()); }/* ww w . j a v a 2 s .c om*/ String delayInMillisProperty = eventAdapterConfiguration.getProperties() .get(FileTailEventAdapterConstants.EVENT_ADAPTER_DELAY_MILLIS); int delayInMillis = FileTailEventAdapterConstants.DEFAULT_DELAY_MILLIS; if (delayInMillisProperty != null && (!delayInMillisProperty.trim().isEmpty())) { delayInMillis = Integer.parseInt(delayInMillisProperty); } boolean startFromEnd = false; String startFromEndProperty = eventAdapterConfiguration.getProperties() .get(FileTailEventAdapterConstants.EVENT_ADAPTER_START_FROM_END); if (startFromEndProperty != null && (!startFromEndProperty.trim().isEmpty())) { startFromEnd = Boolean.parseBoolean(startFromEndProperty); } String filePath = eventAdapterConfiguration.getProperties() .get(FileTailEventAdapterConstants.EVENT_ADAPTER_CONF_FILEPATH); FileTailerListener listener = new FileTailerListener(new File(filePath).getName(), eventAdapterListener); Tailer tailer = new Tailer(new File(filePath), listener, delayInMillis, startFromEnd); fileTailerManager = new FileTailerManager(tailer, listener); singleThreadedExecutor.execute(tailer); }