871adf3bc707a5aac7f98023cab3363dc91087a3
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / device / DeviceContext.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
9 package org.opendaylight.openflowplugin.api.openflow.device;
10
11 import com.google.common.util.concurrent.ListenableFuture;
12 import io.netty.util.Timeout;
13 import java.math.BigInteger;
14 import java.util.List;
15 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
16 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
17 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
18 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
19 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
20 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
21 import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
22 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
24
25 /**
26  * <p>
27  * The central entity of OFP is the Device Context, which encapsulate the logical state of a switch
28  * as seen by the controller. Each OpenFlow session is tracked by a Connection Context.
29  * These attach to a particular Device Context in such a way, that there is at most one primary
30  * session associated with a Device Context. Whenever the controller needs to interact with a
31  * particular switch, it will do so in the context of the calling thread, obtaining a lock on
32  * the corresponding Device Context – thus the Device Context becomes the fine-grained point
33  * of synchronization. The only two entities allowed to send requests towards the switch are
34  * Statistics Manager and RPC Manager. Each of them allocates a Request Context for interacting
35  * with a particular Device Context. The Request Contexts are the basic units of fairness,
36  * which is enforced by keeping a cap on the number of outstanding requests a particular Request
37  * Context can have at any point in time. Should this quota be exceeded, any further attempt to make
38  * a request to the switch will fail immediately, with proper error indication.
39  * </p>
40  */
41 public interface DeviceContext extends
42         OFPContext,
43         AutoCloseable,
44         DeviceReplyProcessor,
45         TxFacade,
46         XidSequencer,
47         DeviceRegistry{
48
49     /**
50      * Method close all auxiliary connections and primary connection.
51      */
52     void shutdownConnection();
53
54     /**
55      * Method add auxiliary connection contexts to this context representing single device connection.
56      * @param connectionContext new connection context
57      */
58     void addAuxiliaryConnectionContext(ConnectionContext connectionContext);
59
60     /**
61      * Method removes auxiliary connection context from this context representing single device connection.
62      * @param connectionContext connection which need to be removed
63      */
64     void removeAuxiliaryConnectionContext(ConnectionContext connectionContext);
65
66     /**
67      * Method provides state of device represented by this device context.
68      *
69      * @return {@link DeviceState}
70      */
71     DeviceState getDeviceState();
72
73     /**
74      * Method has to close TxManager ASAP we are notified about Closed Connection
75      * @return sync. future for Slave and MD-SAL completition for Master
76      */
77     ListenableFuture<Void> shuttingDownDataStoreTransactions();
78
79     /**
80      * @return current devices connection context
81      */
82     ConnectionContext getPrimaryConnectionContext();
83
84     /**
85      * @return current devices auxiliary connection contexts
86      */
87     ConnectionContext getAuxiliaryConnectiobContexts(BigInteger cookie);
88
89
90     /**
91      * @return translator library
92      */
93     TranslatorLibrary oook();
94
95     /**
96      * store cancellable timeout handler of currently running barrier task
97      */
98     void setCurrentBarrierTimeout(Timeout timeout);
99
100     /**
101      * @return cancellable timeout handle of currently running barrier task
102      */
103     Timeout getBarrierTaskTimeout();
104
105     void setNotificationPublishService(NotificationPublishService notificationPublishService);
106
107     MessageSpy getMessageSpy();
108
109     MultiMsgCollector getMultiMsgCollector(final RequestContext<List<MultipartReply>> requestContext);
110
111     /**
112      * indicates that device context is fully published (e.g.: packetIn messages should be passed)
113      */
114     void onPublished();
115
116     /**
117      * change packetIn rate limiter borders
118      *
119      * @param upperBound max amount of outstanding packetIns
120      */
121     void updatePacketInRateLimit(long upperBound);
122
123     /**
124      * @return registry point for item life cycle sources of device
125      */
126     ItemLifeCycleRegistry getItemLifeCycleSourceRegistry();
127
128     @Override
129     void close();
130
131     void setSwitchFeaturesMandatory(boolean switchFeaturesMandatory);
132
133     void registerClusterSingletonServices(ClusterSingletonServiceProvider singletonServiceProvider);
134
135 }
136