X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fapi%2FNotificationPublishService.java;h=5ec51269b738df3e7625133773a2d72cf1af7705;hp=87e37ffed1dbf0f1e9bc2fdb7c366427b314078c;hb=0f518a7ba2c8ceb3b4e9d038faca7c9b315db7d4;hpb=a30d7fb04b2134d68399a20eaf859e317d40c71a diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java index 87e37ffed1..5ec51269b7 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/NotificationPublishService.java @@ -7,6 +7,8 @@ */ package org.opendaylight.controller.md.sal.binding.api; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.TimeUnit; import org.opendaylight.yangtools.yang.binding.Notification; @@ -26,6 +28,13 @@ import org.opendaylight.yangtools.yang.binding.Notification; * notification has or has not been seen. */ public interface NotificationPublishService extends BindingService { + + /** + * Well-known value indicating that the binding-aware implementation is currently not + * able to accept a notification. + */ + ListenableFuture REJECTED = Futures.immediateFailedFuture(new NotificationRejectedException("Rejected due to resource constraints.")); + /** * Publishes a notification to subscribed listeners. This initiates * the process of sending the notification, but delivery to the @@ -47,14 +56,16 @@ public interface NotificationPublishService extends BindingService { * listeners can happen asynchronously, potentially after a call to * this method returns. * - * This method is guaranteed not to block. + * Still guaranteed not to block. Returns Listenable Future which will complete once. * * @param notification * the notification to publish. - * @return true if the notification was accepted for processing, false otherwise + * @return A listenable future which will report completion when the service has finished + * propagating the notification to its immediate registrants, or {@value #REJECTED} if resource + * constraints prevent * @throws NullPointerException if the notification is null */ - boolean offerNotification(Notification notification); + ListenableFuture offerNotification(Notification notification); /** * Publishes a notification to subscribed listeners. This initiates @@ -68,11 +79,14 @@ public interface NotificationPublishService extends BindingService { * @param timeout how long to wait before giving up, in units of unit * @param unit a TimeUnit determining how to interpret the * timeout parameter - * @return true if the notification was accepted for processing, false otherwise + * @return A listenable future which will report completion when the service has finished + * propagating the notification to its immediate registrants, or {@value #REJECTED} if resource + * constraints prevent * @throws InterruptedException if interrupted while waiting * @throws NullPointerException if the notification or unit is null * @throws IllegalArgumentException if timeout is negative. */ - boolean offerNotification(Notification notification, int timeout, TimeUnit unit) - throws InterruptedException; + ListenableFuture offerNotification(Notification notification, int timeout, TimeUnit unit) + throws InterruptedException; + }