本文整理汇总了Java中com.espertech.esper.client.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于com.espertech.esper.client包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.espertech.esper.client.Configuration; //导入依赖的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);
}
示例2: testTimestamp
import com.espertech.esper.client.Configuration; //导入依赖的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);
}
}
示例3: initVariables
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
/**
* initialize all the variables from the Configuration
*/
private void initVariables(String strategyName, Configuration configuration) {
try {
Map<String, ConfigurationVariable> variables = configuration.getVariables();
for (Map.Entry<String, ConfigurationVariable> entry : variables.entrySet()) {
String key = entry.getKey().replace("_", ".");
String obj = ConfigurationUtil.getStrategyConfig(strategyName).getString(key);
if (obj != null) {
Class<?> clazz = Class.forName(entry.getValue().getType());
Object castedObj = JavaClassHelper.parse(clazz, obj);
entry.getValue().setInitializationValue(castedObj);
}
}
} catch (ClassNotFoundException e) {
throw new RuleServiceException(e);
}
}
示例4: 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));
}
示例5: setUp
import com.espertech.esper.client.Configuration; //导入依赖的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));
}
示例6: prepare
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param map
* @param tc
* @param oc
*/
@Override
public void prepare(@SuppressWarnings("rawtypes") Map map, TopologyContext tc, OutputCollector oc) {
this.collector = oc;
Configuration cepConfig = new Configuration();
if (this.eventTypes == null || (this.objectStatements == null && this.statements == null)) {
throw new FailedException("Event types cannot be null and at least one type of statement has to be not null");
}
for (Map.Entry<GlobalStreamId, Grouping> a : tc.getThisSources().entrySet()) {
Fields f = tc.getComponentOutputFields(a.getKey());
if (!this.eventTypes.keySet().containsAll(f.toList())) {
throw new FailedException("Event types and fields from source streams do not match: Event Types="
+ Arrays.toString(this.eventTypes.keySet().toArray())
+ " Stream Fields=" + Arrays.toString(f.toList().toArray()));
}
cepConfig.addEventType(a.getKey().get_componentId() + "_" + a.getKey().get_streamId(), this.eventTypes);
}
this.epService = EPServiceProviderManager.getDefaultProvider(cepConfig);
this.epService.initialize();
if (!processStatemens()) {
throw new FailedException("At least one type of statement has to be not empty");
}
}
示例7: setUp
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
public void setUp() throws Exception {
AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.makeAgentInstanceContext();
SelectExprEventTypeRegistry selectExprEventTypeRegistry = new SelectExprEventTypeRegistry("abc", new StatementEventTypeRefImpl());
SelectExprProcessorHelper selectFactory = new SelectExprProcessorHelper(Collections.<Integer>emptyList(), SupportSelectExprFactory.makeSelectListFromIdent("theString", "s0"),
Collections.<SelectExprStreamDesc>emptyList(), null, null, false, new SupportStreamTypeSvc1Stream(), SupportEventAdapterService.getService(), null, selectExprEventTypeRegistry, agentInstanceContext.getEngineImportService(), 1, "stmtname", null, new Configuration(), null, new TableServiceImpl(), null);
SelectExprProcessorForge selectForge = selectFactory.getForge();
supportAggregationService = new SupportAggregationService();
ExprNode[] groupKeyNodes = new ExprNode[2];
groupKeyNodes[0] = SupportExprNodeFactory.makeIdentNode("intPrimitive", "s0");
groupKeyNodes[1] = SupportExprNodeFactory.makeIdentNode("intBoxed", "s0");
ResultSetProcessorRowPerGroupForge forge = new ResultSetProcessorRowPerGroupForge(selectForge.getResultEventType(), selectForge, groupKeyNodes, null, true, false, null, false, false, false, false, null, null, 1, null);
ResultSetProcessorFactory factory = forge.getResultSetProcessorFactory(agentInstanceContext.getStatementContext(), false);
processor = (ResultSetProcessorRowPerGroup) factory.instantiate(null, supportAggregationService, agentInstanceContext);
}
示例8: configure
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
public void configure(Configuration configuration) throws Exception {
applyMetricsConfig(configuration, -1, 7000, true);
ConfigurationMetricsReporting.StmtGroupMetrics groupOne = new ConfigurationMetricsReporting.StmtGroupMetrics();
groupOne.setInterval(8000);
groupOne.addIncludeLike("%GroupOne%");
groupOne.setReportInactive(true);
configuration.getEngineDefaults().getMetricsReporting().addStmtGroup("GroupOneStatements", groupOne);
ConfigurationMetricsReporting.StmtGroupMetrics groupTwo = new ConfigurationMetricsReporting.StmtGroupMetrics();
groupTwo.setInterval(6000);
groupTwo.setDefaultInclude(true);
groupTwo.addExcludeLike("%Default%");
groupTwo.addExcludeLike("%Metrics%");
configuration.getEngineDefaults().getMetricsReporting().addStmtGroup("GroupTwoNonDefaultStatements", groupTwo);
ConfigurationMetricsReporting.StmtGroupMetrics groupThree = new ConfigurationMetricsReporting.StmtGroupMetrics();
groupThree.setInterval(-1);
groupThree.addIncludeLike("%Metrics%");
configuration.getEngineDefaults().getMetricsReporting().addStmtGroup("MetricsStatements", groupThree);
}
示例9: run
import com.espertech.esper.client.Configuration; //导入依赖的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();
}
示例10: 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);
}
}
示例11: getServiceProvider
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
private EPServiceProvider getServiceProvider(String context) throws IOException {
EPServiceProvider serviceProvider = engineState.value();
if (serviceProvider != null) {
return serviceProvider;
}
synchronized (lock) {
serviceProvider = engineState.value();
if (serviceProvider == null) {
Configuration configuration = new Configuration();
configuration.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
serviceProvider = EPServiceProviderManager.getProvider(context, configuration);
serviceProvider.getEPAdministrator().getConfiguration().addEventType(inputType.getTypeClass());
serviceProvider.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
EPStatement statement = query.createStatement(serviceProvider.getEPAdministrator());
statement.addListener((newData, oldData) -> {
for (EventBean event : newData) {
EsperSelectFunction<OUT> userFunction = getUserFunction();
try {
output.collect(new StreamRecord<>((userFunction.select(event))));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
this.engineState.update(serviceProvider);
return serviceProvider;
} else {
return engineState.value();
}
}
}
示例12: init
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
/**
* Initalizes the Sensor
*
* @param instanceId instance id where the sensor running
* @param poolSize sensor poolsize value
* @throws Exception throws if any error while initializing sensor.
*/
public void init(int instanceId, int poolSize) throws Exception {
long start = System.currentTimeMillis();
logger.info(">>> Sensor initialization started.");
this.instanceId = instanceId - 1;
this.poolSize = poolSize;
Configuration cfg = new Configuration();
cfg.addEventType("PerfEvent", PerfEvent.class.getName());
cfg.addEventType("DelayedPerfEvent", DelayedPerfEvent.class.getName());
cfg.addEventType("OpsEvent", OpsEvent.class.getName());
cfg.addEventType("OpsCloseEvent", OpsCloseEvent.class.getName());
cfg.addEventType("ChannelDownEvent", ChannelDownEvent.class.getName());
ConfigurationEngineDefaults.Threading ct = cfg.getEngineDefaults().getThreading();
ct.setThreadPoolInbound(true);
ct.setThreadPoolInboundNumThreads(ESPER_INBOUND_THREADS);
ct.setThreadPoolOutbound(true);
ct.setThreadPoolOutboundNumThreads(ESPER_OUTBOUND_THREADS);
ct.setThreadPoolRouteExec(true);
ct.setThreadPoolRouteExecNumThreads(ESPER_ROUTE_EXEC_THREADS);
ct.setThreadPoolTimerExec(true);
ct.setThreadPoolTimerExecNumThreads(ESPER_TIMER_THREADS);
this.epService = EPServiceProviderManager.getDefaultProvider(cfg);
loadAllStatements();
this.isInited = true;
long tt = TimeUnit.SECONDS.convert((System.currentTimeMillis() - start), TimeUnit.MILLISECONDS);
logger.info(">>> Sensor initialization completed. Took " + tt + " seconds!!!");
}
示例13: EsperOperation
import com.espertech.esper.client.Configuration; //导入依赖的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());
}
示例14: testContextQuery
import com.espertech.esper.client.Configuration; //导入依赖的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));
}
示例15: startCEPEngine
import com.espertech.esper.client.Configuration; //导入依赖的package包/类
/**
* Method in which we start the CEP engine
*
*/
private void startCEPEngine() {
Configuration cepConfig = new Configuration();
this.epService = EPServiceProviderManager.getProvider("CityPulse Event Detection engine", cepConfig);
logger.info("EventDetection: CEP engine started.");
}