本文整理汇总了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);
}
}
示例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());
}
示例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));
}
示例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();
}
示例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();
}
示例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);
}
}
示例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());
}