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