From befc174df22fd0a55fc66704b43d8c5b82bd4494 Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Tue, 24 Mar 2015 11:57:10 +0100 Subject: [PATCH] evolved API - device context offers primary and auxiliary connection contexts - RpcContext and RequestContext offers generic way of invoking rpc call Change-Id: Icafafdb7c64e5c43a0d4675ee360e177d8f0d69e Signed-off-by: Martin Bobak --- .../api/openflow/device/DeviceContext.java | 16 ++++++++++++++++ .../api/openflow/device/RequestContext.java | 5 +++++ .../api/openflow/rpc/RpcContext.java | 8 +++----- .../impl/device/DeviceContextImpl.java | 13 +++++++++++++ .../impl/rpc/RequestContextImpl.java | 12 +++++++++--- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java index 0ff3d737c8..c5148e425e 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java @@ -12,6 +12,8 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.MessageHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures; +import java.math.BigInteger; +import java.util.Collection; /** * The central entity of OFP is the Device Context, which encapsulate the logical state of a switch @@ -75,5 +77,19 @@ public interface DeviceContext extends MessageHandler { */ TableFeatures getCapabilities(); + /** + * Method provides current devices connection context. + * + * @return + */ + ConnectionContext getPrimaryConnectionContext(); + + /** + * Method provides current devices auxiliary connection contexts. + * + * @return + */ + ConnectionContext getAuxiliaryConnectiobContexts(BigInteger cookie); + } diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/RequestContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/RequestContext.java index 2d6ae1989a..f9380ac99d 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/RequestContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/RequestContext.java @@ -8,6 +8,10 @@ package org.opendaylight.openflowplugin.api.openflow.device; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.RpcResult; +import java.util.concurrent.Future; + /** * Request context handles all requests on device. Number of requests is limited by request quota. When this quota is * exceeded all rpc's will end up with exception. @@ -16,6 +20,7 @@ package org.opendaylight.openflowplugin.api.openflow.device; */ public interface RequestContext { + Future> createRequestFuture(DataObject dataObject); } diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcContext.java index 59c0c1ab6f..19dc4404bc 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcContext.java @@ -7,11 +7,11 @@ */ package org.opendaylight.openflowplugin.api.openflow.rpc; -import java.util.concurrent.Future; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.RpcService; import org.opendaylight.yangtools.yang.common.RpcResult; +import java.util.concurrent.Future; /** * This context is registered with MD-SAL as a routed RPC provider for the inventory node backed by this switch and @@ -32,16 +32,14 @@ public interface RpcContext extends AutoCloseable { * * @param data */ - Future> addNewRequest(DataObject data); + Future> addNewRequest(DataObject data); /** * Method for setting request quota value. When the Request Context quota is exceeded, incoming RPCs fail * immediately, with a well-defined error. - * + * * @param maxRequestsPerDevice */ void setRequestContextQuota(int maxRequestsPerDevice); - boolean isRequestContextCapacityEmpty(); - } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java index a421938ad6..d2a900b9e8 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java @@ -15,6 +15,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures; import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.DataObject; +import java.math.BigInteger; +import java.util.Collection; /** * @@ -63,4 +65,15 @@ public class DeviceContextImpl implements DeviceContext { return null; } + @Override + public ConnectionContext getPrimaryConnectionContext() { + return null; + } + + @Override + public ConnectionContext getAuxiliaryConnectiobContexts(final BigInteger cookie) { + return null; + } + + } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RequestContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RequestContextImpl.java index 053ccf5384..12e8f6e7dd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RequestContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RequestContextImpl.java @@ -1,27 +1,33 @@ /** * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.openflowplugin.impl.rpc; -import java.util.concurrent.Future; +import com.google.common.util.concurrent.SettableFuture; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.common.RpcResult; +import java.util.concurrent.Future; /** * @author joe - * */ public class RequestContextImpl implements RequestContext { private final Future> result; + private SettableFuture requestFuture; public RequestContextImpl(final Future> result) { this.result = result; } + @Override + public Future> createRequestFuture(final DataObject dataObject) { + requestFuture = SettableFuture.create(); + return requestFuture; + } } -- 2.36.6