Bug 6110: Fixed bugs in statistics manager due to race condition.
[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 AutoCloseable, ClusterLifecycleSupervisor, ClusterInitializationPhaseHandler {
22     /**
23      * Context state
24      */
25     enum CONTEXT_STATE {
26         /* Initialization phase, context not yet fully initialized */
27         INITIALIZATION,
28         /* Standard working phase everything is fine */
29         WORKING,
30         /* Termination phase context is being shutting down */
31         TERMINATION
32     }
33
34     /**
35      * Get actual context state
36      * @return actual context state
37      */
38     CONTEXT_STATE getState();
39
40     /**
41      * About to stop services in cluster not master anymore or going down
42      * @return Future most of services need time to be closed
43      * @param connectionInterrupted true if clustering services stopping by device disconnect
44      */
45     default ListenableFuture<Void> stopClusterServices(boolean connectionInterrupted) {
46         return Futures.immediateFailedFuture(new RejectedExecutionException("Cannot stop abstract services, check implementation of cluster services"));
47     }
48
49     /**
50      * Get cluster singleton service identifier
51      * @return cluster singleton service identifier
52      */
53     ServiceGroupIdentifier getServiceIdentifier();
54
55     /**
56      * Get device info
57      * @return device info
58      */
59     DeviceInfo getDeviceInfo();
60
61     @Override
62     void close();
63 }