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


Java EPServiceProvider.initialize方法代码示例

本文整理汇总了Java中com.espertech.esper.client.EPServiceProvider.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java EPServiceProvider.initialize方法的具体用法?Java EPServiceProvider.initialize怎么用?Java EPServiceProvider.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.EPServiceProvider的用法示例。


在下文中一共展示了EPServiceProvider.initialize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void run(EPServiceProvider epService) throws Exception {
    SupportExceptionHandlerFactory.getFactoryContexts().clear();
    SupportExceptionHandlerFactory.getHandlers().clear();
    epService.initialize();

    String epl = "@Name('ABCName') select myinvalidagg() from SupportBean";
    epService.getEPAdministrator().createEPL(epl);

    List<ExceptionHandlerFactoryContext> contexts = SupportExceptionHandlerFactory.getFactoryContexts();
    assertEquals(2, contexts.size());
    assertEquals(epService.getURI(), contexts.get(0).getEngineURI());
    assertEquals(epService.getURI(), contexts.get(1).getEngineURI());

    SupportExceptionHandlerFactory.SupportExceptionHandler handlerOne = SupportExceptionHandlerFactory.getHandlers().get(0);
    SupportExceptionHandlerFactory.SupportExceptionHandler handlerTwo = SupportExceptionHandlerFactory.getHandlers().get(1);
    epService.getEPRuntime().sendEvent(new SupportBean());

    assertEquals(1, handlerOne.getContexts().size());
    assertEquals(1, handlerTwo.getContexts().size());
    ExceptionHandlerContext ehc = handlerOne.getContexts().get(0);
    assertEquals(epService.getURI(), ehc.getEngineURI());
    assertEquals(epl, ehc.getEpl());
    assertEquals("ABCName", ehc.getStatementName());
    assertEquals("Sample exception", ehc.getThrowable().getMessage());
    assertNotNull(ehc.getCurrentEvent());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:ExecClientExceptionHandlerGetCtx.java

示例2: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void run() {

        Configuration configuration = new Configuration();
        configuration.addEventType("PriceLimit", PriceLimit.class.getName());
        configuration.addEventType("StockTick", StockTick.class.getName());

        log.info("Setting up EPL");
        EPServiceProvider epService = EPServiceProviderManager.getProvider(engineURI, configuration);
        epService.initialize();
        new StockTickerMonitor(epService, new StockTickerResultListener());

        log.info("Generating test events: 1 million ticks, ratio 2 hits, 100 stocks");
        StockTickerEventGenerator generator = new StockTickerEventGenerator();
        LinkedList stream = generator.makeEventStream(1000000, 500000, 100, 25, 30, 48, 52, false);
        log.info("Generating " + stream.size() + " events");

        log.info("Sending " + stream.size() + " limit and tick events");
        for (Object theEvent : stream) {
            epService.getEPRuntime().sendEvent(theEvent);

            if (continuousSimulation) {
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    log.debug("Interrupted", e);
                    break;
                }
            }
        }

        log.info("Done.");
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:StockTickerMain.java

示例3: setup

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public EPServiceProvider setup() {

        Configuration config = new Configuration();
        config.getEngineDefaults().getExecution().setPrioritized(true);
        config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
        // using Map-event representations by default
        config.getEngineDefaults().getEventMeta().setDefaultEventRepresentation(EventUnderlyingType.MAP);

        EPServiceProvider engine = EPServiceProviderManager.getDefaultProvider(config);
        engine.initialize();

        // Resolve "trivia.epl" file.
        InputStream inputFile = this.getClass().getClassLoader().getResourceAsStream("trivia.epl");
        if (inputFile == null) {
            inputFile = this.getClass().getClassLoader().getResourceAsStream("etc/trivia.epl");
        }
        if (inputFile == null) {
            throw new RuntimeException("Failed to find file 'trivia.epl' in classpath or relative to classpath");
        }

        try {
            engine.getEPAdministrator().getDeploymentAdmin().readDeploy(inputFile, null, null, null);
        } catch (Exception e) {
            throw new RuntimeException("Error deploying EPL from 'trivia.epl': " + e.getMessage(), e);
        }

        return engine;
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:29,代码来源:TriviaExample.java

示例4: setupEngine

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private static EPServiceProvider setupEngine(String engineURI, TimeUnit timeUnit) {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.getEngineDefaults().getTimeSource().setTimeUnit(timeUnit);
    configuration.getEngineDefaults().getExecution().setAllowIsolatedService(true);
    configuration.getEngineDefaults().getViewResources().setShareViews(false);
    EPServiceProvider epService = EPServiceProviderManager.getProvider(engineURI, configuration);
    epService.initialize();
    return epService;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:10,代码来源:SupportEngineFactory.java

示例5: runAssertionAdapterLoader

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private void runAssertionAdapterLoader() throws Exception {
    SupportPluginLoader.reset();
    // Assure destroy order ESPER-489

    Properties props = new Properties();
    props.put("name", "val");
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addPluginLoader("MyLoader", SupportPluginLoader.class.getName(), props);

    props = new Properties();
    props.put("name2", "val2");
    config.addPluginLoader("MyLoader2", SupportPluginLoader.class.getName(), props);

    EPServiceProvider service = EPServiceProviderManager.getProvider("ExecClientAdapterLoader", config);
    assertEquals(2, SupportPluginLoader.getNames().size());
    assertEquals(2, SupportPluginLoader.getPostInitializes().size());
    assertEquals("MyLoader", SupportPluginLoader.getNames().get(0));
    assertEquals("MyLoader2", SupportPluginLoader.getNames().get(1));
    assertEquals("val", SupportPluginLoader.getProps().get(0).get("name"));
    assertEquals("val2", SupportPluginLoader.getProps().get(1).get("name2"));

    Object loader = service.getContext().getEnvironment().get("plugin-loader/MyLoader");
    assertTrue(loader instanceof SupportPluginLoader);
    loader = service.getContext().getEnvironment().get("plugin-loader/MyLoader2");
    assertTrue(loader instanceof SupportPluginLoader);

    SupportPluginLoader.getPostInitializes().clear();
    SupportPluginLoader.getNames().clear();
    service.initialize();
    assertEquals(2, SupportPluginLoader.getPostInitializes().size());
    assertEquals(2, SupportPluginLoader.getNames().size());

    service.destroy();
    assertEquals(2, SupportPluginLoader.getDestroys().size());
    assertEquals("val2", SupportPluginLoader.getDestroys().get(0).get("name2"));
    assertEquals("val", SupportPluginLoader.getDestroys().get(1).get("name"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:38,代码来源:ExecClientAdapterLoader.java

示例6: checkEPLSyntax

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public static void checkEPLSyntax(String statement) throws EsperBoltException {
    Configuration cepConfig = new Configuration();
    EPServiceProvider service = EPServiceProviderManager.getDefaultProvider(cepConfig);
    service.initialize();
    try {
        service.getEPAdministrator().prepareEPL(statement);
    } catch (EPStatementException e) {
        throw new EsperBoltException(e.getMessage(), e);
    }
    service.destroy();
}
 
开发者ID:miguelantonio,项目名称:storm-esper-bolt,代码行数:12,代码来源:EsperBolt.java

示例7: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void run(String engineURI) {
    log.info("Setting up EPL");

    Configuration config = new Configuration();
    config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);   // external timer for testing
    config.addEventType("OHLCTick", OHLCTick.class);
    config.addPlugInView("examples", "ohlcbarminute", OHLCBarPlugInViewFactory.class.getName());

    EPServiceProvider epService = EPServiceProviderManager.getProvider(engineURI, config);
    epService.initialize();     // Since running in a unit test may use the same engine many times

    // set time as an arbitrary start time
    sendTimer(epService, toTime("9:01:50"));

    Object[][] statements = new Object[][]{
            {"S1", "select * from OHLCTick#groupwin(ticker)#ohlcbarminute(timestamp, price)"},
    };

    for (Object[] statement : statements) {
        String stmtName = (String) statement[0];
        String expression = (String) statement[1];
        log.info("Creating statement: " + expression);
        EPStatement stmt = epService.getEPAdministrator().createEPL(expression, stmtName);

        if (stmtName.equals("S1")) {
            OHLCUpdateListener listener = new OHLCUpdateListener();
            stmt.addListener(listener);
        }
    }

    log.info("Sending test events");

    Object[][] input = new Object[][]{
            {"9:01:51", null},  // lets start simulating at 9:01:51
            {"9:01:52", "IBM", 100.5, "9:01:52"},  // lets have an event arrive on time
            {"9:02:03", "IBM", 100.0, "9:02:03"},
            {"9:02:10", "IBM", 99.0, "9:02:04"},  // lets have an event arrive later; this timer event also triggers a bucket
            {"9:02:20", "IBM", 98.0, "9:02:16"},
            {"9:02:30", "NOC", 11.0, "9:02:30"},
            {"9:02:45", "NOC", 12.0, "9:02:45"},
            {"9:02:55", "NOC", 13.0, "9:02:55"},
            {"9:03:02", "IBM", 101.0, "9:02:58"},   // this event arrives late but counts in the same bucket
            {"9:03:06", "IBM", 109.0, "9:02:59"},   // this event arrives too late: it should be ignored (5 second cutoff time, see view)
            {"9:03:07", "IBM", 103.0, "9:03:00"},   // this event should count for the next bucket
            {"9:03:55", "NOC", 12.5, "9:03:55"},
            {"9:03:58", "NOC", 12.75, "9:03:58"},
            {"9:04:00", "IBM", 104.0, "9:03:59"},
            {"9:04:02", "IBM", 105.0, "9:04:00"},   // next bucket starts with this event
            {"9:04:07", null},   // should complete next bucket even though there is no event arriving
            {"9:04:30", null},   // pretend no events
            {"9:04:59", null},
            {"9:05:00", null},
            {"9:05:10", null},
            {"9:05:15", "IBM", 105.5, "9:05:13"},
            {"9:05:59", null},
            {"9:06:07", null},
    };

    for (int i = 0; i < input.length; i++) {
        String timestampArrival = (String) input[i][0];
        log.info("Sending timer event " + timestampArrival);
        sendTimer(epService, toTime(timestampArrival));

        String ticker = (String) input[i][1];
        if (ticker != null) {
            double price = ((Number) input[i][2]).doubleValue();
            String timestampTick = (String) input[i][3];
            OHLCTick theEvent = new OHLCTick(ticker, price, toTime(timestampTick));

            log.info("Sending event " + theEvent);
            epService.getEPRuntime().sendEvent(theEvent);
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:75,代码来源:OHLCMain.java

示例8: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void run(String engineURI)
{
    log.info("Setting up EPL");

    Configuration config = new Configuration();
    config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);   // external timer for testing
    config.addEventType("OHLCTick", OHLCTick.class);
    config.addPlugInView("examples", "ohlcbarminute", OHLCBarPlugInViewFactory.class.getName());

    EPServiceProvider epService = EPServiceProviderManager.getProvider(engineURI, config);
    epService.initialize();     // Since running in a unit test may use the same engine many times

    // set time as an arbitrary start time
    sendTimer(epService, toTime("9:01:50"));

    Object[][] statements = new Object[][] {
        {"S1",    "select * from OHLCTick.std:groupwin(ticker).examples:ohlcbarminute(timestamp, price)"},
        };

    for (Object[] statement : statements)
    {
        String stmtName = (String) statement[0];
        String expression = (String) statement[1];
        log.info("Creating statement: " + expression);
        EPStatement stmt = epService.getEPAdministrator().createEPL(expression, stmtName);

        if (stmtName.equals("S1"))
        {
            OHLCUpdateListener listener = new OHLCUpdateListener();
            stmt.addListener(listener);
        }
    }

    log.info("Sending test events");

    Object[][] input = new Object[][] {
            {"9:01:51", null},  // lets start simulating at 9:01:51
            {"9:01:52", "IBM", 100.5, "9:01:52"},  // lets have an event arrive on time
            {"9:02:03", "IBM", 100.0, "9:02:03"},
            {"9:02:10", "IBM",  99.0, "9:02:04"},  // lets have an event arrive later; this timer event also triggers a bucket
            {"9:02:20", "IBM",  98.0, "9:02:16"},
            {"9:02:30", "NOC",  11.0, "9:02:30"},
            {"9:02:45", "NOC",  12.0, "9:02:45"},
            {"9:02:55", "NOC",  13.0, "9:02:55"},
            {"9:03:02", "IBM", 101.0, "9:02:58"},   // this event arrives late but counts in the same bucket
            {"9:03:06", "IBM", 109.0, "9:02:59"},   // this event arrives too late: it should be ignored (5 second cutoff time, see view)
            {"9:03:07", "IBM", 103.0, "9:03:00"},   // this event should count for the next bucket
            {"9:03:55", "NOC",  12.5, "9:03:55"},
            {"9:03:58", "NOC",  12.75, "9:03:58"},
            {"9:04:00", "IBM", 104.0, "9:03:59"},
            {"9:04:02", "IBM", 105.0, "9:04:00"},   // next bucket starts with this event
            {"9:04:07", null},   // should complete next bucket even though there is no event arriving
            {"9:04:30", null},   // pretend no events
            {"9:04:59", null},
            {"9:05:00", null},
            {"9:05:10", null},
            {"9:05:15", "IBM", 105.5, "9:05:13"},
            {"9:05:59", null},
            {"9:06:07", null},
    };

    for (int i = 0; i < input.length; i++)
    {
        String timestampArrival = (String) input[i][0];
        log.info("Sending timer event " + timestampArrival);
        sendTimer(epService, toTime(timestampArrival));

        String ticker = (String) input[i][1];
        if (ticker != null)
        {
            double price = ((Number) input[i][2]).doubleValue();
            String timestampTick = (String) input[i][3];
            OHLCTick event = new OHLCTick(ticker, price, toTime(timestampTick));

            log.info("Sending event " + event);
            epService.getEPRuntime().sendEvent(event);
        }
    }
}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:80,代码来源:OHLCMain.java


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