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


Java EPRuntimeIsolatedSPI类代码示例

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


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

示例1: runAssertionNextScheduledTime

import com.espertech.esper.core.service.EPRuntimeIsolatedSPI; //导入依赖的package包/类
private void runAssertionNextScheduledTime(EPServiceProvider epService) {

        EPRuntimeSPI runtimeSPI = (EPRuntimeSPI) epService.getEPRuntime();

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
        assertNull(epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[0][]);

        EPStatement stmtOne = epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(2 sec)]");
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{stmtOne.getName(), 2000L}});

        EPStatement stmtTwo = epService.getEPAdministrator().createEPL("@Name('s2') select * from pattern[timer:interval(150 msec)]");
        assertEquals(150L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{"s2", 150L}, {stmtOne.getName(), 2000L}});

        stmtTwo.destroy();
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{stmtOne.getName(), 2000L}});

        EPStatement stmtThree = epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(3 sec) and timer:interval(4 sec)]");
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{stmtOne.getName(), 2000L}, {stmtThree.getName(), 3000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2500));
        assertEquals(3000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{stmtThree.getName(), 3000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(3500));
        assertEquals(4000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][]{{stmtThree.getName(), 4000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(4500));
        assertEquals(null, epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[0][]);

        // test isolated service
        EPServiceProviderIsolated isolated = epService.getEPServiceIsolated("I1");
        EPRuntimeIsolatedSPI isolatedSPI = (EPRuntimeIsolatedSPI) isolated.getEPRuntime();

        isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
        assertNull(isolated.getEPRuntime().getNextScheduledTime());
        assertSchedules(isolatedSPI.getStatementNearestSchedules(), new Object[0][]);

        EPStatement stmtFour = isolated.getEPAdministrator().createEPL("select * from pattern[timer:interval(2 sec)]", null, null);
        assertEquals(2000L, (long) isolatedSPI.getNextScheduledTime());
        assertSchedules(isolatedSPI.getStatementNearestSchedules(), new Object[][]{{stmtFour.getName(), 2000L}});

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

示例2: testNextScheduledTime

import com.espertech.esper.core.service.EPRuntimeIsolatedSPI; //导入依赖的package包/类
public void testNextScheduledTime() {

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
        assertNull(epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[0][]);

        EPStatement stmtOne = epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(2 sec)]");
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{stmtOne.getName(), 2000L}});

        EPStatement stmtTwo = epService.getEPAdministrator().createEPL("@Name('s2') select * from pattern[timer:interval(150 msec)]");
        assertEquals(150L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{"s2", 150L}, {stmtOne.getName(), 2000L}});

        stmtTwo.destroy();
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{stmtOne.getName(), 2000L}});

        EPStatement stmtThree = epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(3 sec) and timer:interval(4 sec)]");
        assertEquals(2000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{stmtOne.getName(), 2000L}, {stmtThree.getName(), 3000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2500));
        assertEquals(3000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{stmtThree.getName(), 3000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(3500));
        assertEquals(4000L, (long) epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[][] {{stmtThree.getName(), 4000L}});

        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(4500));
        assertEquals(null, epService.getEPRuntime().getNextScheduledTime());
        assertSchedules(runtimeSPI.getStatementNearestSchedules(), new Object[0][]);
        
        // test isolated service
        EPServiceProviderIsolated isolated = epService.getEPServiceIsolated("I1");
        EPRuntimeIsolatedSPI isolatedSPI = (EPRuntimeIsolatedSPI) isolated.getEPRuntime();

        isolated.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
        assertNull(isolated.getEPRuntime().getNextScheduledTime());
        assertSchedules(isolatedSPI.getStatementNearestSchedules(), new Object[0][]);

        EPStatement stmtFour = isolated.getEPAdministrator().createEPL("select * from pattern[timer:interval(2 sec)]", null, null);
        assertEquals(2000L, (long) isolatedSPI.getNextScheduledTime());
        assertSchedules(isolatedSPI.getStatementNearestSchedules(), new Object[][] {{stmtFour.getName(), 2000L}});
    }
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:47,代码来源:TestTimeControlEvent.java


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