FlumeBuilder { public static EventSink buildSink(Context context, String s) throws FlumeSpecException { try { CommonTree snkTree = parseSink(s); return buildEventSink(context, snkTree, sinkFactory); } catch (RecognitionException re) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", re); throw new FlumeSpecException(re.toString()); } catch (NumberFormatException nfe) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", nfe); throw new FlumeSpecException(nfe.getMessage()); } catch (IllegalArgumentException iae) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", iae); throw new FlumeSpecException(iae.getMessage()); } catch (RuntimeRecognitionException re) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", re); throw new FlumeSpecException(re.getMessage()); } }  static void setSourceFactory(SourceFactory srcFact); static void setSinkFactory(SinkFactory snkFact); static CommonTree parseSink(String s); static CommonTree parseSource(String s); static Pair<EventSource, EventSink> buildNode(Context context, File f); @SuppressWarnings("unchecked") static Map<String, Pair<String, String>> parseConf(Context ctx,
      String s); @SuppressWarnings("unchecked") static Map<String, Pair<EventSource, EventSink>> build(
      Context context, String s); static EventSource buildSource(Context ctx, String s); static EventSink buildSink(Context context, String s); @Deprecated static EventSink buildSink(String s); static String toLine(String name, String src, String snk); static Object buildSimpleArg(CommonTree t); static OutputFormat createFormat(FormatFactory ff, Object o ); static Pair<String, CommonTree> buildKWArg(CommonTree t); static Set<String> getSinkNames(); static Set<String> getDecoratorNames(); static Set<String> getSourceNames();  }
@Test public void testFailover() throws IOException, FlumeSpecException { String multi2 = "< flakeyAppend(.9,1337) console ? counter(\"count\") >"; FlumeBuilder.buildSink(new Context(), multi2); String multi = "< { flakeyAppend(.9,1337) => console } ? counter(\"count\") >"; FlumeBuilder.buildSink(new Context(), multi); }
@Test public void testTerseDeco() throws IOException, FlumeSpecException { String multi2 = "flakeyAppend(.9,1337) console"; FlumeBuilder.buildSink(new Context(), multi2); }
@Test public void testFailoverBad1() throws IOException, FlumeSpecException { try { String multi = "< unpossible ? counter(\"count\") >"; FlumeBuilder.buildSink(new Context(), multi); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testFailoverBad2() throws IOException, FlumeSpecException { try { String multi = "< { flakeyAppend(.9,1337) => console } ? unpossible(\"count\") >"; FlumeBuilder.buildSink(new Context(), multi); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testRollSink() throws FlumeSpecException, RecognitionException { String roll = "roll (200) { null } "; EventSink snk = FlumeBuilder.buildSink(new Context(), roll); assertTrue(snk instanceof RollSink); }
@Test public void testGenCollector() throws FlumeSpecException { EventSink snk = FlumeBuilder.buildSink(LogicalNodeContext.testingContext(), "collector() { customDfsSink(\"file: assertTrue(snk instanceof CollectorSink); }
@Test public void testGenCollectorArgs() throws FlumeSpecException { EventSink snk = FlumeBuilder .buildSink(LogicalNodeContext.testingContext(), "collector(foo=\"bar\") { customDfsSink(\"file: assertTrue(snk instanceof CollectorSink); snk = FlumeBuilder .buildSink(LogicalNodeContext.testingContext(), "collector(3,foo=\"bar\") { customDfsSink(\"file: assertTrue(snk instanceof CollectorSink); snk = FlumeBuilder.buildSink(LogicalNodeContext.testingContext(), "collector(3) { customDfsSink(\"file: assertTrue(snk instanceof CollectorSink); }
@Test public void testConsoleFuncArg() throws FlumeSpecException { EventSink snk = FlumeBuilder.buildSink(LogicalNodeContext.testingContext(), "console(seqfile(\"BZip2Codec\"))"); assertNotNull(snk); }
@Test public void testBadParse() throws FlumeSpecException { try { FlumeBuilder.buildSink(new Context(), "asink [ something bad] "); } catch (Exception e) { System.out.println(e); return; } fail("expected recognition exception"); }
@Test public void testBadLex() throws FlumeSpecException { try { FlumeBuilder.buildSink(new Context(), "#$!@#$!@#$ "); } catch (Exception e) { System.out.println(e); return; } fail("expected recognition exception"); }
@Test public void testBuildConsole() throws IOException, FlumeSpecException { FlumeBuilder.buildSink(new Context(), "console"); }
@Test public void testBuildBadArgs() throws FlumeSpecException { try { FlumeBuilder.buildSink(new Context(), "console(1,2,3,4,5,6)"); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testBuildConsoleBad() { try { FlumeBuilder.buildSink(new Context(), "unpossiblesink"); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testMultiSink() throws IOException, FlumeSpecException { String multi = "[ console , counter(\"count\") ]"; FlumeBuilder.buildSink(new Context(), multi); }
@Test public void testMultiSinkBad() throws IOException, FlumeSpecException { try { String multi = "[ console , unpossiblesink(\"count\") ]"; FlumeBuilder.buildSink(new Context(), multi); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testDecorated() throws IOException, FlumeSpecException { String decorated = "{ intervalSampler(5) => console }"; FlumeBuilder.buildSink(new Context(), decorated); }
@Test public void testDecoratedBad1() throws IOException, FlumeSpecException { try { String decorated = "{ unpossible(5) => console }"; FlumeBuilder.buildSink(new Context(), decorated); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }
@Test public void testDecoratedBad2() throws IOException, FlumeSpecException { try { String decorated = "{ intervalSampler(5) => unpossible }"; FlumeBuilder.buildSink(new Context(), decorated); } catch (FlumeSpecException e) { System.out.println(e); return; } fail("should have thrown exception"); }