當前位置: 首頁>>代碼示例>>Java>>正文


Java Emitter類代碼示例

本文整理匯總了Java中com.espertech.esper.dataflow.ops.Emitter的典型用法代碼示例。如果您正苦於以下問題:Java Emitter類的具體用法?Java Emitter怎麽用?Java Emitter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Emitter類屬於com.espertech.esper.dataflow.ops包,在下文中一共展示了Emitter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runAssertion

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
private void runAssertion(EPServiceProvider epService, String format, Boolean log, String layout, String title, Boolean linefeed) {
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    String graph = "create dataflow MyConsoleOut\n" +
            "Emitter -> instream<SupportBean>{name : 'e1'}\n" +
            "LogSink(instream) {\n" +
            (format == null ? "" : "  format: '" + format + "',\n") +
            (log == null ? "" : "  log: " + log + ",\n") +
            (layout == null ? "" : "  layout: '" + layout + "',\n") +
            (title == null ? "" : "  title: '" + title + "',\n") +
            (linefeed == null ? "" : "  linefeed: " + linefeed + ",\n") +
            "}";
    EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);

    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyConsoleOut");

    Emitter emitter = instance.startCaptive().getEmitters().get("e1");
    emitter.submit(new SupportBean("E1", 1));

    instance.cancel();
    stmtGraph.destroy();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:23,代碼來源:ExecDataflowOpLogSink.java

示例2: startCaptive

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public synchronized EPDataFlowInstanceCaptive startCaptive() {
    checkExecCompleteState();
    checkExecCancelledState();
    checkExecRunningState();
    setState(EPDataFlowState.RUNNING);

    callOperatorOpen();

    Map<String, Emitter> emitters = new HashMap<String, Emitter>();
    for (Pair<Object, Boolean> operatorStatePair : operators.values()) {
        if (operatorStatePair.getFirst() instanceof Emitter) {
            Emitter emitter = (Emitter) operatorStatePair.getFirst();
            emitters.put(emitter.getName(), emitter);
        }
    }

    return new EPDataFlowInstanceCaptive(emitters, sourceRunnables);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:19,代碼來源:EPDataFlowInstanceImpl.java

示例3: startCaptive

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public synchronized EPDataFlowInstanceCaptive startCaptive() {
    checkExecCompleteState();
    checkExecCancelledState();
    checkExecRunningState();
    setState(EPDataFlowState.RUNNING);

    callOperatorOpen();

    Map<String, Emitter> emitters = new HashMap<String, Emitter>();
    for (Object operator : operators.values()) {
        if (operator instanceof Emitter) {
            Emitter emitter = (Emitter) operator;
            emitters.put(emitter.getName(), emitter);
        }
    }
    
    return new EPDataFlowInstanceCaptive(emitters, sourceRunnables);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:19,代碼來源:EPDataFlowInstanceImpl.java

示例4: runAssertion

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
private void runAssertion(String format, Boolean log, String layout, String title, Boolean linefeed)
{
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);
    
    String graph = "create dataflow MyConsoleOut\n" +
            "Emitter -> instream<SupportBean>{name : 'e1'}\n" +
            "LogSink(instream) {\n" +
            (format == null ? "" : "  format: '" + format + "',\n") +
            (log == null ? "" : "  log: " + log + ",\n") +
            (layout == null ? "" : "  layout: '" + layout + "',\n") +
            (title == null ? "" : "  title: '" + title + "',\n") +
            (linefeed == null ? "" : "  linefeed: " + linefeed + ",\n") +
            "}";
    EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);

    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyConsoleOut");

    Emitter emitter = instance.startCaptive().getEmitters().get("e1");
    emitter.submit(new SupportBean("E1", 1));

    instance.cancel();
    stmtGraph.destroy();
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:24,代碼來源:TestDataFlowOpLogSink.java

示例5: runAssertionIterateFinalMarker

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
private void runAssertionIterateFinalMarker(EPServiceProvider epService) {
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    String graph = "create dataflow MySelect\n" +
            "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
            "@Audit Select(instream_s0 as ALIAS) -> outstream {\n" +
            "  select: (select theString, sum(intPrimitive) as sumInt from ALIAS group by theString order by theString asc),\n" +
            "  iterate: true" +
            "}\n" +
            "CaptureOp(outstream) {}\n";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<>();
    Map<String, Object> operators = CollectionUtil.populateNameValueMap("CaptureOp", capture);

    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
    EPDataFlowInstanceCaptive captive = instance.startCaptive();

    Emitter emitter = captive.getEmitters().get("emitterS0");
    emitter.submit(new SupportBean("E3", 4));
    emitter.submit(new SupportBean("E2", 3));
    emitter.submit(new SupportBean("E1", 1));
    emitter.submit(new SupportBean("E2", 2));
    emitter.submit(new SupportBean("E1", 5));
    assertEquals(0, capture.getCurrent().length);

    emitter.submitSignal(new EPDataFlowSignalFinalMarker() {
    });
    EPAssertionUtil.assertPropsPerRow(capture.getCurrent(), "theString,sumInt".split(","), new Object[][]{{"E1", 6}, {"E2", 5}, {"E3", 4}});

    instance.cancel();
    epService.getEPAdministrator().destroyAllStatements();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:36,代碼來源:ExecDataflowOpSelect.java

示例6: runAssertionSelectPerformance

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
private void runAssertionSelectPerformance(EPServiceProvider epService) throws Exception {
    epService.getEPAdministrator().createEPL("create objectarray schema MyEventOA(p0 string, p1 long)");

    /*
    EPStatement stmt = epService.getEPAdministrator().createEPL("select p0, sum(p1) from MyEvent");

    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000000; i++) {
        epService.getEPRuntime().sendEvent(new Object[] {"E1", 1L}, "MyEvent");
    }
    long end = System.currentTimeMillis();
    System.out.println("delta=" + (end - start) / 1000d);
    System.out.println(stmt.iterator().next().get("sum(p1)"));
    */

    epService.getEPAdministrator().createEPL("create dataflow MyDataFlowOne " +
            "Emitter -> instream<MyEventOA> {name: 'E1'}" +
            "Select(instream as ME) -> astream {select: (select p0, sum(p1) from ME)}");
    EPDataFlowInstance df = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlowOne");
    Emitter emitter = df.startCaptive().getEmitters().get("E1");
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1; i++) {
        emitter.submit(new Object[]{"E1", 1L});
    }
    long end = System.currentTimeMillis();
    //System.out.println("delta=" + (end - start) / 1000d);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:28,代碼來源:ExecDataflowOpSelect.java

示例7: run

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void run(EPServiceProvider epService) throws Exception {
    epService.getEPAdministrator().getConfiguration().addImport(this.getClass().getName());

    String epl = "create dataflow RollingTopWords\n" +
            "create objectarray schema WordEvent (word string),\n" +
            "Emitter -> wordstream<WordEvent> {name:'a'} // Produces word stream\n" +
            "Select(wordstream) -> wordcount { // Sliding time window count per word\n" +
            "  select: (select word, count(*) as wordcount from wordstream#time(30) group by word)\n" +
            "}\n" +
            "Select(wordcount) -> wordranks { // Rank of words\n" +
            "  select: (select window(*) as rankedWords from wordcount#sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
            "}\n" +
            "DefaultSupportCaptureOp(wordranks) {}";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(epl);

    // prepare test
    DefaultSupportCaptureOp capture = new DefaultSupportCaptureOp();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(capture));

    EPDataFlowInstance instanceOne = epService.getEPRuntime().getDataFlowRuntime().instantiate("RollingTopWords", options);
    Emitter emitter = instanceOne.startCaptive().getEmitters().get("a");

    for (String word : new String[]{"this", "is", "a", "test", "that", "is", "a", "word", "test"}) {
        emitter.submit(new Object[]{word});
    }
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
    assertEquals(1, capture.getCurrent().length);
    Map map = (Map) capture.getCurrent()[0];
    Object[][] rows = (Object[][]) map.get("rankedWords");
    EPAssertionUtil.assertPropsPerRow(rows, "word,count".split(","), new Object[][]{{"is", 2L}, {"a", 2L}, {"test", 2L}});

    instanceOne.cancel();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:38,代碼來源:ExecDataflowExampleRollingTopWords.java

示例8: testIterateFinalMarker

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void testIterateFinalMarker() {
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    String graph = "create dataflow MySelect\n" +
            "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
            "@Audit Select(instream_s0 as ALIAS) -> outstream {\n" +
            "  select: (select theString, sum(intPrimitive) as sumInt from ALIAS group by theString order by theString asc),\n" +
            "  iterate: true" +
            "}\n" +
            "CaptureOp(outstream) {}\n";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<Object>();
    Map<String, Object> operators = CollectionUtil.populateNameValueMap("CaptureOp", capture);

    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
    EPDataFlowInstanceCaptive captive = instance.startCaptive();

    Emitter emitter = captive.getEmitters().get("emitterS0");
    emitter.submit(new SupportBean("E3", 4));
    emitter.submit(new SupportBean("E2", 3));
    emitter.submit(new SupportBean("E1", 1));
    emitter.submit(new SupportBean("E2", 2));
    emitter.submit(new SupportBean("E1", 5));
    assertEquals(0, capture.getCurrent().length);

    emitter.submitSignal(new EPDataFlowSignalFinalMarker() {});
    EPAssertionUtil.assertPropsPerRow(capture.getCurrent(), "theString,sumInt".split(","), new Object[][] { {"E1", 6}, {"E2", 5}, {"E3", 4} });

    instance.cancel();
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:34,代碼來源:TestDataFlowOpSelect.java

示例9: testSelectPerformance

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void testSelectPerformance() throws Exception {
    epService.getEPAdministrator().createEPL("create objectarray schema MyEvent(p0 string, p1 long)");

    /*
    EPStatement stmt = epService.getEPAdministrator().createEPL("select p0, sum(p1) from MyEvent");

    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000000; i++) {
        epService.getEPRuntime().sendEvent(new Object[] {"E1", 1L}, "MyEvent");
    }
    long end = System.currentTimeMillis();
    System.out.println("delta=" + (end - start) / 1000d);
    System.out.println(stmt.iterator().next().get("sum(p1)"));
    */

    epService.getEPAdministrator().createEPL("create dataflow MyDataFlowOne " +
            "Emitter -> instream<MyEvent> {name: 'E1'}" +
            "Select(instream as ME) -> astream {select: (select p0, sum(p1) from ME)}");
    EPDataFlowInstance df = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlowOne");
    Emitter emitter = df.startCaptive().getEmitters().get("E1");
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1; i++) {
        emitter.submit(new Object[] {"E1", 1L});
    }
    long end = System.currentTimeMillis();
    //System.out.println("delta=" + (end - start) / 1000d);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:28,代碼來源:TestDataFlowOpSelect.java

示例10: testGraph

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void testGraph() throws Exception {
    String epl = "create dataflow RollingTopWords\n" +
            "create objectarray schema WordEvent (word string),\n" +
            "Emitter -> wordstream<WordEvent> {name:'a'} // Produces word stream\n" +
            "Select(wordstream) -> wordcount { // Sliding time window count per word\n" +
            "  select: (select word, count(*) as wordcount from wordstream.win:time(30) group by word)\n" +
            "}\n" +
            "Select(wordcount) -> wordranks { // Rank of words\n" +
            "  select: (select window(*) as rankedWords from wordcount.ext:sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
            "}\n" +
            "DefaultSupportCaptureOp(wordranks) {}";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(epl);

    // prepare test
    DefaultSupportCaptureOp capture = new DefaultSupportCaptureOp();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(capture));

    EPDataFlowInstance instanceOne = epService.getEPRuntime().getDataFlowRuntime().instantiate("RollingTopWords", options);
    Emitter emitter = instanceOne.startCaptive().getEmitters().get("a");

    for (String word : new String[] {"this", "is", "a", "test", "that", "is", "a", "word", "test"}) {
        emitter.submit(new Object[] {word});
    }
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
    assertEquals(1, capture.getCurrent().length);
    Map map = (Map) capture.getCurrent()[0];
    Object[][] rows = (Object[][]) map.get("rankedWords");
    EPAssertionUtil.assertPropsPerRow(rows, "word,count".split(","), new Object[][]{{"is", 2L}, {"a", 2L}, {"test", 2L}});

    instanceOne.cancel();
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:36,代碼來源:TestExampleRollingTopWords.java

示例11: runAssertionOutputRateLimit

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
private void runAssertionOutputRateLimit(EPServiceProvider epService) {
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    String graph = "create dataflow MySelect\n" +
            "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
            "Select(instream_s0) -> outstream {\n" +
            "  select: (select sum(intPrimitive) as sumInt from instream_s0 output snapshot every 1 minute)\n" +
            "}\n" +
            "CaptureOp(outstream) {}\n";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<>();
    Map<String, Object> operators = CollectionUtil.populateNameValueMap("CaptureOp", capture);

    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
    EPDataFlowInstanceCaptive captive = instance.startCaptive();
    Emitter emitter = captive.getEmitters().get("emitterS0");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(5000));
    emitter.submit(new SupportBean("E1", 5));
    emitter.submit(new SupportBean("E2", 3));
    emitter.submit(new SupportBean("E3", 6));
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(60000 + 5000));
    EPAssertionUtil.assertProps(capture.getCurrentAndReset()[0], "sumInt".split(","), new Object[]{14});

    emitter.submit(new SupportBean("E4", 3));
    emitter.submit(new SupportBean("E5", 6));
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(120000 + 5000));
    EPAssertionUtil.assertProps(capture.getCurrentAndReset()[0], "sumInt".split(","), new Object[]{14 + 9});

    instance.cancel();

    emitter.submit(new SupportBean("E5", 6));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(240000 + 5000));
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPAdministrator().destroyAllStatements();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:45,代碼來源:ExecDataflowOpSelect.java

示例12: run

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void run(EPServiceProvider epService) throws Exception {
    epService.getEPAdministrator().getConfiguration().addImport(DefaultSupportCaptureOp.class.getName());

    String[] fields = "p0,p1".split(",");
    epService.getEPAdministrator().getConfiguration().addEventType("MyOAEventType", fields, new Object[]{String.class, int.class});

    epService.getEPAdministrator().createEPL("create dataflow MyDataFlow " +
            "Emitter -> outstream<MyOAEventType> {name:'src1'}" +
            "DefaultSupportCaptureOp(outstream) {}");

    DefaultSupportCaptureOp<Object> captureOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(captureOp));

    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlow", options);
    EPDataFlowInstanceCaptive captiveStart = instance.startCaptive();
    assertEquals(0, captiveStart.getRunnables().size());
    assertEquals(1, captiveStart.getEmitters().size());
    Emitter emitter = captiveStart.getEmitters().get("src1");
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    emitter.submit(new Object[]{"E1", 10});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][]{{"E1", 10}});

    emitter.submit(new Object[]{"E2", 20});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][]{{"E1", 10}, {"E2", 20}});

    emitter.submitSignal(new EPDataFlowSignalFinalMarker() {
    });
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[0][]);
    EPAssertionUtil.assertPropsPerRow(captureOp.getAndReset().get(0).toArray(), fields, new Object[][]{{"E1", 10}, {"E2", 20}});

    emitter.submit(new Object[]{"E3", 30});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][]{{"E3", 30}});

    // stays running until cancelled (no transition to complete)
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    instance.cancel();
    assertEquals(EPDataFlowState.CANCELLED, instance.getState());

    // test doc sample
    String epl = "create dataflow HelloWorldDataFlow\n" +
            "  create schema SampleSchema(text string),\t// sample type\t\t\n" +
            "\t\n" +
            "  Emitter -> helloworld.stream<SampleSchema> { name: 'myemitter' }\n" +
            "  LogSink(helloworld.stream) {}";
    epService.getEPAdministrator().createEPL(epl);
    epService.getEPRuntime().getDataFlowRuntime().instantiate("HelloWorldDataFlow");
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:51,代碼來源:ExecDataflowAPIStartCaptive.java

示例13: testOutputRateLimit

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void testOutputRateLimit() {
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    String graph = "create dataflow MySelect\n" +
            "Emitter -> instream_s0<SupportBean>{name: 'emitterS0'}\n" +
            "Select(instream_s0) -> outstream {\n" +
            "  select: (select sum(intPrimitive) as sumInt from instream_s0 output snapshot every 1 minute)\n" +
            "}\n" +
            "CaptureOp(outstream) {}\n";
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<Object>();
    Map<String, Object> operators = CollectionUtil.populateNameValueMap("CaptureOp", capture);

    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
    EPDataFlowInstanceCaptive captive = instance.startCaptive();
    Emitter emitter = captive.getEmitters().get("emitterS0");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(5000));
    emitter.submit(new SupportBean("E1", 5));
    emitter.submit(new SupportBean("E2", 3));
    emitter.submit(new SupportBean("E3", 6));
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(60000 + 5000));
    EPAssertionUtil.assertProps(capture.getCurrentAndReset()[0], "sumInt".split(","), new Object[] {14});

    emitter.submit(new SupportBean("E4", 3));
    emitter.submit(new SupportBean("E5", 6));
    assertEquals(0, capture.getCurrentAndReset().length);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(120000 + 5000));
    EPAssertionUtil.assertProps(capture.getCurrentAndReset()[0], "sumInt".split(","), new Object[] {14+9});

    instance.cancel();

    emitter.submit(new SupportBean("E5", 6));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(240000 + 5000));
    assertEquals(0, capture.getCurrentAndReset().length);
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:43,代碼來源:TestDataFlowOpSelect.java

示例14: testStartCaptiveCancel

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
public void testStartCaptiveCancel() throws Exception {
    String[] fields = "p0,p1".split(",");
    epService.getEPAdministrator().getConfiguration().addEventType("MyOAEventType", fields, new Object[] {String.class, int.class});

    epService.getEPAdministrator().createEPL("create dataflow MyDataFlow " +
            "Emitter -> outstream<MyOAEventType> {name:'src1'}" +
            "DefaultSupportCaptureOp(outstream) {}");

    DefaultSupportCaptureOp<Object> captureOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(captureOp));

    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlow", options);
    EPDataFlowInstanceCaptive captiveStart = instance.startCaptive();
    assertEquals(0, captiveStart.getRunnables().size());
    assertEquals(1, captiveStart.getEmitters().size());
    Emitter emitter = captiveStart.getEmitters().get("src1");
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    emitter.submit(new Object[] {"E1", 10});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][] {{"E1", 10}});

    emitter.submit(new Object[] {"E2", 20});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][] {{"E1", 10}, {"E2", 20}});

    emitter.submitSignal(new EPDataFlowSignalFinalMarker(){});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[0][]);
    EPAssertionUtil.assertPropsPerRow(captureOp.getAndReset().get(0).toArray(), fields, new Object[][] {{"E1", 10}, {"E2", 20}});

    emitter.submit(new Object[] {"E3", 30});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][] {{"E3", 30}});

    // stays running until cancelled (no transition to complete)
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    instance.cancel();
    assertEquals(EPDataFlowState.CANCELLED, instance.getState());

    // test doc sample
    String epl = "create dataflow HelloWorldDataFlow\n" +
            "  create schema SampleSchema(text string),\t// sample type\t\t\n" +
            "\t\n" +
            "  Emitter -> helloworld.stream<SampleSchema> { name: 'myemitter' }\n" +
            "  LogSink(helloworld.stream) {}";
    epService.getEPAdministrator().createEPL(epl);
    epService.getEPRuntime().getDataFlowRuntime().instantiate("HelloWorldDataFlow");
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:48,代碼來源:TestAPIStartCaptive.java

示例15: EPDataFlowInstanceCaptive

import com.espertech.esper.dataflow.ops.Emitter; //導入依賴的package包/類
/**
 * Ctor.
 *
 * @param emitters  any emitters that are part of the data flow
 * @param runnables any runnables that represent source operators
 */
public EPDataFlowInstanceCaptive(Map<String, Emitter> emitters, List<GraphSourceRunnable> runnables) {
    this.emitters = emitters;
    this.runnables = runnables;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:11,代碼來源:EPDataFlowInstanceCaptive.java


注:本文中的com.espertech.esper.dataflow.ops.Emitter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。