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


Java CurrentTimeEvent类代码示例

本文整理汇总了Java中com.espertech.esper.client.time.CurrentTimeEvent的典型用法代码示例。如果您正苦于以下问题:Java CurrentTimeEvent类的具体用法?Java CurrentTimeEvent怎么用?Java CurrentTimeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CurrentTimeEvent类属于com.espertech.esper.client.time包,在下文中一共展示了CurrentTimeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTimestamp

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
@Test
public void testTimestamp() {
	final Configuration cepConfig = new Configuration();
	cepConfig.addEventType("Event", EapEvent.class.getName());
	final EPServiceProvider cep = EPServiceProviderManager.getProvider("myCEPEngine", cepConfig);
	final EPRuntime cepRT = cep.getEPRuntime();
	final EPAdministrator cepAdm = cep.getEPAdministrator();

	// create statement
	final EPStatement timeStatement = cepAdm.createEPL("select count(*) from Event.win:time(1 hour)");
	timeStatement.addListener(new CEPListener());

	// create events
	final List<EapEvent> ratingEvents = this.createRatingEvents();
	this.sortEventListByDate(ratingEvents);

	// pass events to Esper engine
	for (final EapEvent event : ratingEvents) {
		cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
		// System.out.println(new
		// CurrentTimeEvent(event.getTimestamp().getTime()).toString());
		cepRT.sendEvent(new CurrentTimeEvent(event.getTimestamp().getTime()));
		cepRT.sendEvent(event);
	}
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:26,代码来源:StatementTest.java

示例2: tryAssertion

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void tryAssertion(EPServiceProvider epService) {

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
        SupportUpdateListener listenerOne = new SupportUpdateListener();
        String[] fields = "c0,c1".split(",");
        EPStatement statementOne = epService.getEPAdministrator().createEPL("context NestedContext " +
                "select theString as c0, sum(intPrimitive) as c1 from SupportBean \n" +
                "output last when terminated");
        statementOne.addListener(listenerOne);

        epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
        epService.getEPRuntime().sendEvent(new SupportBean("E2", 2));
        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(10000));
        EPAssertionUtil.assertPropsPerRow(listenerOne.getDataListsFlattened(), fields,
                new Object[][]{{"E1", 1}, {"E2", 2}}, null);
        listenerOne.reset();

        epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
        epService.getEPRuntime().sendEvent(new SupportBean("E3", 4));
        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(20000));
        EPAssertionUtil.assertPropsPerRow(listenerOne.getDataListsFlattened(), fields,
                new Object[][]{{"E1", 3}, {"E3", 4}}, null);

        epService.getEPAdministrator().destroyAllStatements();
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:26,代码来源:ExecContextNested.java

示例3: setUp

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
public void setUp() {
    Configuration configuration = new Configuration();
    configuration.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
    configuration.addEventType("MarketDataEvent", MarketDataEvent.class.getName());

    epService = EPServiceProviderManager.getProvider("TestTicksPerSecondStatement", configuration);
    epService.initialize();
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));

    new TicksPerSecondStatement(epService.getEPAdministrator());
    TicksFalloffStatement stmt = new TicksFalloffStatement(epService.getEPAdministrator());
    listener = new SupportUpdateListener();
    stmt.addListener(listener);

    // Use external clocking for the test
    epService.getEPRuntime().sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:TestTicksFalloffStatement.java

示例4: test1PReceiveFAQ

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
public void test1PReceiveFAQ() throws Exception {
    // send Q + A
    engine.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    engine.getEPRuntime().sendEvent(EventFactory.makeTriviaQuestion("Q1", "What clock never ticks?", "The un-clog", 0), "TriviaQuestion");
    engine.getEPRuntime().sendEvent(EventFactory.makePlayerAnswer("P1", "Q1", "peter pan", System.currentTimeMillis()), "PlayerAnswer");

    // send FA request, assert response
    engine.getEPRuntime().sendEvent(EventFactory.makePlayerFARequest("P2", "Q1"), "PlayerFARequest");

    // send answer
    engine.getEPRuntime().sendEvent(EventFactory.makePlayerAnswer("P2", "Q1", "The un-clog", System.currentTimeMillis()), "PlayerAnswer");

    engine.getEPRuntime().sendEvent(new CurrentTimeEvent(35000));

    engine.getEPRuntime().sendEvent(EventFactory.makeUpdateScore("Q1"), "UpdateScore");
    assertScore("P1", -1);
    assertScore("P2", 1);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:TestTriviaCases.java

示例5: run

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
public void run() {
    long time = 1000;
    long numAdvances = 0;
    try {
        while (latch.get() && (maxNumAdvances == -1 || numAdvances < maxNumAdvances)) {
            epService.getEPRuntime().sendEvent(new CurrentTimeEvent(time));
            numAdvances++;
            time += 1000;
            try {
                Thread.sleep(threadSleepTime);
            } catch (InterruptedException e) {
            }
        }
    } catch (RuntimeException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:ExecMTContextInitiatedTerminatedWithNowParallel.java

示例6: runAssertionMethodAggRateUnbound

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionMethodAggRateUnbound(EPServiceProvider epService) {

        EPServiceProviderIsolated isolated = epService.getEPServiceIsolated("I1");
        isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(0));

        String[] fields = "c0".split(",");
        String epl = "select rate(1, filter:theString like 'A%') as c0 from SupportBean";
        EPStatement stmt = isolated.getEPAdministrator().createEPL(epl, "stmt1", null);
        SupportUpdateListener listener = new SupportUpdateListener();
        stmt.addListener(listener);

        sendEventAssert(isolated, listener, "X1", 0, fields, new Object[]{null});
        sendEventAssert(isolated, listener, "A1", 1, fields, new Object[]{null});

        isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));
        sendEventAssert(isolated, listener, "X2", 2, fields, new Object[]{null});
        sendEventAssert(isolated, listener, "A2", 2, fields, new Object[]{1.0});
        sendEventAssert(isolated, listener, "A3", 3, fields, new Object[]{2.0});

        stmt.destroy();
        isolated.destroy();
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:ExecAggregateFilterNamedParameter.java

示例7: runAssertionWithTime

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionWithTime(EPServiceProvider epService, long startTime, long flipTime) {
    EPServiceProviderIsolated isolated = epService.getEPServiceIsolated("isolated");
    isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(startTime));

    String text = "select * from SupportBean " +
            "match_recognize (" +
            " measures A as a" +
            " pattern (A*)" +
            " interval 10 seconds" +
            ")";

    EPStatement stmt = isolated.getEPAdministrator().createEPL(text, "s0", null);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    isolated.getEPRuntime().sendEvent(new SupportBean("E1", 1));

    isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(flipTime - 1));
    assertFalse(listener.getIsInvokedAndReset());

    isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(flipTime));
    assertTrue(listener.getIsInvokedAndReset());

    isolated.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:26,代码来源:ExecRowRecogIntervalMicrosecondResolution.java

示例8: runAssertionSelfJoin

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionSelfJoin(EPServiceProvider epService) {
    // ESPER-528
    epService.getEPAdministrator().createEPL(EventRepresentationChoice.MAP.getAnnotationText() + " create schema Product (product string, productsize int)");

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    String query =
            " @Hint('reclaim_group_aged=1,reclaim_group_freq=1') select Product.product as product, Product.productsize as productsize from Product unidirectional" +
                    " left outer join Product#time(3 seconds)#groupwin(product,productsize)#size PrevProduct on Product.product=PrevProduct.product and Product.productsize=PrevProduct.productsize" +
                    " having PrevProduct.size<2";
    epService.getEPAdministrator().createEPL(query);

    // Set to larger number of executions and monitor memory
    for (int i = 0; i < 10; i++) {
        sendProductNew(epService, "The id of this product is deliberately very very long so that we can use up more memory per instance of this event sent into Esper " + i, i);
        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(i * 100));
        //if (i % 2000 == 0) {
        //    System.out.println("i=" + i + "; Allocated: " + Runtime.getRuntime().totalMemory() / 1024 / 1024 + "; Free: " + Runtime.getRuntime().freeMemory() / 1024 / 1024);
        //}
    }

    epService.getEPAdministrator().destroyAllStatements();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:ExecViewGroupWin.java

示例9: runAssertionOutputEveryTimePeriod

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionOutputEveryTimePeriod(EPServiceProvider epService) {
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));

    String stmtText = "select symbol from MarketData#keepall output snapshot every 1 day 2 hours 3 minutes 4 seconds 5 milliseconds";
    EPStatement stmt = epService.getEPAdministrator().createEPL(stmtText);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);
    sendMDEvent(epService, "E1", 0);

    long deltaSec = 26 * 60 * 60 + 3 * 60 + 4;
    long deltaMSec = deltaSec * 1000 + 5 + 2000;
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(deltaMSec - 1));
    assertFalse(listener.isInvoked());

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(deltaMSec));
    assertEquals("E1", listener.assertOneGetNewAndReset().get("symbol"));

    stmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:20,代码来源:ExecOutputLimitSimple.java

示例10: runAssertionMeasurePresence

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionMeasurePresence(EPServiceProvider engine, long baseTime, String select, Object value) {

        engine.getEPRuntime().sendEvent(new CurrentTimeEvent(baseTime));
        String epl = "select * from SupportBean  " +
                "match_recognize (" +
                "    measures A as a, A.theString as id, " + select + " as val " +
                "    pattern (A B*) " +
                "    interval 1 minute " +
                "    define " +
                "        A as (A.intPrimitive=1)," +
                "        B as (B.intPrimitive=2))";
        SupportUpdateListener listener = new SupportUpdateListener();
        engine.getEPAdministrator().createEPL(epl).addListener(listener);

        engine.getEPRuntime().sendEvent(new SupportBean("E1", 1));
        engine.getEPRuntime().sendEvent(new SupportBean("E2", 2));

        engine.getEPRuntime().sendEvent(new CurrentTimeSpanEvent(baseTime + 60 * 1000 * 2));
        assertEquals(value, listener.getNewDataListFlattened()[0].get("val"));

        engine.getEPAdministrator().destroyAllStatements();
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:ExecRowRecogClausePresence.java

示例11: runAssertionStartZeroInitiatedNow

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionStartZeroInitiatedNow(EPServiceProvider epService) {
    String[] fieldsOne = "c0,c1".split(",");

    // test start-after with immediate start
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    String contextExpr = "create context CtxPerId start after 0 sec end after 60 sec";
    epService.getEPAdministrator().createEPL(contextExpr);
    EPStatement stream = epService.getEPAdministrator().createEPL("context CtxPerId select theString as c0, intPrimitive as c1 from SupportBean");
    SupportUpdateListener listener = new SupportUpdateListener();
    stream.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fieldsOne, new Object[]{"E1", 1});

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(59999));
    epService.getEPRuntime().sendEvent(new SupportBean("E2", 2));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fieldsOne, new Object[]{"E2", 2});

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(60000));
    epService.getEPRuntime().sendEvent(new SupportBean("E3", 3));
    assertFalse(listener.getAndClearIsInvoked());

    epService.getEPAdministrator().destroyAllStatements();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:ExecContextInitTerm.java

示例12: tryAssertionPatternUniOuterJoinNoOn

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void tryAssertionPatternUniOuterJoinNoOn(EPServiceProvider epService, SupportUpdateListener listener, long startTime) {
    String[] fields = "c0,c1".split(",");
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(startTime + 2000));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[]{null, 1L});

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 10));
    assertFalse(listener.isInvoked());

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(startTime + 3000));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[]{10, 1L});

    epService.getEPRuntime().sendEvent(new SupportBean("E2", 11));

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(startTime + 4000));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[]{21, 2L});

    epService.getEPRuntime().sendEvent(new SupportBean("E3", 12));

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(startTime + 5000));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[]{33, 3L});
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:22,代码来源:ExecJoinUnidirectionalStream.java

示例13: runAssertionExpressionBatch

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionExpressionBatch(EPServiceProvider epService) throws Exception {
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);
    String epl = "@Name('create_var') create variable long ENGINE_TIME;\n" +
            "@Name('engine_time_update') on pattern[every timer:interval(10 seconds)] set ENGINE_TIME = current_timestamp();\n" +
            "@Name('out_null') select window(*) from SupportBean#groupwin(theString)#expr_batch(oldest_timestamp.plus(9 seconds) < ENGINE_TIME);";
    epService.getEPAdministrator().getDeploymentAdmin().parseDeploy(epl);

    SupportUpdateListener listener = new SupportUpdateListener();
    epService.getEPAdministrator().getStatement("out_null").addListener(listener);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(5000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(10000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(11000));

    assertFalse(listener.isInvoked());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:ExecViewGroupWin.java

示例14: run

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
public void run(EPServiceProvider defaultEPService) throws Exception {
    assertNoEngineJMX();

    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.getEngineDefaults().getMetricsReporting().setJmxEngineMetrics(true);
    EPServiceProvider epService = EPServiceProviderManager.getProvider(ENGINE_NAME, configuration);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(DateTime.parseDefaultMSec("2002-05-1T08:00:00.000")));
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

    epService.getEPAdministrator().createEPL("select * from pattern [every a=SupportBean(theString like 'A%') -> b=SupportBean(theString like 'B') where timer:within(a.intPrimitive)]");
    epService.getEPRuntime().sendEvent(new SupportBean("A1", 10));
    epService.getEPRuntime().sendEvent(new SupportBean("A2", 60));

    assertEngineJMX();

    epService.destroy();

    assertNoEngineJMX();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:ExecClientEPServiceProviderMetricsJMX.java

示例15: runAssertionOrAndNotAndZeroStart

import com.espertech.esper.client.time.CurrentTimeEvent; //导入依赖的package包/类
private void runAssertionOrAndNotAndZeroStart(EPServiceProvider epService) {
    epService.getEPAdministrator().getConfiguration().addEventType("A", SupportBean_A.class.getName());
    epService.getEPAdministrator().getConfiguration().addEventType("B", SupportBean_B.class.getName());
    epService.getEPAdministrator().getConfiguration().addEventType("C", SupportBean_C.class.getName());

    tryOrAndNot(epService, "(a=A -> b=B) or (a=A -> not b=B)");
    tryOrAndNot(epService, "a=A -> (b=B or not B)");

    // try zero-time start
    SupportUpdateListener listener = new SupportUpdateListener();
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPAdministrator().createEPL("select * from pattern [timer:interval(0) or every timer:interval(1 min)]").addListenerWithReplay(listener);
    assertTrue(listener.isInvoked());

    epService.getEPAdministrator().destroyAllStatements();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:17,代码来源:ExecPatternOperatorOr.java


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