Class EventPublisher
- java.lang.Object
-
- org.ovirt.vdsm.jsonrpc.client.events.EventPublisher
-
- All Implemented Interfaces:
Publisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>
public class EventPublisher extends java.lang.Object implements Publisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>
Jsonrpc implementation ofPublisher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classEventPublisher.EventCallableEvent processing task which is submit to aExecutorServicefor processing.
-
Field Summary
Fields Modifier and Type Field Description private EventDecomposerdecomposerprivate inteventTimeoutInHoursprivate java.util.concurrent.ExecutorServiceexecutorServiceprivate static org.slf4j.Loggerlogprivate SubscriptionMatchermatcherprivate java.util.concurrent.ScheduledExecutorServicescheduledExecutorService
-
Constructor Summary
Constructors Constructor Description EventPublisher(java.util.concurrent.ExecutorService executorService, int eventTimeoutInHours)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclean(SubscriptionHolder holder)voidcleanupOldEvents()voidclose()intcountEvents(JsonRpcEvent event)private voidprocess(SubscriptionHolder holder)voidprocess(JsonRpcEvent event)This method is used by @linkResponseWorkerto submit an @linkJsonRpcEventfor processing.voidpublish(java.lang.String subscriptionId, java.util.Map<java.lang.String,java.lang.Object> params)RequestPublisherto send data.private voidscheduleCleanupTask()voidsubscribe(EventSubscriber subscriber)RequestPublisherto start streaming data.
-
-
-
Field Detail
-
log
private static org.slf4j.Logger log
-
executorService
private java.util.concurrent.ExecutorService executorService
-
scheduledExecutorService
private java.util.concurrent.ScheduledExecutorService scheduledExecutorService
-
matcher
private SubscriptionMatcher matcher
-
decomposer
private EventDecomposer decomposer
-
eventTimeoutInHours
private int eventTimeoutInHours
-
-
Method Detail
-
scheduleCleanupTask
private void scheduleCleanupTask()
-
cleanupOldEvents
public void cleanupOldEvents()
-
subscribe
public void subscribe(EventSubscriber subscriber)
Description copied from interface:PublisherRequestPublisherto start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription.Each
Subscriptionwill work for only a singleSubscriber.A
Subscribershould only subscribe once to a singlePublisher.If the
Publisherrejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(java.lang.Throwable).- Specified by:
subscribein interfacePublisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>- Parameters:
subscriber- theSubscriberthat will consume signals from thisPublisher
-
publish
public void publish(java.lang.String subscriptionId, java.util.Map<java.lang.String,java.lang.Object> params) throws java.io.IOExceptionDescription copied from interface:PublisherRequestPublisherto send data.- Specified by:
publishin interfacePublisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>- Parameters:
subscriptionId- the identifier forSubscriberwho will consume the eventparams- the data that needs to be sent to theSubscriber- Throws:
java.io.IOException- an exception is thrown if the params cannot be serialized
-
process
private void process(SubscriptionHolder holder)
-
clean
private void clean(SubscriptionHolder holder)
-
process
public void process(JsonRpcEvent event)
This method is used by @linkResponseWorkerto submit an @linkJsonRpcEventfor processing.- Parameters:
event- which is submitted for processing.
-
countEvents
public int countEvents(JsonRpcEvent event)
-
close
public void close()
-
-