Bug 5596 Created lifecycle service
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / OFPContext.java
index 9e8227e5b5845b4e8b6350016ae9aaec9a6bd75b..7bd11c9be76fe8463c413cee753c61c70b67396f 100644 (file)
@@ -7,6 +7,13 @@
  */
 package org.opendaylight.openflowplugin.api.openflow;
 
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.RejectedExecutionException;
+import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+
 /**
  * General API for all OFP Context
  */
@@ -17,23 +24,45 @@ public interface OFPContext {
     }
 
     /**
-     * distinguished device context states
+     * Context state
      */
     enum CONTEXT_STATE {
-        /**
-         * initial phase
-         */
+        /* Initialization phase, context not yet fully initialized */
         INITIALIZATION,
-        /**
-         * standard phase
-         */
+        /* Standard working phase everything is fine */
         WORKING,
-        /**
-         * termination phase
-         */
+        /* Termination phase context is being shutting down */
         TERMINATION
     }
 
+    /**
+     * @return actual context state
+     */
     CONTEXT_STATE getState();
 
+    /**
+     * Starting cluster services for context becoming master
+     */
+    default void startupClusterServices() throws ExecutionException, InterruptedException {
+        throw new InterruptedException("Cannot start abstract service, check implementation of cluster services");
+    }
+
+    /**
+     * About to stop services in cluster not master anymore or going down
+     * @return Future most of services need time to be closed
+     */
+    default ListenableFuture<Void> stopClusterServices(){
+        return Futures.immediateFailedFuture(new RejectedExecutionException("Cannot stop abstract services, check implementation of cluster services"));
+    }
+
+    /**
+     * @return cluster singleton service identifier
+     */
+    ServiceGroupIdentifier getServiceIdentifier();
+
+    /**
+     * @return device info
+     */
+    DeviceInfo getDeviceInfo();
+
 }