2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.mdsal.binding.javav2.api;
11 import com.google.common.annotations.Beta;
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import java.util.concurrent.TimeUnit;
15 import org.opendaylight.mdsal.binding.javav2.spec.base.Notification;
18 * A {@link NotificationService} which also allows its users to submit YANG-modeled notifications for delivery.
21 * There are three methods of submission, following the patters from {@link java.util.concurrent.BlockingQueue}:
24 * - {@link #putNotification(org.opendaylight.mdsal.binding.javav2.spec.base.Notification)}, which may block
25 * indefinitely if the implementation cannot allocate resources to accept the notification,
26 * - {@link #offerNotification(org.opendaylight.mdsal.binding.javav2.spec.base.Notification)}, which does not block if
27 * face of resource starvation,
28 * - {@link #offerNotification(org.opendaylight.mdsal.binding.javav2.spec.base.Notification, int, TimeUnit)}, which may
29 * block for specified time if resources are thin.
32 * The actual delivery to listeners is asynchronous and implementation-specific.
33 * Users of this interface should not make any assumptions as to whether the
34 * notification has or has not been seen.
38 public interface NotificationPublishService extends BindingService {
40 ListenableFuture<Object> REJECTED = Futures.immediateFailedFuture(
41 new NotificationRejectedException("Rejected due to resource constraints."));
43 void putNotification(Notification<?> notification) throws InterruptedException;
45 ListenableFuture<?> offerNotification(Notification<?> notification);
47 ListenableFuture<?> offerNotification(Notification<?> notification, int timeout, TimeUnit unit)
48 throws InterruptedException;