fad140245183c3a4e79fe7a3e1ab54c5e11f5301
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / OFPContext.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.api.openflow;
9
10 import com.google.common.util.concurrent.Futures;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import java.util.concurrent.RejectedExecutionException;
13 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
15 import org.opendaylight.openflowplugin.api.openflow.device.handlers.ClusterInitializationPhaseHandler;
16 import org.opendaylight.openflowplugin.api.openflow.device.handlers.ClusterLifecycleSupervisor;
17
18 /**
19  * General API for all OFP Context
20  */
21 public interface OFPContext extends ClusterLifecycleSupervisor, ClusterInitializationPhaseHandler {
22
23     void setState(CONTEXT_STATE contextState);
24
25     /**
26      * Context state
27      */
28     enum CONTEXT_STATE {
29         /* Initialization phase, context not yet fully initialized */
30         INITIALIZATION,
31         /* Standard working phase everything is fine */
32         WORKING,
33         /* Termination phase context is being shutting down */
34         TERMINATION
35     }
36
37     /**
38      * @return actual context state
39      */
40     CONTEXT_STATE getState();
41
42     /**
43      * About to stop services in cluster not master anymore or going down
44      * @return Future most of services need time to be closed
45      * @param deviceDisconnected true if clustering services stopping by device disconnect
46      */
47     default ListenableFuture<Void> stopClusterServices(final boolean deviceDisconnected){
48         return Futures.immediateFailedFuture(new RejectedExecutionException("Cannot stop abstract services, check implementation of cluster services"));
49     }
50
51     /**
52      * @return cluster singleton service identifier
53      */
54     ServiceGroupIdentifier getServiceIdentifier();
55
56     /**
57      * @return device info
58      */
59     DeviceInfo getDeviceInfo();
60
61 }