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