本文整理汇总了Java中com.espertech.esper.client.EPServiceProviderManager类的典型用法代码示例。如果您正苦于以下问题:Java EPServiceProviderManager类的具体用法?Java EPServiceProviderManager怎么用?Java EPServiceProviderManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EPServiceProviderManager类属于com.espertech.esper.client包,在下文中一共展示了EPServiceProviderManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEsper
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
@Test
public void testEsper() {
EPServiceProvider engine = EPServiceProviderManager.getDefaultProvider();
engine.getEPAdministrator().getConfiguration().addEventType(TestEvent.class);
String query = "select name, age from TestEvent";
EPStatement statement = engine.getEPAdministrator().createEPL(query);
statement.addListener((newData, oldData) -> {
String name = (String) newData[0].get("name");
int age = (int) newData[0].get("age");
System.out.println(name + " " + age);
});
engine.getEPRuntime().sendEvent(new TestEvent("peter", 10));
}
示例2: main
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Configuration config = new Configuration();
//config.addEventType("BasicEvent", BasicEvent.class);
config.addEventType("PerfEvent", PerfEvent.class);
/* If we gonna use custom timestamps - use this
ConfigurationEventTypeLegacy cetl = new ConfigurationEventTypeLegacy();
cetl.setStartTimestampPropertyName("timestamp");
cetl.setEndTimestampPropertyName("timestamp");
config.addEventType("PerfEvent", PerfEvent.class.getName(), cetl);
*/
// Get engine instance
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
String stmt = "insert into OpsEvent select ciId, 'cpu' as name, 'open' as state, 'count:' || cast(count(1),string) as cnt from PerfEvent.win:time(1 min) where metrics('cpu') > 10 group by ciId having count(1) > 0 output first every 3 minutes";
EPStatement statement = epService.getEPAdministrator().createEPL(stmt, "test");
assertTrue(statement != null);
}
示例3: testTimestamp
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的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);
}
}
示例4: configure
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* This method configures the CEP.
*
* @return It returns a well configured esper service provider instance.
*/
private EPServiceProvider configure() {
// configure logging
System.setProperty(DOMImplementationRegistry.PROPERTY,
"com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
// configure supported event ids
Configuration config = new Configuration();
config.addEventTypeAutoName(LogEvent.class.getPackage().getName());
// create provider
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
// discover schema url
URL schemaURL = ComplexEventProcessor.class.getClassLoader().getResource(eventLogFile);
logger.info("xsd path is: " + schemaURL.toString());
// configure default xml stream
ConfigurationEventTypeXMLDOM sensorcfg = new ConfigurationEventTypeXMLDOM();
sensorcfg.setRootElementName("log");
sensorcfg.setSchemaResource(schemaURL.toString());
epService.getEPAdministrator().getConfiguration()
.addEventType(LogEvent.LogEventStream, sensorcfg);
return epService;
}
示例5: start
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
public void start() {
if (log.isInfoEnabled()) {
log.info("Starting EsperIO Kafka Output Adapter for engine URI '{}'", engineURI);
}
// Obtain engine
EPServiceProviderSPI engine = (EPServiceProviderSPI) EPServiceProviderManager.getProvider(engineURI);
// Obtain and invoke flow controlle
String className = getRequiredProperty(properties, OUTPUT_FLOWCONTROLLER_CONFIG);
EsperIOKafkaOutputFlowController controller;
try {
controller = (EsperIOKafkaOutputFlowController) JavaClassHelper.instantiate(EsperIOKafkaOutputFlowController.class, className, engine.getEngineImportService().getClassForNameProvider());
EsperIOKafkaOutputFlowControllerContext context = new EsperIOKafkaOutputFlowControllerContext(engine, properties);
controller.initialize(context);
} catch (Throwable t) {
throw new ConfigurationException("Unexpected exception invoking flow-controller initialize method on class " + className + " for engine URI '" + engineURI + "': " + t.getMessage(), t);
}
if (log.isInfoEnabled()) {
log.info("Completed starting EsperIO Kafka Output Adapter for engine URI '{}'", engineURI);
}
}
示例6: testExistingTypeNoOptions
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* Play a CSV file using an existing event type definition (no timestamps).
* <p>
* Should not require a timestamp column, should block thread until played in.
*/
public void testExistingTypeNoOptions() {
epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA", useBean));
epService.initialize();
EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
(new CSVInputAdapter(epService, new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA")).start();
assertEquals(1, listener.getNewDataList().size());
// test graph
String graph = "create dataflow ReadCSV " +
"FileSource -> mystream<TypeA> { file: '" + CSV_FILENAME_ONELINE_TRADE + "', hasTitleLine: true, classpathFile: true }" +
"DefaultSupportCaptureOp(mystream) {}";
epService.getEPAdministrator().createEPL(graph);
DefaultSupportCaptureOp<Object> outputOp = new DefaultSupportCaptureOp<Object>();
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("ReadCSV", new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProvider(outputOp)));
instance.run();
List<List<Object>> received = outputOp.getAndReset();
Object[] receivedArr = received.get(0).toArray();
assertEquals(1, receivedArr.length);
}
示例7: testEngineThread1000PerSec
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* Play a CSV file using an engine thread
*/
public void testEngineThread1000PerSec() throws Exception {
epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
epService.initialize();
EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA");
spec.setEventsPerSec(1000);
spec.setUsingEngineThread(true);
InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
inputAdapter.start();
Thread.sleep(1000);
assertEquals(1, listener.getNewDataList().size());
}
示例8: testEngineThread1PerSec
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* Play a CSV file using an engine thread.
*/
public void testEngineThread1PerSec() throws Exception {
epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
epService.initialize();
EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE_MULTIPLE), "TypeA");
spec.setEventsPerSec(1);
spec.setUsingEngineThread(true);
InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
inputAdapter.start();
Thread.sleep(1500);
assertEquals(1, listener.getNewDataList().size());
listener.reset();
Thread.sleep(300);
assertEquals(0, listener.getNewDataList().size());
Thread.sleep(2000);
assertTrue(listener.getNewDataList().size() >= 2);
}
示例9: testAppThread
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* Play a CSV file using the application thread
*/
public void testAppThread() throws Exception {
epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
epService.initialize();
EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA");
spec.setEventsPerSec(1000);
InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
inputAdapter.start();
assertEquals(1, listener.getNewDataList().size());
}
示例10: testDynamicType
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
/**
* Play a CSV file using no existing (dynamic) event type (no timestamp)
*/
public void testDynamicType() {
CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeB");
Configuration config = new Configuration();
config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
epService = EPServiceProviderManager.getDefaultProvider(config);
epService.initialize();
InputAdapter feed = new CSVInputAdapter(epService, spec);
EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeB#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
assertEquals(String.class, stmt.getEventType().getPropertyType("symbol"));
assertEquals(String.class, stmt.getEventType().getPropertyType("price"));
assertEquals(String.class, stmt.getEventType().getPropertyType("volume"));
feed.start();
assertEquals(1, listener.getNewDataList().size());
}
示例11: setUp
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
public void setUp() {
Configuration configuration = new Configuration();
configuration.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
configuration.addEventType("MarketDataEvent", MarketDataEvent.class.getName());
epService = EPServiceProviderManager.getProvider("TestTicksPerSecondStatement", configuration);
epService.initialize();
epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
new TicksPerSecondStatement(epService.getEPAdministrator());
TicksFalloffStatement stmt = new TicksFalloffStatement(epService.getEPAdministrator());
listener = new SupportUpdateListener();
stmt.addListener(listener);
// Use external clocking for the test
epService.getEPRuntime().sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
}
示例12: runAssertionIteratorMultiStmtNoViewShare
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的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();
}
示例13: runAssertionIteratorMultiStmtViewShare
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的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();
}
示例14: run
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的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();
}
示例15: init
import com.espertech.esper.client.EPServiceProviderManager; //导入依赖的package包/类
public void init(){
epService = EPServiceProviderManager.getProvider(id);
epAdminProxy = new EPAdministratorImplProxy(epService.getEPAdministrator());
messageHandlingScheduler=new MessageHandlingScheduler(id, 1);
responseMessageHandlingScheduler=new MessageHandlingScheduler(id, 1);
workerStatWriter=new AsyncFileWriter("log/workerstats", 8000);
linkManager=ServiceManager.getInstance(id).getLinkManager();
linkManager.init();
linkManager.setNewLinkListener(newLinkHandler);
delayedContainerFlowRegistry=new DelayedStreamContainerFlowRegistry(this);
centralizedTreeBuilder=new CentralizedTreeBuilder(this);
streamFlowBuilder=new StreamFlowBuilder(this);
streamContainerFlowBuilder=new StreamContainerFlowBuilder(this);
coordStatReportor=new CoordinatorStatReportor(this);
streamReviewer=new StreamReviewer(existedFscList, existedPscList,
existedJscList, existedRscList);
costEval=new CostEvaluator(containerNameMap, streamReviewer);
expectedSpoutCount=(int)ServiceManager.getConfig().getLong(Options.EXPECTED_SPOUNT_COUNT, 0);
}