Merge "device state holds information about device synchronization status"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / OpenFlowPluginProviderImpl.java
index a7574a03ccea17b66100ed19c7e0e66ef7930e60..7fee889d64021548b7420000e0c4aa664ee46860 100644 (file)
@@ -9,6 +9,9 @@
 package org.opendaylight.openflowplugin.impl;
 
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -28,7 +31,8 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager
 import org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl;
 import org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl;
 import org.opendaylight.openflowplugin.impl.rpc.RpcManagerImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole;
+import org.opendaylight.openflowplugin.impl.statistics.StatisticsManagerImpl;
+import org.opendaylight.openflowplugin.impl.util.TranslatorLibraryUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,22 +51,33 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider {
     private ProviderContext providerContext;
     private OfpRole role;
     private Collection<SwitchConnectionProvider> switchConnectionProviders;
+    private Long rpcRequestsQuota;
+
+    public OpenFlowPluginProviderImpl(final Long rpcRequestsQuota) {
+        this.rpcRequestsQuota = rpcRequestsQuota;
+    }
 
     @Override
     public void onSessionInitiated(final ProviderContext providerContextArg) {
         providerContext = providerContextArg;
+        final DataBroker dataBroker = providerContext.getSALService(DataBroker.class);
+        final NotificationProviderService notificationService = providerContext.getSALService(NotificationProviderService.class);
+
         connectionManager = new ConnectionManagerImpl();
-        rpcManager = new RpcManagerImpl(providerContext);
-        deviceManager = new DeviceManagerImpl(rpcManager, providerContext.getSALService(DataBroker.class));
+        deviceManager = new DeviceManagerImpl(dataBroker);
+        statisticsManager = new StatisticsManagerImpl();
+        rpcManager = new RpcManagerImpl(providerContext, rpcRequestsQuota);
+
         connectionManager.setDeviceConnectedHandler(deviceManager);
-        //TODO : initialize statistics manager
-        //TODO : initialize translatorLibrary + inject into deviceMngr
+        deviceManager.setDeviceInitializationPhaseHandler(statisticsManager);
+        deviceManager.setNotificationService(notificationService);
+        statisticsManager.setDeviceInitializationPhaseHandler(rpcManager);
+        rpcManager.setDeviceInitializationPhaseHandler(deviceManager);
+
+        TranslatorLibraryUtil.setBasicTranslatorLibrary(deviceManager);
         startSwitchConnections();
     }
 
-    /**
-     * @param connectionManager2
-     */
     private void startSwitchConnections() {
         final List<ListenableFuture<Boolean>> starterChain = new ArrayList<>(switchConnectionProviders.size());
         for (final SwitchConnectionProvider switchConnectionPrv : switchConnectionProviders) {
@@ -78,6 +93,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider {
                 LOG.info("All switchConnectionProviders are up and running ({}).",
                         result.size());
             }
+
             @Override
             public void onFailure(final Throwable t) {
                 LOG.warn("Some switchConnectionProviders failed to start.", t);
@@ -95,6 +111,7 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider {
         this.role = role;
     }
 
+
     @Override
     public void setBindingAwareBroker(final BindingAwareBroker bindingAwareBroker) {
         this.bindingAwareBroker = bindingAwareBroker;