Merge "BUG-837: it unstable (added missing bundles)"
[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 org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
12 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MessageHandler;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures;
15
16 /**
17  * The central entity of OFP is the Device Context, which encapsulate the logical state of a switch
18  * as seen by the controller. Each OpenFlow session is tracked by a Connection Context.
19  * These attach to a particular Device Context in such a way, that there is at most one primary
20  * session associated with a Device Context. Whenever the controller needs to interact with a
21  * particular switch, it will do so in the context of the calling thread, obtaining a lock on
22  * the corresponding Device Context – thus the Device Context becomes the fine-grained point
23  * of synchronization. The only two entities allowed to send requests towards the switch are
24  * Statistics Manager and RPC Manager. Each of them allocates a Request Context for interacting
25  * with a particular Device Context. The Request Contexts are the basic units of fairness,
26  * which is enforced by keeping a cap on the number of outstanding requests a particular Request
27  * Context can have at any point in time. Should this quota be exceeded, any further attempt to make
28  * a request to the switch will fail immediately, with proper error indication.
29  * <p/>
30  * Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
31  */
32 public interface DeviceContext extends MessageHandler {
33
34
35     /**
36      * Method add auxiliary connection contexts to this context representing single device connection.
37      *
38      * @param connectionContext
39      */
40     void addAuxiliaryConenctionContext(ConnectionContext connectionContext);
41
42     /**
43      * Method removes auxiliary connection context from this context representing single device connection.
44      *
45      * @param connectionContext
46      */
47     void removeAuxiliaryConenctionContext(ConnectionContext connectionContext);
48
49
50     /**
51      * Method provides state of device represented by this device context.
52      *
53      * @return {@link DeviceState}
54      */
55     DeviceState getDeviceState();
56
57     /**
58      * Method sets transaction chain used for all data store operations on device
59      * represented by this context. This transaction chain is write only.
60      *
61      * @param transactionChain
62      */
63     void setTransactionChain(TransactionChain transactionChain);
64
65     /**
66      * Method exposes transaction created for device
67      * represented by this context. This should be used as write only.
68      */
69     TransactionChain getTransactionChain();
70
71     /**
72      * Method provides capabilities of connected device.
73      *
74      * @return
75      */
76     TableFeatures getCapabilities();
77
78 }
79