Merge "fixing late hooking of request into deviceContext registry"
authormichal rehak <mirehak@cisco.com>
Mon, 20 Apr 2015 17:28:02 +0000 (17:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 20 Apr 2015 17:28:03 +0000 (17:28 +0000)
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/queue/TicketProcessorFactoryImpl.java

index 75d2755d60139cc1e7d45b0d679019d78966037e..fba5816a548cc19419837f704744bbbe8fce61f5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * <p/>
  * 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
@@ -16,6 +16,7 @@ import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -23,7 +24,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
@@ -212,13 +212,23 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
         final SettableFuture<RpcResult<T>> finalFuture = SettableFuture.create();
         Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<T>>>() {
             @Override
-            public void onSuccess(List<RpcResult<T>> result) {
-                LOG.warn("Positive confirmation of flow push is not supported by OF-spec");
-                for (FlowModInputBuilder ofFlowModInput : ofFlowModInputs) {
-                    LOG.warn("flow future result was successful [{}] = this should have never happen",
-                            ofFlowModInput.getXid());
+            public void onSuccess(List<RpcResult<T>> results) {
+                Iterator<FlowModInputBuilder> flowModInputBldIterator = ofFlowModInputs.iterator();
+                List<RpcError> rpcErrorLot = new ArrayList<>();
+                for (RpcResult<T> rpcResult : results) {
+                    FlowModInputBuilder flowModInputBld = flowModInputBldIterator.next();
+                    if (rpcResult.isSuccessful()) {
+                        Long xid = flowModInputBld.getXid();
+                        LOG.warn("Positive confirmation of flow push is not supported by OF-spec");
+                        LOG.warn("flow future result was successful [{}] = this should have never happen",
+                                xid);
+                        rpcErrorLot.add(RpcResultBuilder.newError(ErrorType.APPLICATION, "",
+                                "flow future result was successful ["+xid+"] = this should have never happen"));
+                    } else {
+                        rpcErrorLot.addAll(rpcResult.getErrors());
+                    }
                 }
-                finalFuture.setException(new DeviceDataException("positive confirmation of flow occurred"));
+                finalFuture.set(RpcResultBuilder.<T>failed().withRpcErrors(rpcErrorLot).build());
             }
 
             @Override
index 1a5e71e0ec9d64b4df9d0576cbb5837475f4af09..77269da99e9f9678d2c94e668ec2583c7c893ab5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * <p/>
  * 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
@@ -37,7 +37,7 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
 
         // extract the port number
         Long port = null;
-        if(input.getVersion() == OFConstants.OFP_VERSION_1_0 && input.getInPort() != null) {
+        if (input.getVersion() == OFConstants.OFP_VERSION_1_0 && input.getInPort() != null) {
             port = input.getInPort().longValue();
         } else if (input.getVersion() == OFConstants.OFP_VERSION_1_3) {
             if (input.getMatch() != null && input.getMatch().getMatchEntry() != null) {
@@ -52,16 +52,16 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
         if (input.getCookie() != null) {
             packetReceivedBuilder.setFlowCookie(new FlowCookie(input.getCookie()));
         }
-        if(port != null) {
+        if (port != null) {
             packetReceivedBuilder.setIngress(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(datapathId, port, OpenflowVersion.get(input.getVersion())));
         }
         packetReceivedBuilder.setPacketInReason(PacketInUtil.getMdSalPacketInReason(input.getReason()));
 
-        if(input.getTableId() != null) {
+        if (input.getTableId() != null) {
             packetReceivedBuilder.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(input.getTableId().getValue().shortValue()));
         }
 
-        if(input.getMatch() != null) {
+        if (input.getMatch() != null) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match packetInMatch = getPacketInMatch(input, datapathId);
             packetReceivedBuilder.setMatch(packetInMatch);
         }
@@ -88,15 +88,12 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
     private Long getPortNumberFromMatch(List<MatchEntry> entries) {
         Long port = null;
         for (MatchEntry entry : entries) {
-            InPortCase inPortCase = ((InPortCase) entry.getMatchEntryValue());
-            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort inPort = inPortCase.getInPort();
-            if (inPort != null) {
-
-                if (port == null) {
+            if (InPortCase.class.equals(entry.getMatchEntryValue().getImplementedInterface())) {
+                InPortCase inPortCase = ((InPortCase) entry.getMatchEntryValue());
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort inPort = inPortCase.getInPort();
+                if (inPort != null) {
                     port = inPort.getPortNumber().getValue();
-                } else {
-//                        LOG.warn("Multiple input ports discovered when walking through match entries (at least {} and {})",
-//                                port, inPort.getPortNumber().getValue());
+                    break;
                 }
             }
         }
index b034693055002feb65266cab936eb208bdfa7d20..11a5ffea46e7d2a185b50005dd83281e5b063dd3 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.queue;
 
+import com.google.common.collect.ImmutableMap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
@@ -23,8 +23,6 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
-
 /**
  * OfHeader to DataObject implementation
  */
@@ -61,7 +59,7 @@ public class TicketProcessorFactoryImpl implements TicketProcessorFactory<OfHead
     public void setTicketFinisher(TicketFinisher<DataObject> ticketFinisher) {
         this.ticketFinisher = ticketFinisher;
     }
-    
+
     /**
      * @param ticket
      * @return runnable ticket processor
@@ -86,7 +84,7 @@ public class TicketProcessorFactoryImpl implements TicketProcessorFactory<OfHead
                         }
                     }
                 } catch (Exception e) {
-                    LOG.error("translation problem: {}", e.getMessage());
+                    LOG.warn("translation problem: {}", e.getMessage());
                     ticket.getResult().setException(e);
                 }
                 LOG.debug("message processing done (type: {}, ticket: {})",
@@ -98,7 +96,7 @@ public class TicketProcessorFactoryImpl implements TicketProcessorFactory<OfHead
 
         return ticketProcessor;
     }
-    
+
     /**
      * @param ticket
      * @return runnable ticket processor
@@ -130,10 +128,10 @@ public class TicketProcessorFactoryImpl implements TicketProcessorFactory<OfHead
 
         return ticketProcessor;
     }
-    
-    
+
+
     /**
-     * @param ticket 
+     * @param ticket
      *
      */
     @Override
@@ -173,7 +171,7 @@ public class TicketProcessorFactoryImpl implements TicketProcessorFactory<OfHead
         } else {
             LOG.warn("No translators for this message Type: {}", messageType);
         }
-        
+
         return result;
     }
 }