From 27f402a23af92655acb275cf01bd2aa289d7e756 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 18:36:14 +0200 Subject: [PATCH] ThrottledNotificationsOfferer should not be generic The only use of the type argument is to bind method arguments -- which we can spell out. This way we can reuse an offerer across multiple types without incurring warnings. Change-Id: Ie003f6c9ebe00f1abae4f8171086a7240843a14c Signed-off-by: Robert Varga --- .../connection/ThrottledNotificationsOfferer.java | 7 ++++--- .../ThrottledNotificationsOffererImpl.java | 14 +++++++------- .../impl/device/DeviceManagerImpl.java | 5 ++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ThrottledNotificationsOfferer.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ThrottledNotificationsOfferer.java index 3fae497d7a..4c42fa7ebb 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ThrottledNotificationsOfferer.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/connection/ThrottledNotificationsOfferer.java @@ -10,15 +10,16 @@ package org.opendaylight.openflowplugin.api.openflow.connection; 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 extends AutoCloseable { +public interface ThrottledNotificationsOfferer extends AutoCloseable { - ListenableFuture applyThrottlingOnConnection(Queue notificationsQueue); + ListenableFuture applyThrottlingOnConnection(Queue notificationsQueue); - boolean isThrottlingEffective(Queue notificationsQueue); + boolean isThrottlingEffective(Queue notificationsQueue); @Override void close() throws SecurityException; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ThrottledNotificationsOffererImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ThrottledNotificationsOffererImpl.java index 85403b8024..92e80a45aa 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ThrottledNotificationsOffererImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/ThrottledNotificationsOffererImpl.java @@ -27,10 +27,10 @@ import org.slf4j.LoggerFactory; /** * Created by Martin Bobak <mbobak@cisco.com> on 8.5.2015. */ -public class ThrottledNotificationsOffererImpl implements ThrottledNotificationsOfferer, Runnable { +public class ThrottledNotificationsOffererImpl implements ThrottledNotificationsOfferer, Runnable { private static final Logger LOG = LoggerFactory.getLogger(ThrottledNotificationsOffererImpl.class); - private final Map, SettableFuture> throttledQueues = new ConcurrentHashMap<>(); + private final Map, SettableFuture> throttledQueues = new ConcurrentHashMap<>(); private final ThreadPoolLoggingExecutor throttleWorkerPool; private final NotificationPublishService notificationPublishService; private final MessageSpy messageIntelligenceAgency; @@ -51,7 +51,7 @@ public class ThrottledNotificationsOffererImpl implement } @Override - public ListenableFuture applyThrottlingOnConnection(final Queue notificationsQueue) { + public ListenableFuture applyThrottlingOnConnection(final Queue notificationsQueue) { SettableFuture throttleWatching = SettableFuture.create(); throttledQueues.put(notificationsQueue, throttleWatching); synchronized (throttledQueues) { @@ -77,9 +77,9 @@ public class ThrottledNotificationsOffererImpl implement // NOOP } } else { - for (Map.Entry, SettableFuture> throttledTuple : throttledQueues.entrySet()) { - Queue key = throttledTuple.getKey(); - T notification = key.poll(); + for (Map.Entry, SettableFuture> throttledTuple : throttledQueues.entrySet()) { + Queue key = throttledTuple.getKey(); + Notification notification = key.poll(); if (notification == null) { synchronized (key) { // free throttling and announce via future @@ -106,7 +106,7 @@ public class ThrottledNotificationsOffererImpl implement } @Override - public boolean isThrottlingEffective(final Queue notificationsQueue) { + public boolean isThrottlingEffective(final Queue notificationsQueue) { return throttledQueues.containsKey(notificationsQueue); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java index ee2ea6daa3..57d876f1d3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java @@ -75,7 +75,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 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; @@ -115,7 +114,7 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable { private DeviceInitializationPhaseHandler deviceInitPhaseHandler; private NotificationService notificationService; private NotificationPublishService notificationPublishService; - private ThrottledNotificationsOfferer throttledNotificationsOfferer; + private ThrottledNotificationsOfferer throttledNotificationsOfferer; private final List deviceContexts = new ArrayList(); private final MessageIntelligenceAgency messageIntelligenceAgency; @@ -509,6 +508,6 @@ public class DeviceManagerImpl implements DeviceManager, AutoCloseable { spyPool = new ScheduledThreadPoolExecutor(1); spyPool.scheduleAtFixedRate(messageIntelligenceAgency, spyRate, spyRate, TimeUnit.SECONDS); - throttledNotificationsOfferer = new ThrottledNotificationsOffererImpl<>(notificationPublishService, messageIntelligenceAgency); + throttledNotificationsOfferer = new ThrottledNotificationsOffererImpl(notificationPublishService, messageIntelligenceAgency); } } -- 2.36.6