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
-
-
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 void
cleanupOldEvents()
void
close()
int
countEvents(JsonRpcEvent event)
void
process(JsonRpcEvent event)
This method is used by @linkResponseWorker
to submit an @linkJsonRpcEvent
for processing.void
publish(java.lang.String subscriptionId, java.util.Map<java.lang.String,java.lang.Object> params)
RequestPublisher
to send data.void
subscribe(EventSubscriber subscriber)
RequestPublisher
to start streaming data.
-
-
-
Method Detail
-
cleanupOldEvents
public void cleanupOldEvents()
-
subscribe
public void subscribe(EventSubscriber subscriber)
Description copied from interface:Publisher
RequestPublisher
to start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
.Each
Subscription
will work for only a singleSubscriber
.A
Subscriber
should only subscribe once to a singlePublisher
.If the
Publisher
rejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(java.lang.Throwable)
.- Specified by:
subscribe
in interfacePublisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>
- Parameters:
subscriber
- theSubscriber
that 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.IOException
Description copied from interface:Publisher
RequestPublisher
to send data.- Specified by:
publish
in interfacePublisher<java.util.Map<java.lang.String,java.lang.Object>,EventSubscriber>
- Parameters:
subscriptionId
- the identifier forSubscriber
who 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
public void process(JsonRpcEvent event)
This method is used by @linkResponseWorker
to submit an @linkJsonRpcEvent
for processing.- Parameters:
event
- which is submitted for processing.
-
countEvents
public int countEvents(JsonRpcEvent event)
-
close
public void close()
-
-