Class MonitoringService
- java.lang.Object
-
- jadex.platform.service.monitoring.MonitoringService
-
- All Implemented Interfaces:
IMonitoringService
public class MonitoringService extends java.lang.Object implements IMonitoringService
Basic monitoring service implementation that stores the events in memory. Allows for defining a maximum number of events kept to avoid memory leaks (default is 10000).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jadex.bridge.service.types.monitoring.IMonitoringService
IMonitoringService.PublishEventLevel, IMonitoringService.PublishTarget
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The agent.protected java.util.List<IMonitoringEvent>
events
The list of events.protected IFilter<IMonitoringEvent>
filter
The event filter to filter out some events.protected long
max
The maximum number of events to keep, -1 for unrestricted.protected java.util.Map<SubscriptionIntermediateFuture<IMonitoringEvent>,IFilter<IMonitoringEvent>>
subscriptions
The subscriptions (subscription future -> subscription info).
-
Constructor Summary
Constructors Constructor Description MonitoringService()
Create a new MonitoringService.MonitoringService(long max, IFilter<IMonitoringEvent> filter)
Create a new MonitoringService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addEvent(IMonitoringEvent event)
Add a new event to the list.protected void
addSubscription(SubscriptionIntermediateFuture<IMonitoringEvent> future, IFilter<IMonitoringEvent> filter)
Add a new subscription.protected void
forwardEvent(IMonitoringEvent event)
Forward event to all currently registered subscribers.protected void
forwardEvent(IMonitoringEvent event, SubscriptionIntermediateFuture<IMonitoringEvent> sub)
Forward event to one subscribers.IFuture<java.lang.Void>
publishEvent(IMonitoringEvent event)
Publish a new event.protected void
removeSubscription(SubscriptionIntermediateFuture<IMonitoringEvent> fut)
Remove an existing subscription.IFuture<java.lang.Void>
shutdown()
Notify subscribers that monitoring service is terminated.ISubscriptionIntermediateFuture<IMonitoringEvent>
subscribeToEvents(IFilter<IMonitoringEvent> filter)
Subscribe to monitoring events.
-
-
-
Field Detail
-
agent
protected IInternalAccess agent
The agent.
-
events
protected java.util.List<IMonitoringEvent> events
The list of events.
-
max
protected long max
The maximum number of events to keep, -1 for unrestricted.
-
subscriptions
protected java.util.Map<SubscriptionIntermediateFuture<IMonitoringEvent>,IFilter<IMonitoringEvent>> subscriptions
The subscriptions (subscription future -> subscription info).
-
filter
protected IFilter<IMonitoringEvent> filter
The event filter to filter out some events.
-
-
Constructor Detail
-
MonitoringService
public MonitoringService()
Create a new MonitoringService.
-
MonitoringService
public MonitoringService(long max, IFilter<IMonitoringEvent> filter)
Create a new MonitoringService.
-
-
Method Detail
-
shutdown
public IFuture<java.lang.Void> shutdown()
Notify subscribers that monitoring service is terminated.
-
publishEvent
public IFuture<java.lang.Void> publishEvent(IMonitoringEvent event)
Publish a new event.- Specified by:
publishEvent
in interfaceIMonitoringService
- Parameters:
event
- The event.
-
subscribeToEvents
public ISubscriptionIntermediateFuture<IMonitoringEvent> subscribeToEvents(IFilter<IMonitoringEvent> filter)
Subscribe to monitoring events.- Specified by:
subscribeToEvents
in interfaceIMonitoringService
- Parameters:
filter
- An optional filter.
-
addEvent
protected void addEvent(IMonitoringEvent event)
Add a new event to the list. Removes an old entry if size=max.
-
addSubscription
protected void addSubscription(SubscriptionIntermediateFuture<IMonitoringEvent> future, IFilter<IMonitoringEvent> filter)
Add a new subscription.- Parameters:
future
- The subscription future.si
- The subscription info.
-
removeSubscription
protected void removeSubscription(SubscriptionIntermediateFuture<IMonitoringEvent> fut)
Remove an existing subscription.- Parameters:
fut
- The subscription future to remove.
-
forwardEvent
protected void forwardEvent(IMonitoringEvent event)
Forward event to all currently registered subscribers.
-
forwardEvent
protected void forwardEvent(IMonitoringEvent event, SubscriptionIntermediateFuture<IMonitoringEvent> sub)
Forward event to one subscribers.
-
-