import com.google.common.util.concurrent.ListenableFuture;
import java.util.Queue;
+import org.opendaylight.yangtools.yang.binding.Notification;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 8.5.2015.
*/
-public interface ThrottledNotificationsOfferer<T> extends AutoCloseable {
+public interface ThrottledNotificationsOfferer extends AutoCloseable {
- ListenableFuture<Void> applyThrottlingOnConnection(Queue<T> notificationsQueue);
+ ListenableFuture<Void> applyThrottlingOnConnection(Queue<? extends Notification> notificationsQueue);
- boolean isThrottlingEffective(Queue<T> notificationsQueue);
+ boolean isThrottlingEffective(Queue<? extends Notification> notificationsQueue);
@Override
void close() throws SecurityException;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 8.5.2015.
*/
-public class ThrottledNotificationsOffererImpl<T extends Notification> implements ThrottledNotificationsOfferer<T>, Runnable {
+public class ThrottledNotificationsOffererImpl implements ThrottledNotificationsOfferer, Runnable {
private static final Logger LOG = LoggerFactory.getLogger(ThrottledNotificationsOffererImpl.class);
- private final Map<Queue<T>, SettableFuture<Void>> throttledQueues = new ConcurrentHashMap<>();
+ private final Map<Queue<? extends Notification>, SettableFuture<Void>> throttledQueues = new ConcurrentHashMap<>();
private final ThreadPoolLoggingExecutor throttleWorkerPool;
private final NotificationPublishService notificationPublishService;
private final MessageSpy messageIntelligenceAgency;
}
@Override
- public ListenableFuture<Void> applyThrottlingOnConnection(final Queue<T> notificationsQueue) {
+ public ListenableFuture<Void> applyThrottlingOnConnection(final Queue<? extends Notification> notificationsQueue) {
SettableFuture<Void> throttleWatching = SettableFuture.create();
throttledQueues.put(notificationsQueue, throttleWatching);
synchronized (throttledQueues) {
// NOOP
}
} else {
- for (Map.Entry<Queue<T>, SettableFuture<Void>> throttledTuple : throttledQueues.entrySet()) {
- Queue<T> key = throttledTuple.getKey();
- T notification = key.poll();
+ for (Map.Entry<Queue<? extends Notification>, SettableFuture<Void>> throttledTuple : throttledQueues.entrySet()) {
+ Queue<? extends Notification> key = throttledTuple.getKey();
+ Notification notification = key.poll();
if (notification == null) {
synchronized (key) {
// free throttling and announce via future
}
@Override
- public boolean isThrottlingEffective(final Queue<T> notificationsQueue) {
+ public boolean isThrottlingEffective(final Queue<? extends Notification> notificationsQueue) {
return throttledQueues.containsKey(notificationsQueue);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
private NotificationService notificationService;
private NotificationPublishService notificationPublishService;
- private ThrottledNotificationsOfferer<PacketInMessage> throttledNotificationsOfferer;
+ private ThrottledNotificationsOfferer throttledNotificationsOfferer;
private final List<DeviceContext> deviceContexts = new ArrayList<DeviceContext>();
private final MessageIntelligenceAgency messageIntelligenceAgency;
spyPool = new ScheduledThreadPoolExecutor(1);
spyPool.scheduleAtFixedRate(messageIntelligenceAgency, spyRate, spyRate, TimeUnit.SECONDS);
- throttledNotificationsOfferer = new ThrottledNotificationsOffererImpl<>(notificationPublishService, messageIntelligenceAgency);
+ throttledNotificationsOfferer = new ThrottledNotificationsOffererImpl(notificationPublishService, messageIntelligenceAgency);
}
}