X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2FMDController.java;h=95c3717a4f9845c9f43cd03bccf8a77a78e95955;hb=refs%2Fheads%2Fstable%2Fboron;hp=bb333de44e3f8551d61af9bac6c0dc93cdebfb3e;hpb=7a67f5f10dab58faa6eeb0c34be3fa81e54a4336;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java index bb333de44e..95c3717a4f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java @@ -8,6 +8,11 @@ package org.opendaylight.openflowplugin.openflow.md.core; +import com.google.common.util.concurrent.ForwardingBlockingQueue; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; @@ -24,10 +29,15 @@ import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.openflowplugin.openflow.md.OFConstants; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator; +import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper; +import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey; +import org.opendaylight.openflowplugin.api.openflow.md.queue.PopListener; +import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy; +import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil; import org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorTranslator; import org.opendaylight.openflowplugin.openflow.md.core.translator.ErrorV10Translator; @@ -38,13 +48,10 @@ import org.opendaylight.openflowplugin.openflow.md.core.translator.MultiPartMess import org.opendaylight.openflowplugin.openflow.md.core.translator.MultiPartReplyPortToNodeConnectorUpdatedTranslator; import org.opendaylight.openflowplugin.openflow.md.core.translator.MultipartReplyTableFeaturesToTableUpdatedTranslator; import org.opendaylight.openflowplugin.openflow.md.core.translator.MultipartReplyTranslator; +import org.opendaylight.openflowplugin.openflow.md.core.translator.NotificationPlainTranslator; import org.opendaylight.openflowplugin.openflow.md.core.translator.PacketInTranslator; import org.opendaylight.openflowplugin.openflow.md.core.translator.PacketInV10Translator; import org.opendaylight.openflowplugin.openflow.md.core.translator.PortStatusMessageToNodeConnectorUpdatedTranslator; -import org.opendaylight.openflowplugin.openflow.md.lldp.LLDPSpeakerPopListener; -import org.opendaylight.openflowplugin.openflow.md.queue.PopListener; -import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; -import org.opendaylight.openflowplugin.statistics.MessageSpy; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate; @@ -53,7 +60,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated; @@ -91,19 +100,13 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.ForwardingBlockingQueue; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - /** * */ public class MDController implements IMDController, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MDController.class); + private final ConvertorExecutor convertorExecutor; private Collection switchConnectionProviders; @@ -116,6 +119,12 @@ public class MDController implements IMDController, AutoCloseable { private ErrorHandlerSimpleImpl errorHandler; + private ExtensionConverterProvider extensionConverterProvider; + + public MDController(ConvertorExecutor convertorExecutor) { + this.convertorExecutor = convertorExecutor; + } + /** * @return translator mapping */ @@ -129,27 +138,27 @@ public class MDController implements IMDController, AutoCloseable { public void init() { LOG.debug("init"); - OpenflowPortsUtil.init(); - messageTranslators = new ConcurrentHashMap<>(); popListeners = new ConcurrentHashMap<>(); //TODO: move registration to factory addMessageTranslator(ErrorMessage.class, OF10, new ErrorV10Translator()); addMessageTranslator(ErrorMessage.class, OF13, new ErrorTranslator()); - addMessageTranslator(FlowRemovedMessage.class, OF10, new FlowRemovedTranslator()); - addMessageTranslator(FlowRemovedMessage.class, OF13, new FlowRemovedTranslator()); + addMessageTranslator(FlowRemovedMessage.class, OF10, new FlowRemovedTranslator(convertorExecutor)); + addMessageTranslator(FlowRemovedMessage.class, OF13, new FlowRemovedTranslator(convertorExecutor)); addMessageTranslator(PacketInMessage.class,OF10, new PacketInV10Translator()); - addMessageTranslator(PacketInMessage.class,OF13, new PacketInTranslator()); + addMessageTranslator(PacketInMessage.class,OF13, new PacketInTranslator(convertorExecutor)); addMessageTranslator(PortStatusMessage.class,OF10, new PortStatusMessageToNodeConnectorUpdatedTranslator()); addMessageTranslator(PortStatusMessage.class,OF13, new PortStatusMessageToNodeConnectorUpdatedTranslator()); addMessageTranslator(MultipartReplyMessage.class,OF13,new MultiPartReplyPortToNodeConnectorUpdatedTranslator()); addMessageTranslator(MultipartReplyMessage.class,OF10, new MultiPartMessageDescToNodeUpdatedTranslator()); addMessageTranslator(MultipartReplyMessage.class,OF13, new MultiPartMessageDescToNodeUpdatedTranslator()); addMessageTranslator(ExperimenterMessage.class, OF10, new ExperimenterTranslator()); - addMessageTranslator(MultipartReplyMessage.class,OF10, new MultipartReplyTranslator()); - addMessageTranslator(MultipartReplyMessage.class,OF13, new MultipartReplyTranslator()); - addMessageTranslator(MultipartReplyMessage.class,OF13,new MultipartReplyTableFeaturesToTableUpdatedTranslator()); + addMessageTranslator(MultipartReplyMessage.class,OF10, new MultipartReplyTranslator(convertorExecutor)); + addMessageTranslator(MultipartReplyMessage.class,OF13, new MultipartReplyTranslator(convertorExecutor)); + addMessageTranslator(MultipartReplyMessage.class,OF13,new MultipartReplyTableFeaturesToTableUpdatedTranslator(convertorExecutor)); addMessageTranslator(GetFeaturesOutput.class,OF10, new FeaturesV10ToNodeConnectorUpdatedTranslator()); + addMessageTranslator(NotificationQueueWrapper.class, OF10, new NotificationPlainTranslator()); + addMessageTranslator(NotificationQueueWrapper.class, OF13, new NotificationPlainTranslator()); NotificationPopListener notificationPopListener = new NotificationPopListener(); notificationPopListener.setNotificationProviderService( @@ -174,9 +183,11 @@ public class MDController implements IMDController, AutoCloseable { addMessagePopListener(TableFeaturesErrorNotification.class, notificationPopListener); addMessagePopListener(TableModErrorNotification.class, notificationPopListener); addMessagePopListener(NodeConnectorUpdated.class,notificationPopListener); + addMessagePopListener(NodeConnectorRemoved.class,notificationPopListener); addMessagePopListener(PacketReceived.class,notificationPopListener); addMessagePopListener(TransmitPacketInput.class, notificationPopListener); addMessagePopListener(NodeUpdated.class, notificationPopListener); + addMessagePopListener(NodeRemoved.class, notificationPopListener); addMessagePopListener(SwitchFlowRemoved.class, notificationPopListener); addMessagePopListener(TableUpdated.class, notificationPopListener); @@ -204,10 +215,6 @@ public class MDController implements IMDController, AutoCloseable { //Notification registration for queue-statistics addMessagePopListener(QueueStatisticsUpdate.class, notificationPopListener); - //Notification for LLDPSpeaker - LLDPSpeakerPopListener lldpPopListener = new LLDPSpeakerPopListener(); - addMessagePopListener(NodeConnectorUpdated.class,lldpPopListener); - // Push the updated Listeners to Session Manager which will be then picked up by ConnectionConductor eventually OFSessionUtil.getSessionManager().setTranslatorMapping(messageTranslators); OFSessionUtil.getSessionManager().setPopListenerMapping(popListeners); @@ -218,6 +225,7 @@ public class MDController implements IMDController, AutoCloseable { int rpcThreadLimit = 10; ListeningExecutorService rpcPoolDelegator = createRpcPoolSpyDecorated(rpcThreadLimit, messageSpyCounter); OFSessionUtil.getSessionManager().setRpcPool(rpcPoolDelegator); + OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider); } @@ -296,18 +304,6 @@ public class MDController implements IMDController, AutoCloseable { Future> srvStarted = Futures.allAsList(starterChain); } - /** - * @return wished connections configurations - * @deprecated use configSubsystem - */ - @Deprecated - private static Collection getConnectionConfiguration() { - // TODO:: get config from state manager - ConnectionConfiguration configuration = ConnectionConfigurationFactory.getDefault(); - ConnectionConfiguration configurationLegacy = ConnectionConfigurationFactory.getLegacy(); - return Lists.newArrayList(configuration, configurationLegacy); - } - /** * Function called by the dependency manager before the services exported by * the component are unregistered, this will be followed by a "destroy ()" @@ -324,7 +320,8 @@ public class MDController implements IMDController, AutoCloseable { } Futures.allAsList(stopChain).get(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - LOG.error(e.getMessage(), e); + LOG.warn("failed to stop MDController: {}", e.getMessage()); + LOG.debug("failed to stop MDController.. ", e); } close(); } @@ -406,8 +403,14 @@ public class MDController implements IMDController, AutoCloseable { switchConnectionPrv.setSwitchConnectionHandler(null); } switchConnectionProviders = null; - OpenflowPortsUtil.close(); OFSessionUtil.releaseSessionManager(); errorHandler = null; } + + /** + * @param extensionConverterProvider extension convertor provider + */ + public void setExtensionConverterProvider(ExtensionConverterProvider extensionConverterProvider) { + this.extensionConverterProvider = extensionConverterProvider; + } }