Merge "Moved parsing of unknown nodes from implementation to abstract classes."
authorAlessandro Boch <aboch@cisco.com>
Fri, 12 Jul 2013 00:09:45 +0000 (00:09 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 12 Jul 2013 00:09:45 +0000 (00:09 +0000)
12 files changed:
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/Activator.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java [moved from opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java with 99% similarity]
opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerIT.java
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java
opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 5b2b3b32b4e1ceeb94f3bbcfb0ed969d64ab3dff..b3dae0f97fb72da0175f508309c6a2b01d77347a 100644 (file)
@@ -65,7 +65,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public Object[] getImplementations() {
-        Object[] res = { ForwardingRulesManagerImpl.class };
+        Object[] res = { ForwardingRulesManager.class };
         return res;
     }
 
@@ -86,7 +86,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public void configureInstance(Component c, Object imp, String containerName) {
-        if (imp.equals(ForwardingRulesManagerImpl.class)) {
+        if (imp.equals(ForwardingRulesManager.class)) {
             String interfaces[] = null;
             Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
             Set<String> propSet = new HashSet<String>();
@@ -88,13 +88,13 @@ import org.slf4j.LoggerFactory;
  * the network. It also maintains the central repository of all the forwarding
  * rules installed on the network nodes.
  */
-public class ForwardingRulesManagerImpl implements IForwardingRulesManager, PortGroupChangeListener,
+public class ForwardingRulesManager implements IForwardingRulesManager, PortGroupChangeListener,
         IContainerListener, ISwitchManagerAware, IConfigurationContainerAware, IInventoryListener, IObjectReader,
         ICacheUpdateAware<Long, String>, CommandProvider, IFlowProgrammerListener {
     private static final String SAVE = "Save";
     private static final String NODEDOWN = "Node is Down";
     private static final String SUCCESS = StatusCode.SUCCESS.toString();
-    private static final Logger log = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
+    private static final Logger log = LoggerFactory.getLogger(ForwardingRulesManager.class);
     private Map<Long, String> flowsSaveEvent;
     private String frmFileName;
     private String portGroupFileName;
@@ -1690,7 +1690,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port
             FlowEntryInstall flowEntries = mapEntry.getValue();
             // Skip internal generated static flows
             if (!flowEntries.isInternal()) {
-                inactiveFlows.put(flowEntries.getOriginal(), null);
+                inactiveFlows.put(flowEntries.getOriginal(), flowEntries.getOriginal());
             }
         }
 
index c3f41059cf9982994bcd32e117b3531f42772ac4..c497eb240a4dba53a4eec1ccd134dc2587231081 100644 (file)
@@ -1,18 +1,23 @@
 package org.opendaylight.controller.forwardingrulesmanager.internal;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Bundle;
+
 import javax.inject.Inject;
 
 import org.junit.Assert;
-import org.junit.Test;
 import org.junit.Before;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
@@ -25,14 +30,15 @@ import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.framework.BundleContext;
-import static org.junit.Assert.*;
-import org.ops4j.pax.exam.junit.Configuration;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @RunWith(PaxExam.class)
 public class ForwardingRulesManagerIT {
@@ -166,8 +172,7 @@ public class ForwardingRulesManagerIT {
         // Assert if true, if false we are good to go!
         assertFalse(debugit);
 
-        ServiceReference r = bc
-                .getServiceReference(IForwardingRulesManager.class.getName());
+        ServiceReference r = bc.getServiceReference(IForwardingRulesManager.class.getName());
         if (r != null) {
             this.manager = (IForwardingRulesManager) bc.getService(r);
         }
@@ -195,8 +200,10 @@ public class ForwardingRulesManagerIT {
         Node node = NodeCreator.createOFNode(1L);
         FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
 
-        Status stat = manager.installFlowEntry(null);
-        Assert.assertTrue(stat.getCode().equals(StatusCode.NOTACCEPTABLE));
+        Status stat = manager.installFlowEntry(fe);
+
+        // OF plugin is not there in integration testing mode
+        Assert.assertTrue(stat.getCode() == StatusCode.NOSERVICE);
     }
 
 }
index 446f51eb04c81bd3be6f38038e1d6b33cb5fe964..8468c5b284aee7230d2264974f33e3d428f07127 100644 (file)
@@ -1018,7 +1018,6 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
         if (nc == null) {
             return new Status(StatusCode.BADREQUEST, "Invalid NodeConnector");
         }
-
         HostNodeConnector host = null;
         try {
             host = new HostNodeConnector(dataLayerAddress, networkAddr, nc, vlan);
@@ -1036,6 +1035,14 @@ public class HostTracker implements IfIptoHost, IfHostListener, ISwitchManagerAw
                 return new Status(StatusCode.CONFLICT, "Existing IP, Use PUT to update");
             }
             host.setStaticHost(true);
+            /*
+             * Check if the nc is an ISL port
+             */
+            if (topologyManager != null) {
+                if (topologyManager.isInternal(nc)) {
+                    return new Status(StatusCode.BADREQUEST, "Cannot add host on ISL port");
+                }
+            }
             /*
              * Before adding host, Check if the switch and the port have already
              * come up
index dbc99d06e477bb238a5c49af13cade4dd30ae5dd..642c5ccbaa9db016aad4e68c99eff7087081cdd3 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.controller.hosttracker.northbound;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.security.Principal;
 import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
@@ -40,6 +40,7 @@ import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailab
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.exception.UnsupportedMediaTypeException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
+import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
@@ -48,8 +49,6 @@ import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
 
-import org.opendaylight.controller.sal.authorization.Privilege;
-
 /**
  * Host Tracker Northbound REST APIs.<br>
  * This class provides REST APIs to track host location in a network. Host
@@ -261,7 +260,7 @@ public class HostTrackerNorthbound {
     @POST
     @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @StatusCodes({
-            @ResponseCode(code = 201, condition = "Flow Config processed successfully"),
+            @ResponseCode(code = 201, condition = "Static host created successfully"),
             @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
             @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active"),
             @ResponseCode(code = 415, condition = "Invalid IP Address passed in networkAddress parameter"),
index 81729c3dec029b39502562fdb0dc2c0cfd35ce8f..3fa251365687ef895601bb301f6e3067bc58a413 100644 (file)
@@ -68,29 +68,29 @@ public class SwitchHandler implements ISwitch {
             .getLogger(SwitchHandler.class);
     private static final int SWITCH_LIVENESS_TIMER = 5000;
     private static final int switchLivenessTimeout = getSwitchLivenessTimeout();
-    private int MESSAGE_RESPONSE_TIMER = 2000;
+    private final int MESSAGE_RESPONSE_TIMER = 2000;
 
-    private String instanceName;
-    private ISwitch thisISwitch;
-    private IController core;
+    private final String instanceName;
+    private final ISwitch thisISwitch;
+    private final IController core;
     private Long sid;
     private Integer buffers;
     private Integer capabilities;
     private Byte tables;
     private Integer actions;
     private Selector selector;
-    private SocketChannel socket;
-    private BasicFactory factory;
-    private AtomicInteger xid;
+    private final SocketChannel socket;
+    private final BasicFactory factory;
+    private final AtomicInteger xid;
     private SwitchState state;
     private Timer periodicTimer;
-    private Map<Short, OFPhysicalPort> physicalPorts;
-    private Map<Short, Integer> portBandwidth;
-    private Date connectedDate;
+    private final Map<Short, OFPhysicalPort> physicalPorts;
+    private final Map<Short, Integer> portBandwidth;
+    private final Date connectedDate;
     private Long lastMsgReceivedTimeStamp;
     private Boolean probeSent;
-    private ExecutorService executor;
-    private ConcurrentHashMap<Integer, Callable<Object>> messageWaitingDone;
+    private final ExecutorService executor;
+    private final ConcurrentHashMap<Integer, Callable<Object>> messageWaitingDone;
     private boolean running;
     private IMessageReadWrite msgReadWriteService;
     private Thread switchHandlerThread;
@@ -767,23 +767,19 @@ public class SwitchHandler implements ISwitch {
      * messaging service to transmit it over the socket channel
      */
     class PriorityMessageTransmit implements Runnable {
+        @Override
         public void run() {
             running = true;
             while (running) {
                 try {
-                    while (!transmitQ.isEmpty()) {
-                        PriorityMessage pmsg = transmitQ.poll();
-                        msgReadWriteService.asyncSend(pmsg.msg);
-                        logger.trace("Message sent: {}", pmsg);
-                        /*
-                         * If syncReply is set to true, wait for the response
-                         * back.
-                         */
-                        if (pmsg.syncReply) {
-                            syncMessageInternal(pmsg.msg, pmsg.msg.getXid(), false);
-                        }
+                    PriorityMessage pmsg = transmitQ.take();
+                    msgReadWriteService.asyncSend(pmsg.msg);
+                    /*
+                     * If syncReply is set to true, wait for the response back.
+                     */
+                    if (pmsg.syncReply) {
+                        syncMessageInternal(pmsg.msg, pmsg.msg.getXid(), false);
                     }
-                    Thread.sleep(10);
                 } catch (InterruptedException ie) {
                     reportError(new InterruptedException(
                             "PriorityMessageTransmit thread interrupted"));
@@ -801,6 +797,7 @@ public class SwitchHandler implements ISwitch {
     private void startTransmitThread() {
         this.transmitQ = new PriorityBlockingQueue<PriorityMessage>(11,
                 new Comparator<PriorityMessage>() {
+                    @Override
                     public int compare(PriorityMessage p1, PriorityMessage p2) {
                         if (p2.priority != p1.priority) {
                             return p2.priority - p1.priority;
@@ -930,7 +927,7 @@ public class SwitchHandler implements ISwitch {
                 // the result if OFError already
                 if (logger.isDebugEnabled()) {
                   logger.debug("Send {} failed --> {}", msg.getType(),
-                               ((OFError) result));
+                               (result));
                 }
             }
             return result;
index 527382fafb564daf9824ecea86711d7c89155c4d..3f3c8bde2e2aef4751c735f84e6259da1b10c730 100644 (file)
@@ -88,19 +88,19 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
 
     private Timer discoveryTimer;
     private DiscoveryTimerTask discoveryTimerTask;
-    private long discoveryTimerTick = 1L * 1000; // per tick in msec
+    private final static long discoveryTimerTick = 2L * 1000; // per tick in msec
     private int discoveryTimerTickCount = 0; // main tick counter
     // Max # of ports handled in one batch
     private int discoveryBatchMaxPorts = 500;
     // Periodically restart batching process
     private int discoveryBatchRestartTicks = getDiscoveryInterval();
-    private int discoveryBatchPausePeriod = 5; // pause for few secs
+    private int discoveryBatchPausePeriod = 5;
     // Pause after this point
     private int discoveryBatchPauseTicks = discoveryBatchRestartTicks - discoveryBatchPausePeriod;
     // Number of retries after initial timeout
     private int discoveryRetry = getDiscoveryRetry();
-    private int discoveryTimeoutTicks = getDiscoveryTimeout(); // timeout in sec
-    private int discoveryAgeoutTicks = 120; // age out 2 min
+    private int discoveryTimeoutTicks = getDiscoveryTimeout();
+    private int discoveryAgeoutTicks = getDiscoveryAgeout();
     // multiple of discoveryBatchRestartTicks
     private int discoveryConsistencyCheckMultiple = 2;
     // CC tick counter
@@ -161,6 +161,37 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
         }
     }
 
+    public enum DiscoveryPeriod {
+        INTERVAL(300),
+        TIMEOUT (60),
+        AGEOUT  (120);
+
+        private int time;   // sec
+        private int tick;   // tick
+
+        DiscoveryPeriod(int time) {
+            this.time = time;
+            this.tick = time2Tick(time);
+        }
+
+        public int getTime() {
+            return time;
+        }
+
+        public void setTime(int time) {
+            this.time = time;
+            this.tick = time2Tick(time);
+        }
+
+        public int getTick() {
+            return tick;
+        }
+
+        private int time2Tick(int time) {
+            return (int) (time / (discoveryTimerTick / 1000));
+        }
+    }
+
     private RawPacket createDiscoveryPacket(NodeConnector nodeConnector) {
         String nodeId = HexEncode.longToHexString((Long) nodeConnector.getNode().getID());
 
@@ -1476,44 +1507,50 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
         return sourceMac;
     }
 
+    private int getDiscoveryTicks(DiscoveryPeriod dp, String val) {
+        if (dp == null) {
+            return 0;
+        }
+
+        if (val != null) {
+            try {
+                dp.setTime(Integer.parseInt(val));
+            } catch (Exception e) {
+            }
+        }
+
+        return dp.getTick();
+    }
+
     /**
      * This method returns the interval which determines how often the discovery
-     * packets will be sent. Default is 300 seconds.
+     * packets will be sent.
      *
-     * @return The discovery interval in second
+     * @return The discovery interval in ticks
      */
     private int getDiscoveryInterval() {
-        String elapsedTime = System.getProperty("of.discoveryInterval");
-        int rv = 300;
-
-        try {
-            if (elapsedTime != null) {
-                rv = Integer.parseInt(elapsedTime);
-            }
-        } catch (Exception e) {
-        }
-
-        return rv;
+        String intvl = System.getProperty("of.discoveryInterval");
+        return getDiscoveryTicks(DiscoveryPeriod.INTERVAL, intvl);
     }
 
     /**
      * This method returns the timeout value in waiting for response of a
-     * discovery query. Default is 60 seconds.
+     * discovery query.
      *
-     * @return The discovery timeout in second
+     * @return The discovery timeout in ticks
      */
     private int getDiscoveryTimeout() {
-        String elapsedTime = System.getProperty("of.discoveryTimeout");
-        int rv = 60;
-
-        try {
-            if (elapsedTime != null) {
-                rv = Integer.parseInt(elapsedTime);
-            }
-        } catch (Exception e) {
-        }
+        String timeout = System.getProperty("of.discoveryTimeout");
+        return getDiscoveryTicks(DiscoveryPeriod.TIMEOUT, timeout);
+    }
 
-        return rv;
+    /**
+     * This method returns the discovery entry aging time in ticks.
+     *
+     * @return The aging time in ticks
+     */
+    private int getDiscoveryAgeout() {
+        return getDiscoveryTicks(DiscoveryPeriod.AGEOUT, null);
     }
 
     /**
index f31e079bc7705e64bb7c5aa80bc8afdf9d53256f..c7439edc2e7b7b62bc3e7a0b13cc4ccb214dc894 100644 (file)
@@ -16,6 +16,7 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 
 import org.opendaylight.controller.sal.utils.HexEncode;
+import org.opendaylight.controller.sal.utils.NetUtils;
 import org.openflow.protocol.OFMatch;
 import org.openflow.util.U16;
 import org.openflow.util.U8;
@@ -201,17 +202,15 @@ public class V6Match extends OFMatch implements Cloneable {
         }
 
         this.dataLayerSourceMask = null;
-        if (match.getDataLayerSource() != null) {
+        if (match.getDataLayerSource() != null && !NetUtils.isZeroMAC(match.getDataLayerSource())) {
             this.setDataLayerSource(match.getDataLayerSource(), null);
         } else {
-            this.dataLayerSource = null;
             this.dlSourceState = MatchFieldState.MATCH_ABSENT;
         }
         this.dataLayerDestinationMask = null;
-        if (match.getDataLayerDestination() != null) {
+        if (match.getDataLayerDestination() != null && !NetUtils.isZeroMAC(match.getDataLayerDestination())) {
             this.setDataLayerDestination(match.getDataLayerDestination(), null);
         } else {
-            this.dataLayerDestination = null;
             this.dlDestState = MatchFieldState.MATCH_ABSENT;
         }
 
@@ -1370,4 +1369,122 @@ public class V6Match extends OFMatch implements Cloneable {
         }
         return nbytes;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(dataLayerDestinationMask);
+        result = prime * result + Arrays.hashCode(dataLayerSourceMask);
+        result = prime * result + dataLayerTypeMask;
+        result = prime * result + dataLayerVirtualLanMask;
+        result = prime * result + dataLayerVirtualLanPriorityCodePointMask;
+        result = prime * result + ((dlDestState == null) ? 0 : dlDestState.hashCode());
+        result = prime * result + ((dlSourceState == null) ? 0 : dlSourceState.hashCode());
+        result = prime * result + ((dlVlanState == null) ? 0 : dlVlanState.hashCode());
+        result = prime * result + dstIPv6SubnetMaskbits;
+        result = prime * result + ((ethTypeState == null) ? 0 : ethTypeState.hashCode());
+        result = prime * result + inputPortMask;
+        result = prime * result + ((inputPortState == null) ? 0 : inputPortState.hashCode());
+        result = prime * result + match_len;
+        result = prime * result + ((networkDestinationMask == null) ? 0 : networkDestinationMask.hashCode());
+        result = prime * result + networkProtocolMask;
+        result = prime * result + ((networkSourceMask == null) ? 0 : networkSourceMask.hashCode());
+        result = prime * result + networkTypeOfServiceMask;
+        result = prime * result + ((nwDst == null) ? 0 : nwDst.hashCode());
+        result = prime * result + ((nwDstState == null) ? 0 : nwDstState.hashCode());
+        result = prime * result + ((nwProtoState == null) ? 0 : nwProtoState.hashCode());
+        result = prime * result + ((nwSrc == null) ? 0 : nwSrc.hashCode());
+        result = prime * result + ((nwSrcState == null) ? 0 : nwSrcState.hashCode());
+        result = prime * result + ((nwTosState == null) ? 0 : nwTosState.hashCode());
+        result = prime * result + pad_size;
+        result = prime * result + srcIPv6SubnetMaskbits;
+        result = prime * result + ((tpDstState == null) ? 0 : tpDstState.hashCode());
+        result = prime * result + ((tpSrcState == null) ? 0 : tpSrcState.hashCode());
+        result = prime * result + transportDestinationMask;
+        result = prime * result + transportSourceMask;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        V6Match other = (V6Match) obj;
+        if (!Arrays.equals(dataLayerDestinationMask, other.dataLayerDestinationMask))
+            return false;
+        if (!Arrays.equals(dataLayerSourceMask, other.dataLayerSourceMask))
+            return false;
+        if (dataLayerTypeMask != other.dataLayerTypeMask)
+            return false;
+        if (dataLayerVirtualLanMask != other.dataLayerVirtualLanMask)
+            return false;
+        if (dataLayerVirtualLanPriorityCodePointMask != other.dataLayerVirtualLanPriorityCodePointMask)
+            return false;
+        if (dlDestState != other.dlDestState)
+            return false;
+        if (dlSourceState != other.dlSourceState)
+            return false;
+        if (dlVlanState != other.dlVlanState)
+            return false;
+        if (dstIPv6SubnetMaskbits != other.dstIPv6SubnetMaskbits)
+            return false;
+        if (ethTypeState != other.ethTypeState)
+            return false;
+        if (inputPortMask != other.inputPortMask)
+            return false;
+        if (inputPortState != other.inputPortState)
+            return false;
+        if (match_len != other.match_len)
+            return false;
+        if (networkDestinationMask == null) {
+            if (other.networkDestinationMask != null)
+                return false;
+        } else if (!networkDestinationMask.equals(other.networkDestinationMask))
+            return false;
+        if (networkProtocolMask != other.networkProtocolMask)
+            return false;
+        if (networkSourceMask == null) {
+            if (other.networkSourceMask != null)
+                return false;
+        } else if (!networkSourceMask.equals(other.networkSourceMask))
+            return false;
+        if (networkTypeOfServiceMask != other.networkTypeOfServiceMask)
+            return false;
+        if (nwDst == null) {
+            if (other.nwDst != null)
+                return false;
+        } else if (!nwDst.equals(other.nwDst))
+            return false;
+        if (nwDstState != other.nwDstState)
+            return false;
+        if (nwProtoState != other.nwProtoState)
+            return false;
+        if (nwSrc == null) {
+            if (other.nwSrc != null)
+                return false;
+        } else if (!nwSrc.equals(other.nwSrc))
+            return false;
+        if (nwSrcState != other.nwSrcState)
+            return false;
+        if (nwTosState != other.nwTosState)
+            return false;
+        if (pad_size != other.pad_size)
+            return false;
+        if (srcIPv6SubnetMaskbits != other.srcIPv6SubnetMaskbits)
+            return false;
+        if (tpDstState != other.tpDstState)
+            return false;
+        if (tpSrcState != other.tpSrcState)
+            return false;
+        if (transportDestinationMask != other.transportDestinationMask)
+            return false;
+        if (transportSourceMask != other.transportSourceMask)
+            return false;
+        return true;
+    }
 }
index edb3537c1273c9f6a02cc956b64e481161914b08..4470e17e82bc2b77109a4ca39b9acc741c7a1515 100644 (file)
@@ -8,14 +8,13 @@
 
 package org.opendaylight.controller.sal.core;
 
-import java.util.Arrays;
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.opendaylight.controller.sal.utils.HexEncode;
+
 /**
  * The class contains MAC address property.
  */
@@ -24,7 +23,7 @@ import org.opendaylight.controller.sal.utils.HexEncode;
 public class MacAddress extends Property implements Cloneable {
     private static final long serialVersionUID = 1L;
     @XmlElement(name="macAddress")
-    private final byte[] address;
+    private final String address;
     public static final String name = "macAddress";
 
     /*
@@ -42,20 +41,36 @@ public class MacAddress extends Property implements Cloneable {
      *
      *
      * @param nodeMacAddress
-     *            Data Link Address for the node
+     *            Data Link Address for the node in byte array format
      *
      * @return the constructed object
      */
     public MacAddress(byte[] nodeMacAddress) {
         super(name);
-        this.address = nodeMacAddress.clone();
+        this.address = HexEncode.bytesToHexStringFormat(nodeMacAddress);
+    }
+
+    /**
+     * Constructor to create DatalinkAddress property which contains the MAC
+     * address. The property will be attached to a
+     * {@link org.opendaylight.controller.sal.core.Node}.
+     *
+     *
+     * @param nodeMacAddress
+     *            Data Link Address for the node in String format
+     *
+     * @return the constructed object
+     */
+    public MacAddress(String nodeMacAddress) {
+        super(name);
+        this.address = nodeMacAddress;
     }
 
     /**
-     * @return the node MAC address
+     * @return the node MAC address in byte array format
      */
     public byte[] getMacAddress() {
-        return this.address.clone();
+        return HexEncode.bytesFromHexString(this.address);
     }
 
     @Override
@@ -67,7 +82,8 @@ public class MacAddress extends Property implements Cloneable {
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + Arrays.hashCode(address);
+        result = prime * result
+                + ((address == null) ? 0 : address.hashCode());
         return result;
     }
 
@@ -83,7 +99,7 @@ public class MacAddress extends Property implements Cloneable {
             return false;
         }
         MacAddress other = (MacAddress) obj;
-        if (!Arrays.equals(address, other.address)) {
+        if (!address.equals(other.address)) {
             return false;
         }
         return true;
@@ -91,7 +107,6 @@ public class MacAddress extends Property implements Cloneable {
 
     @Override
     public String toString() {
-        return "MacAddress [address=" +
-            HexEncode.bytesToHexStringFormat(address) + "]";
+        return "MacAddress[" + address + "]";
     }
 }
index 369588c0c4169eb74dd0ca38fd58d3a6b1d95bc1..a7bdb9da8bf32072b73b45a3128b412b9f18f88a 100644 (file)
@@ -116,20 +116,20 @@ public class FlowProgrammerService implements IFlowProgrammerService,
     }
 
     // Set the reference to the plugin flow programmer
-    public void setService(Map props, IPluginInFlowProgrammerService s) {
+    public void setService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
         if (this.pluginFlowProgrammer == null) {
             logger.error("pluginFlowProgrammer store null");
             return;
         }
 
-        logger.trace("Got a service set request {}", s);
-        String type = null;
-        for (Object e : props.entrySet()) {
-            Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                    entry.getValue());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
+        String type = null;
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;
@@ -143,20 +143,21 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         }
     }
 
-    public void unsetService(Map props, IPluginInFlowProgrammerService s) {
+    public void unsetService(Map<String, Object> props, IPluginInFlowProgrammerService s) {
         if (this.pluginFlowProgrammer == null) {
             logger.error("pluginFlowProgrammer store null");
             return;
         }
 
-        String type = null;
         logger.debug("Received unsetpluginFlowProgrammer request");
-        for (Object e : props.entrySet()) {
-            Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:({}) value:({})", entry.getKey(),
-                    entry.getValue());
+        if (logger.isTraceEnabled()) {
+            logger.trace("Got a service set request {}", s);
+            for (Map.Entry<String, Object> entry : props.entrySet()) {
+                logger.trace("Prop key:({}) value:({})", entry.getKey(), entry.getValue());
+            }
         }
 
+        String type = null;
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
             type = (String) value;
index 8c95c46d72abd8e09e068da837288a4d31ad00bd..7fd9bc17d1e4cf05c1a69d0bb169d3e6168ee90a 100644 (file)
@@ -1662,7 +1662,13 @@ CommandProvider {
         if (nodeSet == null) {
             return;
         }
+        List<String> nodeArray = new ArrayList<String>();
         for (Node node : nodeSet) {
+            nodeArray.add(node.toString());
+        }
+        Collections.sort(nodeArray);
+        for (String str: nodeArray) {
+            Node node = Node.fromString(str);
             Description desc = ((Description) getNodeProp(node,
                     Description.propertyName));
             Tier tier = ((Tier) getNodeProp(node, Tier.TierPropName));
index f9574b993ca709d769a48562f5f03cd5ea5e72aa..ce39fed5fcc4960efff1d8959335ced6be066893 100644 (file)
@@ -18,9 +18,9 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -33,25 +33,22 @@ import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Host;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.TimeStamp;
 import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.topology.IListenTopoUpdates;
 import org.opendaylight.controller.sal.topology.ITopologyService;
 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.IObjectReader;
 import org.opendaylight.controller.sal.utils.ObjectReader;
 import org.opendaylight.controller.sal.utils.ObjectWriter;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.topologymanager.ITopologyManager;
 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
 import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig;
@@ -429,6 +426,8 @@ CommandProvider {
         if (this.hostsDB == null) {
             return null;
         }
+        if (this.hostsDB.get(p) == null)
+            return null;
 
         return (this.hostsDB.get(p).getLeft());
     }