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


Java Configuration.configure方法代码示例

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


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

示例1: testIt

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
public void testIt() {
    URL url = FileUtil.class.getClassLoader().getResource("esper-kafka-sample-config.xml");
    assertNotNull("Failed to find sample config file", url);

    Configuration configuration = new Configuration();
    configuration.configure(url);

    ConfigurationPluginLoader config = configuration.getPluginLoaders().get(0);
    assertEquals(EsperIOKafkaInputAdapterPlugin.class.getName(), config.getClassName());

    Properties props = config.getConfigProperties();
    assertEquals(DEV_BOOTSTRAP_SERVER, props.getProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG));
    assertEquals(org.apache.kafka.common.serialization.StringDeserializer.class.getName(), props.getProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG));
    assertEquals("com.mycompany.MyCustomDeserializer", props.getProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));
    assertEquals("my_group_id", props.getProperty(ConsumerConfig.GROUP_ID_CONFIG));

    assertEquals("my_topic", props.get(EsperIOKafkaConfig.TOPICS_CONFIG));
    assertEquals(EsperIOKafkaInputProcessorDefault.class.getName(), props.get(EsperIOKafkaConfig.INPUT_PROCESSOR_CONFIG));
    assertEquals(EsperIOKafkaInputSubscriberByTopicList.class.getName(), props.get(EsperIOKafkaConfig.INPUT_SUBSCRIBER_CONFIG));
    assertEquals(EsperIOKafkaInputTimestampExtractorConsumerRecord.class.getName(), props.get(EsperIOKafkaConfig.INPUT_TIMESTAMPEXTRACTOR_CONFIG));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:22,代码来源:TestKafkaInputConfig.java

示例2: configureEPServiceProvider

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
/**
 * Configure the Esper Service Provider to create the appropriate Esper
 * Runtime.
 * 
 * @throws IOException
 * @throws EPException
 */
private void configureEPServiceProvider() throws EPException, IOException {
	if (LOG.isDebugEnabled()) {
		LOG.debug("Configuring the Esper Service Provider with name: " + providerURI);
	}
	if (this.configuration != null && this.configuration.exists()) {
		Configuration esperConfiguration = new Configuration();
		esperConfiguration = esperConfiguration.configure(this.configuration.getFile());
		epServiceProvider = EPServiceProviderManager.getProvider(providerURI, esperConfiguration);
		LOG.info("Esper configured with a user-provided configuration", esperConfiguration);
	} else {
		epServiceProvider = EPServiceProviderManager.getProvider(providerURI);
	}
	if (LOG.isDebugEnabled()) {
		LOG.debug("Completed configuring the Esper Service Provider with name: " + providerURI);
	}
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:24,代码来源:EsperTemplate.java

示例3: run

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

示例4: setUp

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
public void setUp() {
    URL url = TestRFIDTagsPerSensorStmt.class.getClassLoader().getResource("esper.examples.cfg.xml");
    Configuration config = new Configuration();
    if (url == null) {
        throw new RuntimeException("Could not load sample config file from classpath");
    }
    config.configure(url);

    epService = EPServiceProviderManager.getProvider("RFIDTags", config);
    epService.initialize();

    listener = new SupportUpdateListener();
    RFIDTagsPerSensorStmt rfidStmt = new RFIDTagsPerSensorStmt(epService.getEPAdministrator());
    rfidStmt.addListener(listener);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:16,代码来源:TestRFIDTagsPerSensorStmt.java

示例5: configure

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
public void configure(Configuration configuration) throws Exception {
    Schema avroSchema = SchemaBuilder.record(AVRO_TYPENAME).fields()
            .name("intPrimitive").type().intType().noDefault().endRecord();
    String avroSchemaText = avroSchema.toString().replace("\"", "&quot;");

    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<esper-configuration>\t\n" +
            "\t<event-type name=\"MyStaticBean\" class=\"" + SupportBean.class.getName() + "\"/>\n" +
            "\t<event-type name=\"" + MAP_TYPENAME + "\">\n" +
            "\t\t<java-util-map>\n" +
            "\t  \t\t<map-property name=\"intPrimitive\" class=\"int\"/>\n" +
            "\t  \t</java-util-map>\n" +
            "\t</event-type>\n" +
            "\t\n" +
            "\t<event-type name=\"" + OA_TYPENAME + "\">\n" +
            "\t\t<objectarray>\n" +
            "\t  \t\t<objectarray-property name=\"intPrimitive\" class=\"int\"/>\n" +
            "\t  \t</objectarray>\n" +
            "\t</event-type>\n" +
            "\t<event-type name=\"" + XML_TYPENAME + "\">\n" +
            "\t\t<xml-dom root-element-name=\"myevent\">\n" +
            "\t\t\t<xpath-property property-name=\"intPrimitive\" xpath=\"@intPrimitive\" type=\"number\"/>\n" +
            "\t\t</xml-dom>\n" +
            "\t</event-type>\n" +
            "\t<event-type name=\"" + AVRO_TYPENAME + "\">\n" +
            "\t\t<avro schema-text=\"" + avroSchemaText + "\"/>\n" +
            "\t</event-type>\n" +
            "</esper-configuration>\n";
    configuration.configure(SupportXML.getDocument(xml));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:31,代码来源:ExecEventInfraStaticConfiguration.java

示例6: aggregationTest

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
@Test
public void aggregationTest() {
  Configuration configuration = new Configuration();
  configuration.configure(new File("src/test/java/com/ebay/jetstream/event/processor/esper/raw/EsperTestConfig.xml"));
  EPServiceProvider epService = EPServiceProviderManager.getProvider("EsperTest", configuration);
  EsperTestAggregationStatement esperStmt = new EsperTestAggregationStatement(epService.getEPAdministrator());
  EsperTestAggregationListener listener = new EsperTestAggregationListener();
  esperStmt.addListener(listener);

  ExecutorService threadPool = Executors.newCachedThreadPool(new EsperTestThreadFactory());
  EsperTestAggregationRunnable runnables[] = new EsperTestAggregationRunnable[THREADS_NUM_AGGRTEST];
  try {
    for (int i = 0; i < THREADS_NUM_AGGRTEST; i++) {
      runnables[i] = new EsperTestAggregationRunnable(epService, i);
      threadPool.submit(runnables[i]);
    }
    threadPool.shutdown();
    threadPool.awaitTermination(200, TimeUnit.SECONDS);
  }
  catch (InterruptedException e) {
    fail("InterruptedException: " + e.getMessage());
  }
  assertTrue("ExecutorService failed to shut down properly", threadPool.isShutdown());
  assertEquals(THREADS_NUM_AGGRTEST * 2, listener.getCount());
  assertEquals(THREADS_NUM_AGGRTEST, m_aggregationResults.size()); // only one result per oroginal event
  for (int i = 0; i < THREADS_NUM_AGGRTEST; i++) {
    assertEquals(11.0 + 4. * i, m_aggregationResults.get(i), 1.e-06);
  }
  assertEquals(THREADS_NUM_AGGRTEST, m_aggregationAvgResults.size()); // only one result per oroginal event
  for (int i = 0; i < THREADS_NUM_AGGRTEST; i++) {
    assertEquals((11.0 + 4. * i) / 4., m_aggregationAvgResults.get(i), 1.e-06);
  }
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:34,代码来源:EsperTest.java

示例7: multithreadingTest

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
@Ignore
public void multithreadingTest() {
  Configuration configuration = new Configuration();
  configuration.configure(new File("src/test/java/com/ebay/jetstream/event/processor/esper/raw/EsperTestConfig.xml"));
  EPServiceProvider epService = EPServiceProviderManager.getProvider("EsperTest", configuration);
  EsperTestStatement esperStmt = new EsperTestStatement(epService.getEPAdministrator());

  EsperTestSubscriber subscriber = new EsperTestSubscriber();
  EsperTestListener listener = new EsperTestListener();
  esperStmt.setSubscriber(subscriber);
  esperStmt.addListener(listener);

  ExecutorService threadPool = Executors.newCachedThreadPool(new EsperTestThreadFactory());
  EsperTestRunnable runnables[] = new EsperTestRunnable[THREADS_NUM];
  try {
    for (int i = 0; i < THREADS_NUM; i++) {
      runnables[i] = new EsperTestRunnable(epService, i);
      threadPool.submit(runnables[i]);
    }
    threadPool.shutdown();
    threadPool.awaitTermination(200, TimeUnit.SECONDS);
  }
  catch (InterruptedException e) {
    fail("InterruptedException: " + e.getMessage());
  }
  assertTrue("ExecutorService failed to shut down properly", threadPool.isShutdown());

  log.info("[" + subscriber.getIds().first() + "," + subscriber.getIds().last() + "]");
  assertEquals(THREADS_NUM, subscriber.getCount());

  log.info("[" + listener.getIds().first() + "," + listener.getIds().last() + "]");
  assertEquals(THREADS_NUM, listener.getCount());
  assertEquals(THREADS_NUM, listener.getNewCount());
  assertEquals(0, listener.getOldCount());
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:36,代码来源:EsperTest.java

示例8: handleInitServiceProvider

import com.espertech.esper.client.Configuration; //导入方法依赖的package包/类
protected void handleInitServiceProvider(String strategyName) {

		String providerURI = getProviderURI(strategyName);

		Configuration configuration = new Configuration();
		configuration.configure("esper-" + providerURI.toLowerCase() + ".cfg.xml");

		initVariables(strategyName, configuration);

		Strategy strategy = getLookupService().getStrategyByNameFetched(strategyName);
		configuration.getVariables().get("engineStrategy").setInitializationValue(strategy);

		EPServiceProvider serviceProvider = EPServiceProviderManager.getProvider(providerURI, configuration);

		// must send time event before first schedule pattern
		serviceProvider.getEPRuntime().sendEvent(new CurrentTimeEvent(initTime));
		this.internalClock.put(strategyName, false);

		this.serviceProviders.put(providerURI, serviceProvider);

		logger.debug("initialized service provider: " + strategyName);
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:23,代码来源:RuleServiceImpl.java


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