Added type parameteris.
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / rpc / RpcContext.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.rpc;
9
10 import com.google.common.util.concurrent.SettableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14 import org.opendaylight.yangtools.yang.binding.RpcService;
15 import org.opendaylight.yangtools.yang.common.RpcResult;
16
17 /**
18  * This context is registered with MD-SAL as a routed RPC provider for the inventory node backed by this switch and
19  * tracks the state of any user requests and how they map onto protocol requests. It uses
20  * {@link org.opendaylight.openflowplugin.api.openflow.device.RequestContext} to perform requests.
21  * <p/>
22  * Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
23  */
24 public interface RpcContext extends AutoCloseable {
25
26     <S extends RpcService> void registerRpcServiceImplementation(Class<S> serviceClass, S serviceInstance);
27
28     /**
29      * Method adds request to request queue which has limited quota. After number of requests exceeds quota limit future
30      * will be done immediately and will contain information about exceeded request quota.
31      * 
32      * @param data
33      */
34     <T extends DataObject> SettableFuture<RpcResult<T>> storeOrFail(RequestContext<T> data);
35
36     /**
37      * Method for setting request quota value. When the Request Context quota is exceeded, incoming RPCs fail
38      * immediately, with a well-defined error.
39      * 
40      * @param maxRequestsPerDevice
41      */
42     void setRequestContextQuota(int maxRequestsPerDevice);
43
44     <T extends DataObject> void forgetRequestContext(RequestContext<T> requestContext);
45
46     /**
47      * Method provides device context.
48      * 
49      * @return
50      */
51     DeviceContext getDeviceContext();
52
53     /**
54      * Method returns new request context for current request.
55      * 
56      * @return
57      */
58     <T extends DataObject> RequestContext<T> createRequestContext();
59
60 }