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


Java EPServiceProvider.getEPAdministrator方法代码示例

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


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

示例1: testTimestamp

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

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
public EsperOperation() {
	Configuration cepConfig = new Configuration();
	cepConfig.addEventType("StockTick", Stock.class.getName());
	EPServiceProvider cep = EPServiceProviderManager.getProvider(
			"myCEPEngine", cepConfig);
	cepRT = cep.getEPRuntime();

	EPAdministrator cepAdm = cep.getEPAdministrator();
	EPStatement cepStatement = cepAdm
			.createEPL("select sum(price),product from "
					+ "StockTick.win:time_batch(5 sec) "
					+ "group by product");

	cepStatement.addListener(new CEPListener());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:16,代码来源:EsperOperation.java

示例3: testContextQuery

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
@Test
public void testContextQuery() {
	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();

	cepAdm.createEPL("" + "CREATE CONTEXT NestedContext " + "CONTEXT SegmentedByLocation PARTITION BY values('Location') FROM Event, " + "CONTEXT SegmentedByTime INITIATED BY Event(values('Action')='Ende') TERMINATED AFTER 1 hour, " + "CONTEXT SegmentedByRating PARTITION BY values('Rating') FROM Event");

	final EPStatement transformationStatement = cepAdm.createEPL("" + "CONTEXT NestedContext " + "SELECT ID, values('Location'), values('Rating'), count(*) " + "FROM Event " + "GROUP BY values('Location'), values('Rating') " + "OUTPUT LAST EVERY 30 minute");

	transformationStatement.addListener(new CEPListener());

	final List<EapEvent> events = new ArrayList<EapEvent>();
	events.addAll(this.createRatingEvents());
	events.addAll(this.createKinoEvents());
	this.sortEventListByDate(events);

	for (final EapEvent event : events) {
		cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
		cepRT.sendEvent(new CurrentTimeEvent(event.getTimestamp().getTime()));
		cepRT.sendEvent(event);
	}

	cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_INTERNAL));
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:29,代码来源:StatementTest.java

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

示例5: setUp

import com.espertech.esper.client.EPServiceProvider; //导入方法依赖的package包/类
@BeforeClass
public static void setUp(){
	EPServiceProvider engine = EPServiceProviderManager.getDefaultProvider();
    engine.getEPAdministrator().getConfiguration().addEventType(TestEvents.class);
    epAdmin = engine.getEPAdministrator();
 
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:8,代码来源:EPLParserTest.java

示例6: aggregationTest

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


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