X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2Fadsal%2FFlowServiceAdapter.java;h=84508ca03e99475b7a95fcc0a0e676082e227f04;hp=6267c048a6d678fc0c6bbe6af5fe33b0485a847a;hb=fd8c7a6e7445ca9788c2557caa9da5af8c8a2153;hpb=cfa6e9d0a2193edb2a2e36c04ca95eaf28a651f9 diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java index 6267c048a6..84508ca03e 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowServiceAdapter.java @@ -1,23 +1,38 @@ +/* + * Copyright (c) 2014 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.controller.sal.compatibility.adsal; +import java.math.BigInteger; import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.common.util.Futures; import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.compatibility.NodeMapping; +import org.opendaylight.controller.sal.compatibility.InventoryMapping; import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; -import org.opendaylight.controller.sal.core.ConstructionException; -import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener; import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,58 +46,59 @@ public class FlowServiceAdapter implements SalFlowService, IFlowProgrammerListen private NotificationProviderService publish; @Override - public void flowRemoved(Node node, Flow flow) { + public void flowRemoved(org.opendaylight.controller.sal.core.Node node, Flow flow) { FlowRemovedBuilder flowRemovedBuilder = new FlowRemovedBuilder(); - flowRemovedBuilder.setNode(NodeMapping.toNodeRef(node)); + flowRemovedBuilder.setNode(InventoryMapping.toNodeRef(node)); publish.publish(flowRemovedBuilder.build()); } @Override - public void flowErrorReported(Node node, long rid, Object err) { + public void flowErrorReported(org.opendaylight.controller.sal.core.Node node, long rid, Object err) { // TODO Auto-generated method stub } @Override - public Future> addFlow(AddFlowInput input) { - try { - Flow flow = ToSalConversionsUtils.toFlow(input); - Node node = NodeMapping.toADNode(input.getNode()); - Status status = delegate.addFlowAsync(node, flow); - Void rpcResultType = null; - return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); - } catch (ConstructionException e) { - LOG.error(e.getMessage()); - } - return null; + public Future> addFlow(AddFlowInput input) { + + Flow flow = ToSalConversionsUtils.toFlow(input, null); + @SuppressWarnings("unchecked") + org.opendaylight.controller.sal.core.Node node = InventoryMapping.toAdNode((InstanceIdentifier) input + .getNode().getValue()); + Status status = delegate.addFlowAsync(node, flow); + AddFlowOutputBuilder builder = new AddFlowOutputBuilder(); + builder.setTransactionId(new TransactionId(BigInteger.valueOf(status.getRequestId()))); + AddFlowOutput rpcResultType = builder.build(); + return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); } @Override - public Future> removeFlow(RemoveFlowInput input) { - try { - Flow flow = ToSalConversionsUtils.toFlow(input); - Node node = NodeMapping.toADNode(input.getNode()); - Status status = delegate.removeFlowAsync(node, flow); - Void rpcResultType = null; - return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); - } catch (ConstructionException e) { - LOG.error(e.getMessage()); - } - return null; + public Future> removeFlow(RemoveFlowInput input) { + + Flow flow = ToSalConversionsUtils.toFlow(input, null); + @SuppressWarnings("unchecked") + org.opendaylight.controller.sal.core.Node node = InventoryMapping.toAdNode((InstanceIdentifier) input + .getNode().getValue()); + Status status = delegate.removeFlowAsync(node, flow); + RemoveFlowOutputBuilder builder = new RemoveFlowOutputBuilder(); + builder.setTransactionId(new TransactionId(BigInteger.valueOf(status.getRequestId()))); + RemoveFlowOutput rpcResultType = builder.build(); + return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); + } @Override - public Future> updateFlow(UpdateFlowInput input) { - try { - Node node = NodeMapping.toADNode(input.getNode()); - Flow originalFlow = ToSalConversionsUtils.toFlow(input.getOriginalFlow()); - Flow updatedFlow = ToSalConversionsUtils.toFlow(input.getUpdatedFlow()); - Status status = delegate.modifyFlowAsync(node, originalFlow, updatedFlow); - Void rpcResultType = null; - return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); - } catch (ConstructionException e) { - LOG.error(e.getMessage()); - } - return null; + public Future> updateFlow(UpdateFlowInput input) { + @SuppressWarnings("unchecked") + org.opendaylight.controller.sal.core.Node node = InventoryMapping.toAdNode((InstanceIdentifier) input + .getNode().getValue()); + Flow originalFlow = ToSalConversionsUtils.toFlow(input.getOriginalFlow(), null); + Flow updatedFlow = ToSalConversionsUtils.toFlow(input.getUpdatedFlow(), null); + Status status = delegate.modifyFlowAsync(node, originalFlow, updatedFlow); + UpdateFlowOutputBuilder builder = new UpdateFlowOutputBuilder(); + builder.setTransactionId(new TransactionId(BigInteger.valueOf(status.getRequestId()))); + UpdateFlowOutput rpcResultType = builder.build(); + throw new UnsupportedOperationException("Need to translate AD-SAL status to MD-SAL UpdateFlowOuptut - eaw@cisco.com"); + // return Futures.immediateFuture(Rpcs.getRpcResult(status.isSuccess(), rpcResultType, null)); } }