当前位置: 首页>>代码示例>>Java>>正文


Java Tailer.create方法代码示例

本文整理汇总了Java中org.apache.commons.io.input.Tailer.create方法的典型用法代码示例。如果您正苦于以下问题:Java Tailer.create方法的具体用法?Java Tailer.create怎么用?Java Tailer.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.input.Tailer的用法示例。


在下文中一共展示了Tailer.create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startTailingFile

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
/**
 * Starts tailing the given file, thus updating the log lines in the table.
 *
 * @param file
 *         the file to tail
 *
 * @throws FileNotFoundException
 *         if the file was not found
 */
public void startTailingFile(File file) throws FileNotFoundException {
    if (!file.exists()) {
        throw new FileNotFoundException(file.getAbsolutePath());
    }
    closeCurrentFile();
    config.getState().addToRecentFiles(file.getAbsolutePath());
    logTailListener = new BufferedLogTailListener(columnizer.getValue(), columnizedLogs,
            config.getPreferences().getLogBufferSize());
    logTailListener.skipEmptyLogsProperty().bind(config.getPreferences().skipEmptyLogsProperty());
    logTailListener.limitNumberOfLogsProperty().bind(config.getPreferences().limitNumberOfLogsProperty());
    logTailListener.maxNumberOfLogsProperty().bind(config.getPreferences().maxNumberOfLogsProperty());
    tailer = Tailer.create(file, logTailListener, config.getPreferences().getTailingDelayInMillis());
    tailingFile.set(true);
    tailedFileName.set(file.getAbsolutePath());
}
 
开发者ID:joffrey-bion,项目名称:fx-log,代码行数:25,代码来源:MainController.java

示例2: CsvStreamReader

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
/**
 * Creates a CsvStreamReader with supplied separator and quote char.
 *
 * @param source The file to an underlying CSV source
 * @param separator The delimiter to use for separating entries
 * @param quoteChar The character to use for quoted elements
 * @param escape The character to use for escaping a separator or quote
 * @param line The line number to skip for start reading
 * @param strictQuotes Sets if characters outside the quotes are ignored
 * @param ignoreLeadingWhiteSpace If true, parser should ignore
 *  white space before a quote in a field
 */
private CsvStreamReader(Source source, char separator, char quoteChar,
    char escape, int line, boolean strictQuotes,
    boolean ignoreLeadingWhiteSpace) {
  super(new StringReader("")); // dummy call to base constructor
  contentQueue = new ArrayDeque<>();
  TailerListener listener = new CsvContentListener(contentQueue);
  tailer = Tailer.create(source.file(), listener, DEFAULT_MONITOR_DELAY,
      false, true, 4096);
  this.parser = new CSVParser(separator, quoteChar, escape, strictQuotes,
      ignoreLeadingWhiteSpace);
  this.skipLines = line;
  try {
    // wait for tailer to capture data
    Thread.sleep(DEFAULT_MONITOR_DELAY);
  } catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:CsvStreamReader.java

示例3: testShouldBeCallListenerHandleByLogging

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
@Test
public void testShouldBeCallListenerHandleByLogging() throws Exception {
    Tailer.create(TestFileLoader.load("data/tailer/test.log"), listener, 100, true);

    ConcurrentTestFileWriter.writeTestData("data/tailer/test.log", "logging", 3);

    Thread.sleep(300);
    verify(mockCollector, times(3)).collect(anyString());
}
 
开发者ID:geminiKim,项目名称:logregator,代码行数:10,代码来源:TailCollectorCollectorTest.java

示例4: open

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public void open(Map stormConf) {
  fileToParseName = fileToParse.getAbsolutePath();
  parsedLineQueue = new LinkedBlockingQueue<Map>(maxQueueSize);
  currentLine = 0;

  if (lineParser == null)
    lineParser = new NoOpLogLineParser();

  tailer = Tailer.create(fileToParse, this, tailerDelayMs);
  log.info("Started tailing "+fileToParseName);
}
 
开发者ID:lucidworks,项目名称:storm-solr,代码行数:12,代码来源:FileTailingDataProvider.java

示例5: tail

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public void tail(TailerListener listener) {

        File file = new File(
                             fileLocation);
        Tailer tailer = Tailer.create(file, listener, 10);

        tailer.run();
    }
 
开发者ID:aol,项目名称:micro-server,代码行数:9,代码来源:LogTailer.java

示例6: setLogFile

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public void setLogFile(String pathname) {
	logFile = new File(pathname);
	
	tailerListener = new TailerListener();
	tailer = Tailer.create(logFile, tailerListener, 450, false);
	
	Thread thread = new Thread(tailer);
	thread.setDaemon(true);
	thread.start();
	
	if (logFile.exists() == false){
		logger.warn("Coud not open log file: " + pathname);
	}
}
 
开发者ID:leonardsaers,项目名称:ponytail,代码行数:15,代码来源:Logfile.java

示例7: setupTailer

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
private void setupTailer() {
	TailerListener listener = new LogTailer();
	File tailFile = new File(DebugLogger.LOGGING_FILENAME);
	tailer = Tailer.create(tailFile, new LogTailer(), 500, true);
}
 
开发者ID:Mgamerz,项目名称:me3modmanager,代码行数:6,代码来源:LogWindow.java

示例8: start

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public void start() {
    if (tailer == null) {
        tailer = Tailer.create(getLogsFile(), this, 500L, true);
        LOG.info("Logs watcher started. File {} will be tracked for changes.", configurationMediator.getLogFileName());
    }
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:7,代码来源:LogsWatcherService.java

示例9: test

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public static void test(final TestParams testParams) throws IOException, ClassNotFoundException,
    NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {

  final File tempFile = File.createTempFile("test", "test");
  final File labelFile = File.createTempFile("result", "result");
  LOG.info("Starting test, output file is {}, test config is \n{}", tempFile.getAbsolutePath(), testParams.toString());  
  Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      try {          
        Class.forName(testParams.getTaskClassName())
              .getMethod("main", String[].class)
              .invoke(null, (Object) String.format(
                  testParams.getCliStringTemplate(),
                  tempFile.getAbsolutePath(),
                  testParams.getInputInstances(),
                  testParams.getSamplingSize(),
                  testParams.getInputDelayMicroSec(),
                  labelFile.getAbsolutePath(),
                  testParams.getLabelSamplingSize()
                  ).split("[ ]"));
        } catch (Exception e) {
          LOG.error("Cannot execute test {} {}", e.getMessage(), e.getCause().getMessage());
        }
        return null;
      }
    });

  Thread.sleep(TimeUnit.SECONDS.toMillis(testParams.getPrePollWaitSeconds()));

  CountDownLatch signalComplete = new CountDownLatch(1);

  final Tailer tailer = Tailer.create(tempFile, new TestResultsTailerAdapter(signalComplete), 1000);
  new Thread(new Runnable() {
    @Override
    public void run() {
      tailer.run();
    }
  }).start();

  signalComplete.await();
  tailer.stop();

  assertResults(tempFile, testParams);
  if (testParams.getLabelFileCreated())
    assertLabels(labelFile, testParams);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:48,代码来源:TestUtils.java

示例10: start

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public void start ()  {
	OutputFileListener listener = new OutputFileListener(this);
	tailer = Tailer.create(fileToTail, listener, 500);
}
 
开发者ID:MesquiteProject,项目名称:MesquiteCore,代码行数:5,代码来源:OutputFileTailer.java

示例11: test

import org.apache.commons.io.input.Tailer; //导入方法依赖的package包/类
public static void test(final TestParams testParams) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {

        final File tempFile = File.createTempFile("test", "test");

        LOG.info("Starting test, output file is {}, test config is \n{}", tempFile.getAbsolutePath(), testParams.toString());

        Executors.newSingleThreadExecutor().submit(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                try {
                    Class.forName(testParams.getTaskClassName())
                            .getMethod("main", String[].class)
                            .invoke(null, (Object) String.format(
                                    testParams.getCliStringTemplate(),
                                    tempFile.getAbsolutePath(),
                                    testParams.getInputInstances(),
                                    testParams.getSamplingSize(),
                                    testParams.getInputDelayMicroSec()
                                    ).split("[ ]"));
                } catch (Exception e) {
                    LOG.error("Cannot execute test {} {}", e.getMessage(), e.getCause().getMessage());
                }
                return null;
            }
        });

        Thread.sleep(TimeUnit.SECONDS.toMillis(testParams.getPrePollWaitSeconds()));

        CountDownLatch signalComplete = new CountDownLatch(1);

        final Tailer tailer = Tailer.create(tempFile, new TestResultsTailerAdapter(signalComplete), 1000);
        new Thread(new Runnable() {
            @Override
            public void run() {
                tailer.run();
            }
        }).start();

        signalComplete.await();
        tailer.stop();

        assertResults(tempFile, testParams);
    }
 
开发者ID:YahooArchive,项目名称:samoa,代码行数:45,代码来源:TestUtils.java


注:本文中的org.apache.commons.io.input.Tailer.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。