Changed methods in DeviceContext, created DeviceReplyProcessor interface
[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.math.BigInteger;
12 import java.util.Map;
13 import java.util.concurrent.Future;
14 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
15 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
16 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
18 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MessageHandler;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22 import org.opendaylight.yangtools.yang.common.RpcResult;
23
24 import com.google.common.util.concurrent.SettableFuture;
25
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.concurrent.Future;
30
31 /**
32  * The central entity of OFP is the Device Context, which encapsulate the logical state of a switch
33  * as seen by the controller. Each OpenFlow session is tracked by a Connection Context.
34  * These attach to a particular Device Context in such a way, that there is at most one primary
35  * session associated with a Device Context. Whenever the controller needs to interact with a
36  * particular switch, it will do so in the context of the calling thread, obtaining a lock on
37  * the corresponding Device Context – thus the Device Context becomes the fine-grained point
38  * of synchronization. The only two entities allowed to send requests towards the switch are
39  * Statistics Manager and RPC Manager. Each of them allocates a Request Context for interacting
40  * with a particular Device Context. The Request Contexts are the basic units of fairness,
41  * which is enforced by keeping a cap on the number of outstanding requests a particular Request
42  * Context can have at any point in time. Should this quota be exceeded, any further attempt to make
43  * a request to the switch will fail immediately, with proper error indication.
44  * <p>
45  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
46  */
47 public interface DeviceContext extends MessageHandler {
48
49
50     /**
51      * Method add auxiliary connection contexts to this context representing single device connection.
52      *
53      * @param connectionContext
54      */
55     void addAuxiliaryConenctionContext(ConnectionContext connectionContext);
56
57     /**
58      * Method removes auxiliary connection context from this context representing single device connection.
59      *
60      * @param connectionContext
61      */
62     void removeAuxiliaryConenctionContext(ConnectionContext connectionContext);
63
64
65     /**
66      * Method provides state of device represented by this device context.
67      *
68      * @return {@link DeviceState}
69      */
70     DeviceState getDeviceState();
71
72     /**
73      * Method exposes transaction created for device
74      * represented by this context. This should be used as write only.
75      */
76     WriteTransaction getWriteTransaction();
77
78     /**
79      * Method exposes transaction created for device
80      * represented by this context. This should be used as read only.
81      * This read only transaction has a fresh dataStore snapshot and
82      * here is a possibility to get different data set from  DataStore
83      * as have a write transaction in this context.
84      */
85     ReadTransaction getReadTransaction();
86
87     /**
88      * Method provides capabilities of connected device.
89      *
90      * @return
91      */
92     TableFeatures getCapabilities();
93
94     /**
95      * Method provides current devices connection context.
96      *
97      * @return
98      */
99     ConnectionContext getPrimaryConnectionContext();
100
101     /**
102      * Method provides current devices auxiliary connection contexts.
103      *
104      * @return
105      */
106     ConnectionContext getAuxiliaryConnectiobContexts(BigInteger cookie);
107
108     Xid getNextXid();
109
110     /**
111      * Method writes request context into request context map
112      * @param xid
113      * @param requestFutureContext
114      */
115     public void hookRequestCtx(Xid xid, RequestContext requestFutureContext);
116
117 }
118