Merge "BUG-1421: VLAN tag"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / MDController.java
index 945b663fbd1e23a73a2c2eac95fe490447d441bc..67196af6dc260a83af11b6b6c548435b10345e28 100644 (file)
@@ -27,7 +27,9 @@ 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.TranslatorKey;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterProvider;
 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;
@@ -42,8 +44,9 @@ import org.opendaylight.openflowplugin.openflow.md.core.translator.PacketInTrans
 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.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.queue.PopListener;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.openflowplugin.api.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;
@@ -115,6 +118,8 @@ public class MDController implements IMDController, AutoCloseable {
 
     private ErrorHandlerSimpleImpl errorHandler;
 
+    private ExtensionConverterProvider extensionConverterProvider;
+
     /**
      * @return translator mapping
      */
@@ -127,6 +132,9 @@ 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
@@ -214,6 +222,7 @@ public class MDController implements IMDController, AutoCloseable {
         int rpcThreadLimit = 10;
         ListeningExecutorService rpcPoolDelegator = createRpcPoolSpyDecorated(rpcThreadLimit, messageSpyCounter);
         OFSessionUtil.getSessionManager().setRpcPool(rpcPoolDelegator);
+        OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider);
 
     }
 
@@ -239,7 +248,7 @@ public class MDController implements IMDController, AutoCloseable {
         };
 
         ThreadPoolLoggingExecutor rpcPool = new ThreadPoolLoggingExecutor(rpcThreadLimit, rpcThreadLimit, 0L,
-                TimeUnit.MILLISECONDS, queue);
+                TimeUnit.MILLISECONDS, queue, "OFRpc");
         rpcPool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
                        @Override
                        public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
@@ -402,7 +411,15 @@ public class MDController implements IMDController, AutoCloseable {
             switchConnectionPrv.setSwitchConnectionHandler(null);
         }
         switchConnectionProviders = null;
+        OpenflowPortsUtil.close();
         OFSessionUtil.releaseSessionManager();
         errorHandler = null;
     }
+
+    /**
+     * @param extensionConverterProvider
+     */
+    public void setExtensionConverterProvider(ExtensionConverterProvider extensionConverterProvider) {
+        this.extensionConverterProvider = extensionConverterProvider;
+    }
 }