TailDirSource extends EventSource.Base { public static SourceBuilder builder() { return new SourceBuilder() { @Override public EventSource build(Context ctx, String... argv) { Preconditions .checkArgument(argv.length >= 1 && argv.length <= 4, USAGE); String regex = ".*"; if (argv.length >= 2) { regex = argv[1]; } boolean startFromEnd = false; if (argv.length >= 3) { startFromEnd = Boolean.parseBoolean(argv[2]); } int recurseDepth = 0; if (argv.length >= 4) { recurseDepth = Integer.parseInt(argv[3]); Preconditions.checkArgument(recurseDepth >= 0, "\"recurseDepth\" should be >= 0, but was: " + recurseDepth + ".\n" + USAGE); } Pair<String, DelimMode> mode = TailSource.extractDelimContext(ctx); if (mode != null) { return new TailDirSource(new File(argv[0]), regex, startFromEnd, recurseDepth, mode.getLeft(), mode.getRight()); } return new TailDirSource(new File(argv[0]), regex, startFromEnd, recurseDepth); } }; } TailDirSource(File f, String regex);  TailDirSource(File f, String regex, boolean startFromEnd);  TailDirSource(File f, String regex, boolean startFromEnd,
      int recurseDepth);  TailDirSource(File f, String regex, boolean startFromEnd,
      int recurseDepth, String delimRegex, DelimMode delimMode); @Override synchronized void open(); @Override synchronized void close(); @Override synchronized ReportEvent getMetrics(); @Override Event next(); static SourceBuilder builder(); static final Logger LOG; static final String USAGE; final static String A_FILESADDED; final static String A_FILESDELETED; final static String A_FILESPRESENT; final static String A_SUBDIRSADDED; final static String A_SUBDIRSDELETED; }
@Test public void testBuilder() throws IOException, FlumeSpecException { File tmpdir = FileUtil.mktempdir(); String src = "tailDir(\"" + StringEscapeUtils.escapeJava(tmpdir.getAbsolutePath()) + "\", \"foo.*\""; Context ctx = LogicalNodeContext.testingContext(); FlumeBuilder.buildSource(ctx, src + ")"); FlumeBuilder.buildSource(ctx, src + ", true)"); FlumeBuilder.buildSource(ctx, src + ", false)"); FlumeBuilder.buildSource(ctx, src + ", true,2)"); FileUtil.rmr(tmpdir); }