Merge "Bug 4957 RoleContext updated with initialization"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / OpenflowPluginProvider.java
index 149f6c4610c7466124fe32f1cefc379e74b36112..c151c04faa30ad41317fe1e2a9386d8145a56169 100644 (file)
@@ -22,9 +22,11 @@ import org.opendaylight.openflowplugin.openflow.md.core.MDController;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFRoleManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.OfpRole;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,9 +50,11 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     private OfpRole role;
 
     private OFRoleManager roleManager;
+    private OfEntityManager entManager;
     private DataBroker dataBroker;
     private NotificationProviderService notificationService;
     private RpcProviderRegistry rpcRegistry;
+    private EntityOwnershipService entityOwnershipService;
 
     /**
      * Initialization of services and msgSpy counter
@@ -59,12 +63,15 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         messageCountProvider = new MessageSpyCounterImpl();
         extensionConverterManager = new ExtensionConverterManagerImpl();
         roleManager = new OFRoleManager(OFSessionUtil.getSessionManager());
+        entManager = new OfEntityManager(entityOwnershipService);
+        entManager.setDataBroker(dataBroker);
 
         LOG.debug("dependencies gathered..");
         registrationManager = new SalRegistrationManager();
         registrationManager.setDataService(dataBroker);
         registrationManager.setPublishService(notificationService);
         registrationManager.setRpcProviderRegistry(rpcRegistry);
+        registrationManager.setOfEntityManager(entManager);
         registrationManager.init();
 
         mdController = new MDController();
@@ -76,7 +83,7 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     }
 
     /**
-     * @param switchConnectionProvider
+     * @param switchConnectionProvider switch connection provider
      */
     public void setSwitchConnectionProviders(Collection<SwitchConnectionProvider> switchConnectionProvider) {
         this.switchConnectionProviders = switchConnectionProvider;
@@ -111,11 +118,11 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
     }
 
     /**
-     * @param newRole
+     * @param newRole new controller role
      */
     public void fireRoleChange(OfpRole newRole) {
         if (!role.equals(newRole)) {
-            LOG.debug("my role was chaged from {} to {}", role, newRole);
+            LOG.debug("Controller role was changed from {} to {}", role, newRole);
             role = newRole;
             switch (role) {
                 case BECOMEMASTER:
@@ -149,6 +156,10 @@ public class OpenflowPluginProvider implements AutoCloseable, OpenFlowPluginExte
         this.rpcRegistry = rpcRegistry;
     }
 
+    public void setEntityOwnershipService(EntityOwnershipService entityOwnershipService) {
+        this.entityOwnershipService = entityOwnershipService;
+    }
+
     @VisibleForTesting
     protected RpcProviderRegistry getRpcRegistry() {
         return rpcRegistry;