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


Java EPServiceProvider.destroy方法代码示例

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


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

示例1: testAlert

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void testAlert() throws Exception {
    CycleDetectMain main = new CycleDetectMain();

    EPServiceProvider engine = main.getEngine();
    SupportUpdateListener listener = new SupportUpdateListener();
    engine.getEPAdministrator().getStatement("CycleDetector").addListener(listener);

    engine.getEPRuntime().sendEvent(new TransactionEvent("A", "B", 100));
    engine.getEPRuntime().sendEvent(new TransactionEvent("D", "A", 50));
    engine.getEPRuntime().sendEvent(new TransactionEvent("B", "C", 100));
    engine.getEPRuntime().sendEvent(new TransactionEvent("G", "H", 60));
    assertFalse(listener.isInvoked());

    engine.getEPRuntime().sendEvent(new TransactionEvent("C", "D", 30));
    Collection vertices = (Collection) listener.assertOneGetNewAndReset().get("out");
    EPAssertionUtil.assertEqualsAnyOrder(vertices.toArray(), new Object[]{"A", "B", "C", "D"});

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

示例2: runAssertionIteratorMultiStmtNoViewShare

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private void runAssertionIteratorMultiStmtNoViewShare() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.getEngineDefaults().getViewResources().setShareViews(false);
    EPServiceProvider engine = EPServiceProviderManager.getProvider(ExecMTStmtIterate.class.getSimpleName(), config);

    EPStatement[] stmt = new EPStatement[3];
    for (int i = 0; i < stmt.length; i++) {
        String name = "Stmt_" + i;
        String stmtText = "@Name('" + name + "') select theString from " + SupportBean.class.getName() + "#time(5 min)";
        stmt[i] = engine.getEPAdministrator().createEPL(stmtText);
    }

    trySend(engine, 4, 10, stmt);

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

示例3: runAssertionIteratorMultiStmtViewShare

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private void runAssertionIteratorMultiStmtViewShare() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.getEngineDefaults().getViewResources().setShareViews(true);
    EPServiceProvider engine = EPServiceProviderManager.getProvider(ExecMTStmtIterate.class.getSimpleName(), config);

    EPStatement[] stmt = new EPStatement[3];
    for (int i = 0; i < stmt.length; i++) {
        String name = "Stmt_" + i;
        String stmtText = "@Name('" + name + "') select theString from " + SupportBean.class.getName() + "#time(5 min)";
        stmt[i] = engine.getEPAdministrator().createEPL(stmtText);
    }

    trySend(engine, 4, 10, stmt);

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

示例4: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的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

示例5: testOutput

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void testOutput() {
    Properties adapterProps = SupportConstants.getOutputPluginProps();

    adapterProps.put(EsperIOKafkaConfig.TOPICS_CONFIG, DEV_OUTPUT_TOPIC_JSON);
    adapterProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class.getName());
    adapterProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class.getName());
    adapterProps.put(EsperIOKafkaConfig.OUTPUT_FLOWCONTROLLER_CONFIG, EsperIOKafkaOutputFlowControllerByAnnotatedStmt.class.getName());
    EPServiceProvider epService = SupportConstants.getEngineWKafkaOutput(this.getClass().getSimpleName(), adapterProps);
    epService.getEPAdministrator().getConfiguration().addEventType("SupportBean", SupportBean.class);

    // create statement
    EPStatement statement = epService.getEPAdministrator().createEPL("@name('first') @KafkaOutputDefault select * from SupportBean");

    // get consumer for asserting message
    KafkaConsumer<String, String> consumer = initConsumer();
    Collection<TopicPartition> topicPartitions = Collections.singletonList(new TopicPartition(DEV_OUTPUT_TOPIC_JSON, 0));
    consumer.assign(topicPartitions);
    int numMessages = countMessages(topicPartitions, consumer);
    consumer.seek(topicPartitions.iterator().next(), 0);

    // send-and-await two events
    sendAndAwait(epService, consumer, "E1");
    sendAndAwait(epService, consumer, "E2");

    // destroy and check nothing received
    int numMessagesAfter = countMessages(topicPartitions, consumer);
    statement.destroy();
    epService.getEPRuntime().sendEvent(new SupportBean("XXX", -1));
    assertEquals(2, numMessagesAfter - numMessages);

    // create second statement
    epService.getEPAdministrator().createEPL("@name('second') @KafkaOutputDefault select stringProp from SupportBean");

    // send-and-await another event
    sendAndAwait(epService, consumer, "E3");

    // destroy engine
    epService.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:40,代码来源:TestKafkaOutput.java

示例6: testInput

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void testInput() {
    Properties pluginProperties = SupportConstants.getInputPluginProps(TOPIC, SupportBeanFromStringDeserializer.class.getName(), null);

    EPServiceProvider epService = SupportConstants.getEngineWKafkaInput(this.getClass().getSimpleName(), pluginProperties);
    epService.getEPAdministrator().getConfiguration().addEventType("SupportBean", SupportBean.class);

    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from SupportBean");
    SupportListener listener = new SupportListener();
    stmt.addListener(listener);

    Properties producerProperties = SupportConstants.getProducerProps(org.apache.kafka.common.serialization.StringSerializer.class.getName());
    KafkaProducer<String, String> producer = new KafkaProducer<>(producerProperties);

    // send 10 messages
    for (int i = 0; i < 10; i++) {
        String generatedUUID = UUID.randomUUID().toString();
        producer.send(new ProducerRecord<>(TOPIC, generatedUUID));

        SupportAwaitUtil.awaitOrFail(10, TimeUnit.SECONDS, "failed to receive expected event", (Supplier<Object>) () -> {
            for (EventBean[] events : listener.getEvents()) {
                for (EventBean event : events) {
                    SupportBean bean = (SupportBean) event.getUnderlying();
                    if (bean.getStringProp().equals(generatedUUID)) {
                        return true;
                    }
                }
            }
            return null;
        });
    }

    producer.close();
    epService.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:35,代码来源:TestKafkaInputNoTimestampStringValue.java

示例7: testInput

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

        Properties pluginProperties = SupportConstants.getInputPluginProps(TOPIC, SupportBeanFromByteArrayDeserializer.class.getName(), EsperIOKafkaInputTimestampExtractorConsumerRecord.class.getName());

        EPServiceProvider epService = SupportConstants.getEngineWKafkaInput(this.getClass().getSimpleName(), pluginProperties);
        epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);
        epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));

        EPStatement stmt = epService.getEPAdministrator().createEPL("select * from SupportBean");
        SupportListener listener = new SupportListener();
        stmt.addListener(listener);

        // send single message with Java serialization (Java serialization is used for testing here and may not be the best choice)
        Properties producerProperties = SupportConstants.getProducerProps(org.apache.kafka.common.serialization.ByteArraySerializer.class.getName());
        KafkaProducer<String, byte[]> producer = new KafkaProducer<>(producerProperties);
        String generatedUUID = UUID.randomUUID().toString();
        int randomNumber = (int) (Math.random() * 100000000);
        long timestamp = 100000;
        byte[] serializedEvent = SerializerUtil.objectToByteArr(new SupportBean(generatedUUID, randomNumber));
        producer.send(new ProducerRecord<>(TOPIC, 0, timestamp, "key", serializedEvent));

        SupportAwaitUtil.awaitOrFail(10, TimeUnit.SECONDS, "failed to receive expected event", (Supplier<Object>) () -> {
            for (EventBean[] events : listener.getEvents()) {
                for (EventBean event : events) {
                    SupportBean bean = (SupportBean) event.getUnderlying();
                    if (bean.getStringProp().equals(generatedUUID) && bean.getIntProp() == randomNumber) {
                        return true;
                    }
                }
            }
            return null;
        });

        assertEquals(timestamp, epService.getEPRuntime().getCurrentTime());

        producer.close();
        epService.destroy();
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:39,代码来源:TestKafkaInputMsgTimestampBeanSerValue.java

示例8: testInput

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

        Properties pluginProperties = SupportConstants.getInputPluginProps(TOPIC, ByteArrayDeserializer.class.getName(), null);
        pluginProperties.put(EsperIOKafkaConfig.INPUT_PROCESSOR_CONFIG, SupportInputCustomProcessor.class.getName());

        EPServiceProvider epService = SupportConstants.getEngineWKafkaInput(this.getClass().getSimpleName(), pluginProperties);
        epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);

        EPStatement stmt = epService.getEPAdministrator().createEPL("select * from SupportBean");
        SupportListener listener = new SupportListener();
        stmt.addListener(listener);

        Properties producerProperties = SupportConstants.getProducerProps(org.apache.kafka.common.serialization.ByteArraySerializer.class.getName());
        KafkaProducer<String, byte[]> producer = new KafkaProducer<>(producerProperties);
        int randomNumber = (int) (Math.random() * 100000000);
        byte[] bytes = ByteBuffer.allocate(4).putInt(randomNumber).array();
        producer.send(new ProducerRecord<>(TOPIC, bytes));

        SupportAwaitUtil.awaitOrFail(10, TimeUnit.SECONDS, "failed to receive expected event", (Supplier<Object>) () -> {
            for (EventBean[] events : listener.getEvents()) {
                for (EventBean event : events) {
                    SupportBean bean = (SupportBean) event.getUnderlying();
                    if (bean.getIntProp() == randomNumber) {
                        return true;
                    }
                }
            }
            return null;
        });

        producer.close();
        epService.destroy();

        assertTrue(SupportInputCustomProcessor.isClosed());
        assertNotNull(SupportInputCustomProcessor.getContext().getAdapter());
        assertNotNull(SupportInputCustomProcessor.getContext().getEngine());
        assertNotNull(SupportInputCustomProcessor.getContext().getProperties());
        assertNotNull(SupportInputCustomProcessor.getContext().getConsumer());
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:40,代码来源:TestKafkaInputCustomSubscriberAndProcessor.java

示例9: run

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

    // parse test data
    List<Round> rounds = parse(TESTDATA);

    // loop through the rounds
    for (int i = 0; i < rounds.size(); i++) {
        Round round = rounds.get(i);
        System.out.println("\n\nRound " + i);
        System.out.println("============");
        System.out.println(round);

        // set time
        setTime(engine, round.getTime());

        // send question event
        engine.getEPRuntime().sendEvent(round.getQuestion(), "TriviaQuestion");

        // send player activity
        for (PlayerAction action : round.getPlayerActions()) {
            engine.getEPRuntime().sendEvent(action.getData(), action.getEventName());
        }

        // trigger score update
        engine.getEPRuntime().sendEvent(EventFactory.makeUpdateScore(round.getQuestionId()), "UpdateScore");

        printScore(round.getQuestionId(), TriviaHelper.getScores(engine));
    }

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

示例10: run

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void run() {
    // load config - this defines the XML event types to be processed
    String configFile = "esper.examples.cfg.xml";
    URL url = AutoIdSimMain.class.getClassLoader().getResource(configFile);
    if (url == null) {
        log.error("Error loading configuration file '" + configFile + "' from classpath");
        return;
    }
    Configuration config = new Configuration();
    config.configure(url);

    // get engine instance
    EPServiceProvider epService = EPServiceProviderManager.getProvider(engineURI, config);

    // set up statement
    RFIDTagsPerSensorStmt rfidStmt = new RFIDTagsPerSensorStmt(epService.getEPAdministrator());
    rfidStmt.addListener(new RFIDTagsPerSensorListener());

    // Send events
    if (!continuousSimulation) {
        int eventCount = 0;
        while (eventCount < numEvents) {
            sendEvent(epService.getEPRuntime());
            eventCount++;
        }
    } else {
        while (true) {
            sendEvent(epService.getEPRuntime());
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                break;
            }
        }
    }

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

示例11: 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

示例12: runAssertionDestroyObtainTwice

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private void runAssertionDestroyObtainTwice() {
    SupportPluginLoader.reset();

    Configuration cf = SupportConfigFactory.getConfiguration();
    cf.addPluginLoader("AP", SupportPluginLoader.class.getName(), null);
    EPServiceProviderManager.getProvider("ExecClientAdapterLoader", cf);
    EPServiceProvider ep = EPServiceProviderManager.getProvider("ExecClientAdapterLoader");
    ep.destroy();
    assertEquals(1, SupportPluginLoader.getDestroys().size());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:ExecClientAdapterLoader.java

示例13: testSendCSV

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public void testSendCSV() throws Exception {
    ConfigurationSocketAdapter adapterConfig = new ConfigurationSocketAdapter();
    int port = 6801;
    String engineURI = this.getClass().getSimpleName();

    SocketConfig socket = new SocketConfig();
    socket.setDataType(DataType.PROPERTY_ORDERED_CSV);
    socket.setPort(port);
    socket.setStream("SupportBean");
    socket.setPropertyOrder("stringProp,intProp");
    adapterConfig.getSockets().put("SocketService", socket);

    EsperIOSocketAdapter adapter = new EsperIOSocketAdapter(adapterConfig, engineURI);

    Configuration engineConfig = new Configuration();
    engineConfig.addEventType("SupportBean", SupportBean.class);
    EPServiceProvider provider = EPServiceProviderManager.getProvider(engineURI, engineConfig);

    adapter.start();

    EPStatement stmt = provider.getEPAdministrator().createEPL("select * from SupportBean");
    stmt.addListener(listener);

    String[] fields = "stringProp,intProp".split(",");
    SupportSocketClientCSV client = new SupportSocketClientCSV(port);

    client.send("E1,20" + newline);
    Thread.sleep(200);
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[]{"E1", 20});

    client.close();
    adapter.destroy();
    provider.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:35,代码来源:TestSocketAdapterCSVPropertyOrdered.java

示例14: validateGet

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
private void validateGet(boolean isNio, int port, String engineURI) throws Exception {

        String esperIOHTTPConfig = "<esperio-http-configuration>\n" +
                "<service name=\"service1\" port=\"" + port + "\" nio=\"" + isNio + "\"/>" +
                "<get service=\"service1\" pattern=\"*\"/>" +
                "</esperio-http-configuration>";

        Configuration engineConfig = new Configuration();
        engineConfig.addPluginLoader("EsperIOHTTPAdapter", EsperIOHTTPAdapterPlugin.class.getName(), new Properties(), esperIOHTTPConfig);

        engineConfig.addEventType("SupportBean", SupportBean.class);

        EPServiceProvider provider = EPServiceProviderManager.getProvider(engineURI, engineConfig);

        EPStatement stmt = provider.getEPAdministrator().createEPL("select * from SupportBean");
        stmt.addListener(listener);

        SupportHTTPClient client = new SupportHTTPClient(port);
        String[] fields = "stringProp,intProp".split(",");
        client.request(port, "sendevent", "stream", "SupportBean", "stringProp", "abc", "intProp", "5");
        EPAssertionUtil.assertProps(listener.assertOneGetNew(), fields, new Object[]{"abc", 5});

        listener.reset();
        provider.destroy();

        try {
            client = new SupportHTTPClient(port);
            client.request(port, "sendevent");
            fail();
        } catch (Exception expected) {
        }
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:TestHTTPAdapterInput.java

示例15: 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


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