Disconnection improvements.
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / lifecycle / ContextChain.java
1 /*
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. 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.lifecycle;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
13 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
14 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.ContextChainState;
17
18 /**
19  * Chain of contexts, hold references to the contexts
20  */
21 public interface ContextChain extends AutoCloseable {
22
23     /**
24      * Check if all context are referenced and not null
25      * @return false if reference for some context is missing
26      */
27     boolean isReady();
28
29     /**
30      * Add context to the chain, if reference already exist ignore it
31      * @param context child of OFPContext
32      */
33     <T extends OFPContext> void addContext(final T context);
34
35     void addLifecycleService(final LifecycleService lifecycleService);
36
37     /**
38      * Stop the working contexts, but not release them
39      * @return Future
40      * @param connectionDropped
41      */
42     ListenableFuture<Void> stopChain(boolean connectionDropped);
43
44     /**
45      * Start the contexts, if some context is missing or cant be started returns failed future
46      * @return Future
47      */
48     ListenableFuture<Void> startChain();
49
50     @Override
51     void close();
52
53     /**
54      * Change connection if connection were drop and rebuild
55      * @param connectionContext
56      */
57     void changePrimaryConnection(final ConnectionContext connectionContext);
58
59     ListenableFuture<Void> connectionDropped();
60
61     ContextChainState getContextChainState();
62
63     ConnectionContext getPrimaryConnectionContext();
64
65     void sleepTheChainAndDropConnection();
66
67     void registerServices(@NonNull final ClusterSingletonServiceProvider clusterSingletonServiceProvider);
68
69     void makeDeviceSlave();
70
71     void closePrimaryConnection();
72
73     DeviceContext provideDeviceContext();
74 }