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