X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fdevice%2FDeviceContextImpl.java;h=16ae98f5996fd690e030f2bd7e4359cb4f90eb86;hb=c65275bb09353d58610a644d1dfb70299143742c;hp=0f70c7ac1e06c65102ceca7f13df3d198db97ea1;hpb=f103849e1628bd5d86576087b4b1cc3ea936174b;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java index 0f70c7ac1e..16ae98f599 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java @@ -41,6 +41,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContex import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector; import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher; import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey; +import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry; import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry; @@ -84,11 +85,12 @@ public class DeviceContextImpl implements DeviceContext { private static final Logger LOG = LoggerFactory.getLogger(DeviceContextImpl.class); - // TODO: watermarks should be derived from effective rpc limit (75%|95%) - private static final int PACKETIN_LOW_WATERMARK = 15000; - private static final int PACKETIN_HIGH_WATERMARK = 19000; // TODO: drain factor should be parametrized public static final float REJECTED_DRAIN_FACTOR = 0.25f; + // TODO: low water mark factor should be parametrized + private static final float LOW_WATERMARK_FACTOR = 0.75f; + // TODO: high water mark factor should be parametrized + private static final float HIGH_WATERMARK_FACTOR = 0.95f; private final ConnectionContext primaryConnectionContext; private final DeviceState deviceState; @@ -110,6 +112,7 @@ public class DeviceContextImpl implements DeviceContext { private final MessageTranslator packetInTranslator; private final TranslatorLibrary translatorLibrary; private Map nodeConnectorCache; + private ItemLifeCycleRegistry itemLifeCycleSourceRegistry; @VisibleForTesting @@ -134,7 +137,7 @@ public class DeviceContextImpl implements DeviceContext { messageSpy = _messageSpy; packetInLimiter = new PacketInRateLimiter(primaryConnectionContext.getConnectionAdapter(), - PACKETIN_LOW_WATERMARK, PACKETIN_HIGH_WATERMARK, messageSpy, REJECTED_DRAIN_FACTOR); + /*initial*/ 1000, /*initial*/2000, messageSpy, REJECTED_DRAIN_FACTOR); this.translatorLibrary = translatorLibrary; portStatusTranslator = translatorLibrary.lookupTranslator( @@ -142,6 +145,8 @@ public class DeviceContextImpl implements DeviceContext { packetInTranslator = translatorLibrary.lookupTranslator( new TranslatorKey(deviceState.getVersion(), PacketIn.class.getName())); nodeConnectorCache = new ConcurrentHashMap<>(); + + itemLifeCycleSourceRegistry = new ItemLifeCycleRegistryImpl(); } /** @@ -351,6 +356,8 @@ public class DeviceContextImpl implements DeviceContext { deviceFlowRegistry.close(); deviceMeterRegistry.close(); + itemLifeCycleSourceRegistry.clear(); + for (final DeviceContextClosedHandler deviceContextClosedHandler : closeHandlers) { deviceContextClosedHandler.onDeviceContextClosed(this); @@ -430,4 +437,14 @@ public class DeviceContextImpl implements DeviceContext { Preconditions.checkNotNull(portNumber), Preconditions.checkNotNull(nodeConnectorRef)); } + + @Override + public void updatePacketInRateLimit(long upperBound) { + packetInLimiter.changeWaterMarks((int) (LOW_WATERMARK_FACTOR * upperBound), (int) (HIGH_WATERMARK_FACTOR * upperBound)); + } + + @Override + public ItemLifeCycleRegistry getItemLifeCycleSourceRegistry() { + return itemLifeCycleSourceRegistry; + } }