Fixup openflow-protocol-impl dependencies
[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 package org.opendaylight.openflowplugin.api.openflow.device;
9
10 import com.google.common.annotations.Beta;
11 import java.util.List;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.openflowplugin.api.openflow.FlowGroupInfoHistory;
15 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
16 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
18 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
19 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainStateListener;
20 import org.opendaylight.openflowplugin.api.openflow.lifecycle.DeviceInitializationContext;
21 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
23
24 /**
25  * The central entity of OFP is the Device Context, which encapsulate the logical state of a switch
26  * as seen by the controller. Each OpenFlow session is tracked by a Connection Context.
27  * These attach to a particular Device Context in such a way, that there is at most one primary
28  * session associated with a Device Context. Whenever the controller needs to interact with a
29  * particular switch, it will do so in the context of the calling thread, obtaining a lock on
30  * the corresponding Device Context – thus the Device Context becomes the fine-grained point
31  * of synchronization. The only two entities allowed to send requests towards the switch are
32  * Statistics Manager and RPC Manager. Each of them allocates a Request Context for interacting
33  * with a particular Device Context. The Request Contexts are the basic units of fairness,
34  * which is enforced by keeping a cap on the number of outstanding requests a particular Request
35  * Context can have at any point in time. Should this quota be exceeded, any further attempt to make
36  * a request to the switch will fail immediately, with proper error indication.
37  */
38 public interface DeviceContext extends
39         OFPContext,
40         DeviceReplyProcessor,
41         TxFacade,
42         DeviceRegistry,
43         RequestContextStack,
44         ContextChainStateListener,
45         DeviceInitializationContext {
46
47     /**
48      * Method provides state of device represented by this device context.
49      *
50      * @return {@link DeviceState}
51      */
52     DeviceState getDeviceState();
53
54     /**
55      * Getter.
56      *
57      * @return current devices connection context
58      */
59     ConnectionContext getPrimaryConnectionContext();
60
61     /**
62      * Getter.
63      *
64      * @return translator library
65      */
66     TranslatorLibrary oook();
67
68     /**
69      * Sets notification publish service.
70      *
71      * @param notificationPublishService the notification publish service
72      */
73     void setNotificationPublishService(NotificationPublishService notificationPublishService);
74
75     /**
76      * Gets message spy.
77      *
78      * @return the message spy
79      */
80     MessageSpy getMessageSpy();
81
82     /**
83      * Gets multi msg collector.
84      *
85      * @param <T>            the type parameter
86      * @param requestContext the request context
87      * @return the multi msg collector
88      */
89     <T extends OfHeader> MultiMsgCollector<T> getMultiMsgCollector(RequestContext<List<T>> requestContext);
90
91     /**
92      * Indicates that device context is fully published (e.g.: packetIn messages should be passed).
93      */
94     void onPublished();
95
96     /**
97      * change packetIn rate limiter borders.
98      * @param upperBound max amount of outstanding packetIns
99      */
100     void updatePacketInRateLimit(long upperBound);
101
102     /**
103      * Checks if device and controller supports single layer serialization.
104      * @return true if single layer serialization is supported
105      */
106     boolean canUseSingleLayerSerialization();
107
108     /**
109      * Method for initial submit transaction after successful initial gathering.
110      */
111     boolean initialSubmitTransaction();
112
113     /**
114      * Checks if the statistics polling property is enabled.
115      * @return true if statistics polling is enabled.
116      */
117     boolean isStatisticsPollingOn();
118
119     @Beta
120     @Nullable FlowGroupInfoHistory getFlowGroupInfoHistory();
121 }
122