f651a73a1fac69cdb2fb408bcb79ea2880a543a0
[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 org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
11 import org.opendaylight.yangtools.yang.binding.DataObject;
12 import org.opendaylight.yangtools.yang.binding.RpcService;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14 import java.util.concurrent.Future;
15
16 /**
17  * This context is registered with MD-SAL as a routed RPC provider for the inventory node backed by this switch and
18  * tracks the state of any user requests and how they map onto protocol requests. It uses
19  * {@link org.opendaylight.openflowplugin.api.openflow.device.RequestContext} to perform requests.
20  * <p/>
21  * Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
22  */
23 public interface RpcContext extends AutoCloseable {
24
25     <S extends RpcService> void registerRpcServiceImplementation(Class<S> serviceClass, S serviceInstance);
26
27     /*
28      *  Method adds request to request queue which has limited quota. After number of requests exceeds quota limit
29      *  {@link org.opendaylight.openflowplugin.api.openflow.device.exception.RequestQuotaExceededException} is thrown.
30      *
31      * @param data
32      */
33     <T extends DataObject> Future<RpcResult<T>> addNewRequest(DataObject data);
34
35     /**
36      * Method for setting request quota value. When the Request Context quota is exceeded, incoming RPCs fail
37      * immediately, with a well-defined error.
38      *
39      * @param maxRequestsPerDevice
40      */
41     void setRequestContextQuota(int maxRequestsPerDevice);
42
43     void forgetRequestContext(RequestContext requestContext);
44 }