Mastershipchange service implementation.
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / lifecycle / ContextChainHolder.java
index d043c7ea2188d75f071dcfeb9259d60cfcec5768..490436ce7bfc2701cada56e61aa7c182fa496667 100644 (file)
@@ -7,27 +7,53 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
-import java.util.concurrent.Future;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
 import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceRemovedHandler;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
+import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
+import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 
 /**
- * Generic interface for context chain holder, hold all created context chains
+ * Generic interface for context chain holder, hold all created context chains.
+ * {@link ContextChain} is context that suppose to hold old information about device such as
+ * <ul>
+ *     <li>{@link DeviceContext}</li>
+ *     <li>{@link RpcContext}</li>
+ *     <li>{@link StatisticsContext}</li>
+ * </ul>
+ * Each context is created right after device connect and hold information about particular part of device.
+ * @since 0.4.0 Carbon
+ * @see StatisticsContext
+ * @see RpcContext
+ * @see DeviceContext
  */
-public interface ContextChainHolder {
-
-    <T extends OFPManager> void addManager(final T manager);
-    Future<Void> createContextChain(final DeviceInfo deviceInfo);
-    Future<Void> connectionLost(final DeviceInfo deviceInfo);
-    void destroyContextChain(final DeviceInfo deviceInfo);
+public interface ContextChainHolder extends
+        DeviceConnectedHandler,
+        ContextChainMastershipWatcher,
+        DeviceDisconnectedHandler,
+        DeviceRemovedHandler,
+        EntityOwnershipListener,
+        AutoCloseable {
 
     /**
-     * This method will pair up connection with existing context chain
-     * If context chain doesn't exist will create context chain a set this connection as primary to the new created context chain
-     * If context chain cannot be created close connection and destroy context chain
-     * @param connectionContext new connection
+     * Managers need to be added before.
+     * {@link DeviceManager}
+     * {@link RpcManager}
+     * {@link StatisticsManager}
+     * @param manager a child class of {@link OFPManager}
+     * @param <T> {@link OFPManager}
      */
-    void pairConnection(final ConnectionContext connectionContext);
+    <T extends OFPManager> void addManager(T manager);
+
+    @Override
+    void close() throws Exception;
 
 }