本文整理汇总了Java中com.espertech.esper.client.EPAdministrator类的典型用法代码示例。如果您正苦于以下问题:Java EPAdministrator类的具体用法?Java EPAdministrator怎么用?Java EPAdministrator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EPAdministrator类属于com.espertech.esper.client包,在下文中一共展示了EPAdministrator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTimestamp
import com.espertech.esper.client.EPAdministrator; //导入依赖的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: FindMissingEventStmt
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
public FindMissingEventStmt(EPAdministrator admin) {
// The inner table to both A and B is C.
//
// The listener will consider old events generated when either A or B leave the window, with
// a window size for A and B of 30 minutes.
//
// The window of C is declared large to ensure the C events don't leave the window before A and B
// thus generating false alerts, making these obvious via timestamp. Lets keep 1 hour of data for C.
String stmt = "select irstream * from " +
"TxnEventA#time(30 min) A " +
"full outer join " +
"TxnEventC#time(1 hour) C on A.transactionId = C.transactionId " +
"full outer join " +
"TxnEventB#time(30 min) B on B.transactionId = C.transactionId " +
"where C.transactionId is null";
statement = admin.createEPL(stmt);
}
示例3: CombinedEventStmt
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
public CombinedEventStmt(EPAdministrator admin) {
// We need to take in events A, B and C and produce a single, combined event
String stmt = "insert into CombinedEvent(transactionId, customerId, supplierId, latencyAC, latencyBC, latencyAB)" +
"select C.transactionId," +
"customerId," +
"supplierId," +
"C.timestamp - A.timestamp," +
"C.timestamp - B.timestamp," +
"B.timestamp - A.timestamp " +
"from TxnEventA#time(30 min) A," +
"TxnEventB#time(30 min) B," +
"TxnEventC#time(30 min) C " +
"where A.transactionId = B.transactionId and B.transactionId = C.transactionId";
statement = admin.createEPL(stmt);
}
示例4: createStatement
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
public static void createStatement(EPAdministrator admin) {
EPStatement statement = admin.createEPL("select istream ipAddress, avg(duration) from SampleEvent#time(10 sec) group by ipAddress output snapshot every 2 seconds order by ipAddress asc");
statement.addListener(new UpdateListener() {
public void update(EventBean[] newEvents, EventBean[] oldEvents) {
if (newEvents == null) {
return;
}
for (int i = 0; i < newEvents.length; i++) {
if (log.isInfoEnabled()) {
log.info("IPAddress: " + newEvents[i].get("ipAddress") +
" Avg Duration: " + newEvents[i].get("avg(duration)"));
}
}
}
});
}
示例5: save
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Override
public void save(final Type type)
{
final Map<String, Object> map = new HashMap<String, Object>(type.getProperties());
final EPAdministrator admin = epService.getEPAdministrator();
final ConfigurationOperations config = admin.getConfiguration();
final String name = type.getName();
logger.info("Saving type : " + name);
if (config.isEventTypeExists(name)) {
config.updateMapEventType(name, map);
return;
}
config.addEventType(name, map);
}
示例6: testListTypes
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Test
public void testListTypes()
{
final TypeConfiguration instance = new TypeConfiguration(epService);
final ConfigurationOperations config = mock(ConfigurationOperations.class);
final EPAdministrator admin = mock(EPAdministrator.class);
final EventType eventType1 = mock(EventType.class);
final EventType eventType2 = mock(EventType.class);
final EventType[] eventTypes = new EventType[]{
eventType1, eventType2
};
when(epService.getEPAdministrator()).thenReturn(admin);
when(admin.getConfiguration()).thenReturn(config);
when(config.getEventTypes()).thenReturn(eventTypes);
when(eventType1.getName()).thenReturn("EventType1");
when(eventType2.getName()).thenReturn("EventType2");
final List<String> result = instance.list();
assertEquals(2, result.size());
assertEquals("EventType1", result.get(0));
assertEquals("EventType2", result.get(1));
verify(config).getEventTypes();
}
示例7: testSaveNewType
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Test
public void testSaveNewType()
{
final TypeConfiguration instance = new TypeConfiguration(epService);
final ConfigurationOperations config = mock(ConfigurationOperations.class);
final EPAdministrator admin = mock(EPAdministrator.class);
final Map<String, String> properties = new HashMap<>();
final String name = "EventTypeX";
final Type type = new Type(name, properties);
final Map<String, Object> map = new HashMap<>();
properties.put("value", "string");
properties.put("key", "string");
map.putAll(properties);
when(admin.getConfiguration()).thenReturn(config);
when(epService.getEPAdministrator()).thenReturn(admin);
when(config.isEventTypeExists(eq(name))).thenReturn(Boolean.FALSE);
instance.save(type);
verify(config).isEventTypeExists(eq(name));
verify(config).addEventType(eq(name), eq(map));
}
示例8: testSaveExistingType
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Test
public void testSaveExistingType()
{
final TypeConfiguration instance = new TypeConfiguration(epService);
final ConfigurationOperations config = mock(ConfigurationOperations.class);
final EPAdministrator admin = mock(EPAdministrator.class);
final Map<String, String> properties = new HashMap<>();
final String name = "EventTypeY";
final Type type = new Type(name, properties);
final Map<String, Object> map = new HashMap<>();
properties.put("value", "string");
properties.put("key", "string");
map.putAll(properties);
when(admin.getConfiguration()).thenReturn(config);
when(epService.getEPAdministrator()).thenReturn(admin);
when(config.isEventTypeExists(eq(name))).thenReturn(Boolean.TRUE);
instance.save(type);
verify(config).isEventTypeExists(eq(name));
verify(config).updateMapEventType(eq(name), eq(map));
}
示例9: testRemoveExistingType
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Test
public void testRemoveExistingType()
{
final TypeConfiguration instance = new TypeConfiguration(epService);
final ConfigurationOperations config = mock(ConfigurationOperations.class);
final EPAdministrator admin = mock(EPAdministrator.class);
final String name = "EventTypeY";
when(admin.getConfiguration()).thenReturn(config);
when(epService.getEPAdministrator()).thenReturn(admin);
when(config.isEventTypeExists(eq(name))).thenReturn(Boolean.TRUE);
when(config.removeEventType(eq(name), eq(true))).thenReturn(Boolean.TRUE);
assertTrue(instance.remove(name));
verify(config).isEventTypeExists(eq(name));
verify(config).removeEventType(eq(name), eq(true));
}
示例10: testRemoveNotExistingType
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@Test
public void testRemoveNotExistingType()
{
final TypeConfiguration instance = new TypeConfiguration(epService);
final ConfigurationOperations config = mock(ConfigurationOperations.class);
final EPAdministrator admin = mock(EPAdministrator.class);
final String name = "EventTypeY";
when(admin.getConfiguration()).thenReturn(config);
when(epService.getEPAdministrator()).thenReturn(admin);
when(config.isEventTypeExists(eq(name))).thenReturn(Boolean.FALSE);
when(config.removeEventType(eq(name), eq(true))).thenReturn(Boolean.TRUE);
assertTrue(instance.remove(name));
verify(config).isEventTypeExists(eq(name));
verify(config, never()).removeEventType(eq(name), eq(true));
}
示例11: getAll
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
@RequestMapping(value = "/statements", method = RequestMethod.GET)
public List<StatementDTO> getAll() {
EPAdministrator epAdmin = epService.getEPAdministrator();
String[] names = epAdmin.getStatementNames();
return Arrays.stream(names)
.map(i -> StatementMapper.fromStatement(epAdmin.getStatement(i)))
.collect(Collectors.toList());
}
示例12: EsperOperation
import com.espertech.esper.client.EPAdministrator; //导入依赖的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());
}
示例13: testContextQuery
import com.espertech.esper.client.EPAdministrator; //导入依赖的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));
}
示例14: RealtimeSummaryStmt
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
public RealtimeSummaryStmt(EPAdministrator admin) {
//
// Min,Max,Average total latency from the events (difference in time between A and C) over the past 30 minutes.
// Min,Max,Average latency between events A/B (time stamp of B minus A) and B/C (time stamp of C minus B).
//
String stmtTotal = "select min(latencyAC) as minLatencyAC, " +
"max(latencyAC) as maxLatencyAC, " +
"avg(latencyAC) as avgLatencyAC, " +
"min(latencyAB) as minLatencyAB, " +
"max(latencyAB) as maxLatencyAB, " +
"avg(latencyAB) as avgLatencyAB, " +
"min(latencyBC) as minLatencyBC, " +
"max(latencyBC) as maxLatencyBC, " +
"avg(latencyBC) as avgLatencyBC " +
"from CombinedEvent#time(30 min)";
totalsStatement = admin.createEPL(stmtTotal);
//
// Min,Max,Average latency grouped by (a) customer ID and (b) supplier ID.
// In other words, metrics on the the latency of the orders coming from each customer and going to each supplier.
//
String stmtCustomer = "select customerId," +
"min(latencyAC) as minLatency," +
"max(latencyAC) as maxLatency," +
"avg(latencyAC) as avgLatency " +
"from CombinedEvent#time(30 min) " +
"group by customerId";
byCustomerStatement = admin.createEPL(stmtCustomer);
String stmtSupplier = "select supplierId," +
"min(latencyAC) as minLatency," +
"max(latencyAC) as maxLatency," +
"avg(latencyAC) as avgLatency " +
"from CombinedEvent#time(30 min) " +
"group by supplierId";
bySupplierStatement = admin.createEPL(stmtSupplier);
}
示例15: start
import com.espertech.esper.client.EPAdministrator; //导入依赖的package包/类
public static void start() {
EPAdministrator admin = EPServiceProviderManager.getDefaultProvider().getEPAdministrator();
EPStatement statView = admin.createEPL(
"select * from " + OperationMeasurement.class.getName() +
"#groupwin(customerId, operationName)" +
"#length(100)#uni(latency)");
statView.addListener(new AverageLatencyListener(10000));
}