当前位置: 首页>>代码示例>>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;未经允许,请勿转载。