Merge "Bug #65 - Fix inconsistencies in the NB REST APIs"
authorAlessandro Boch <aboch@cisco.com>
Wed, 11 Sep 2013 16:58:31 +0000 (16:58 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 11 Sep 2013 16:58:31 +0000 (16:58 +0000)
17 files changed:
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/ICoordinatorChangeAware.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IListenRoleChange.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClassResolver.java [new file with mode: 0644]
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/IConfigurationAwareCommon.java
opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/IConfigurationServiceCommon.java
opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/IForwardingStaticRouting.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/IStaticRoutingAware.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupProvider.java
opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java
opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java
opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
third-party/openflowj/src/main/java/org/openflow/protocol/OFError.java
third-party/openflowj/src/main/java/org/openflow/protocol/action/ActionVendorOutputNextHop.java

index 4a92aca6049d76bd1e1694667cb1c80bf73d4ae8..5d0edd8d009ea03280fc1ce3f70027bf4b722644 100644 (file)
@@ -28,5 +28,5 @@ public interface ICoordinatorChangeAware {
      * Function that will be called when there is the event of
      * coordinator change in the cluster.
      */
-    public void coordinatorChanged();
+    void coordinatorChanged();
 }
index e5c7a8839e9ef4c76e6c7be6e36584b096cdeb10..b8798e6705b48997cf561acea0db707e25c8665c 100644 (file)
@@ -37,5 +37,5 @@ public interface IListenRoleChange {
      * active-standby milestone is reached, after will be removed.
      *
      */
-    public void newActiveAvailable();
+    void newActiveAvailable();
 }
diff --git a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClassResolver.java b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClassResolver.java
new file mode 100644 (file)
index 0000000..521a773
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 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.clustering.services_implementation.internal;
+
+import java.lang.ref.WeakReference;
+
+import org.jboss.marshalling.ContextClassResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ClassResolver extends ContextClassResolver {
+    private WeakReference<ClassLoader> osgiClassLoader = null;
+    private static final Logger logger = LoggerFactory.getLogger(ClassResolver.class);
+
+    public ClassResolver() {
+        ClassLoader cl = this.getClass()
+                .getClassLoader();
+        if (cl != null) {
+            this.osgiClassLoader = new WeakReference<ClassLoader>(cl);
+            logger.trace("Acquired weak reference to OSGi classLoader {}", cl);
+        }
+    }
+
+    @Override
+    protected ClassLoader getClassLoader() {
+        ClassLoader ret = null;
+        if (this.osgiClassLoader != null) {
+            ret = this.osgiClassLoader.get();
+            if (ret != null) {
+                if (logger.isTraceEnabled()) {
+                    logger.trace("Returning OSGi class loader {}", ret);
+                }
+                return ret;
+            }
+        }
+
+        logger.warn("Could not resolve classloader!");
+        return ret;
+    }
+}
index f5c655a4eae8fb52afcefad92507177ff1cc479a..cd3a29579194c9a6a9831f4e44d7e67150b69f6d 100644 (file)
@@ -33,6 +33,9 @@ import javax.transaction.TransactionManager;
 
 import org.infinispan.Cache;
 import org.infinispan.configuration.cache.Configuration;
+import org.infinispan.configuration.global.GlobalConfigurationBuilder;
+import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
+import org.infinispan.configuration.parsing.ParserRegistry;
 import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.notifications.Listener;
@@ -247,8 +250,14 @@ public class ClusterManager implements IClusterServices, IContainerAware {
         }
         logger.info("Starting the ClusterManager");
         try {
-            //FIXME keeps throwing FileNotFoundException
-            this.cm = new DefaultCacheManager("config/infinispan-config.xml");
+            ParserRegistry parser = new ParserRegistry(this.getClass()
+                    .getClassLoader());
+            ConfigurationBuilderHolder holder = parser.parseFile("config/infinispan-config.xml");
+            GlobalConfigurationBuilder globalBuilder = holder.getGlobalConfigurationBuilder();
+            globalBuilder.serialization()
+                    .classResolver(new ClassResolver())
+                    .build();
+            this.cm = new DefaultCacheManager(holder, false);
             logger.debug("Allocated ClusterManager");
             if (this.cm != null) {
                 this.cm.start();
index 57a648bf69663da84a0a26f28c60252420c6f808..f06dcb3296dfb4ef402e49a7e86e07e5d5e0232f 100644 (file)
@@ -22,5 +22,5 @@ public interface IConfigurationAwareCommon {
     /**
      * Trigger from configuration component to persist the configuration state.
      */
-    public Status saveConfiguration();
+    Status saveConfiguration();
 }
index fc9c5ac9777d20b55618e310b592b7170b1a2531..c76e3770264aecbf32499eb876502ea9b6daccf1 100644 (file)
@@ -17,5 +17,5 @@ import org.opendaylight.controller.sal.utils.Status;
  *
  */
 public interface IConfigurationServiceCommon {
-    public Status saveConfigurations();
+    Status saveConfigurations();
 }
index 9cbddbb13046202e482a6765c810bfd4e3507bd3..7097958126aaec02cf680265bad8322b6526ae5e 100644 (file)
@@ -352,16 +352,21 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene
         String controller = ci.nextArgument();
         if (controller == null) {
             ci.println("Nodes connected to this controller : ");
-            if (this.getLocalNodes() == null) ci.println("None");
-            else ci.println(this.getLocalNodes().toString());
+            if (this.getLocalNodes() == null) {
+                ci.println("None");
+            } else {
+                ci.println(this.getLocalNodes().toString());
+            }
             return;
         }
         try {
             InetAddress address = InetAddress.getByName(controller);
             ci.println("Nodes connected to controller "+controller);
-            if (this.getNodes(address) == null) ci.println("None");
-            else ci.println(this.getNodes(address).toString());
-            return;
+            if (this.getNodes(address) == null) {
+                ci.println("None");
+            } else {
+                ci.println(this.getNodes(address).toString());
+            }
         } catch (UnknownHostException e) {
            logger.error("An error occured",e);
         }
index 0166d279f66528135322f3c8d250ec381bd2de1a..03d9453126d89c8c5d9074bc7ec7b643c089d9a3 100644 (file)
@@ -30,13 +30,13 @@ public interface IForwardingStaticRouting {
      * @param ipAddress (InetAddress) the IP address
      * @return StaticRoute
      */
-    public StaticRoute getBestMatchStaticRoute(InetAddress ipAddress);
+    StaticRoute getBestMatchStaticRoute(InetAddress ipAddress);
 
     /**
      * Returns all the StaticRouteConfig
      * @return all the StaticRouteConfig
      */
-    public ConcurrentMap<String, StaticRouteConfig> getStaticRouteConfigs();
+    ConcurrentMap<String, StaticRouteConfig> getStaticRouteConfigs();
 
     /**
      * Adds a StaticRouteConfig
@@ -44,7 +44,7 @@ public interface IForwardingStaticRouting {
      * @return a text string indicating the result of the operation..
      * If the operation is successful, the return string will be "SUCCESS"
      */
-    public Status addStaticRoute(StaticRouteConfig config);
+    Status addStaticRoute(StaticRouteConfig config);
 
     /**
      * Removes  the named StaticRouteConfig
@@ -52,5 +52,5 @@ public interface IForwardingStaticRouting {
      * @return a text string indicating the result of the operation.
      * If the operation is successful, the return string will be "SUCCESS"
      */
-    public Status removeStaticRoute(String name);
+    Status removeStaticRoute(String name);
 }
index f650ee9e7748cc1a02a0a73191f9a2f22f0aea46..fb4863b1e04e2c0674068f224b65348d202044cd 100644 (file)
@@ -21,5 +21,5 @@ public interface IStaticRoutingAware {
      * @param s: StaticRoute
      * @param added: boolean true if the static route is added,
      */
-    public void staticRouteUpdate(StaticRoute s, boolean added);
+    void staticRouteUpdate(StaticRoute s, boolean added);
 }
index 1b2128957e9352ffd93a0a0991abf91ec3a354ea..89d24192455231487b926ce1b727b9cb76c4c71d 100644 (file)
@@ -63,7 +63,6 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
     private static Logger log = LoggerFactory
             .getLogger(StaticRoutingImplementation.class);
     private static String ROOT = GlobalConstants.STARTUPHOME.toString();
-    private static final String SAVE = "Save";
     ConcurrentMap<String, StaticRoute> staticRoutes;
     ConcurrentMap<String, StaticRouteConfig> staticRouteConfigs;
     private IfIptoHost hostTracker;
index 7b53eb0b8aa5b157555c87577eed9b9c27cf1eb0..dc4f13f497f5e5a0fce7b8035b71cd40512834b1 100644 (file)
@@ -30,7 +30,7 @@ public interface PortGroupProvider {
      *            New PortGroupConfig object created by user Configuration.
      * @return true if successful. false otherwise.
      */
-    public boolean createPortGroupConfig(PortGroupConfig config);
+    boolean createPortGroupConfig(PortGroupConfig config);
 
     /**
      * This method is invoked by the Controller towards the Provider when an
@@ -40,7 +40,7 @@ public interface PortGroupProvider {
      *            Existing Port Group Configuration deleted by the user.
      * @return true if successful. false otherwise.
      */
-    public boolean deletePortGroupConfig(PortGroupConfig config);
+    boolean deletePortGroupConfig(PortGroupConfig config);
 
     /**
      * Returns the complete mapping database corresponds to a PortGroup
@@ -54,7 +54,7 @@ public interface PortGroupProvider {
      * @return Database of Switch-Id to PortGroup mapping that corresponds to
      *         the Port Group User Configuration.
      */
-    public Map<Node, PortGroup> getPortGroupData(PortGroupConfig config);
+    Map<Node, PortGroup> getPortGroupData(PortGroupConfig config);
 
     /**
      * Returns PortGroup data for a given Switch and user Configuration. Its the
@@ -70,7 +70,7 @@ public interface PortGroupProvider {
      * @return PortGroup data for a given Openflow switch.
      * @see PortGroup
      */
-    public PortGroup getPortGroupData(PortGroupConfig config, long matrixSwitchId);
+    PortGroup getPortGroupData(PortGroupConfig config, long matrixSwitchId);
 
     /**
      * Registers a Listener for Port Group membership changes based on Custom
@@ -80,7 +80,7 @@ public interface PortGroupProvider {
      *            A Controller module that listens to events from the Custom
      *            Port Grouping Application.
      */
-    public void registerPortGroupChange(PortGroupChangeListener listener);
+    void registerPortGroupChange(PortGroupChangeListener listener);
 
     /**
      * Application returns an Usage string for the Match Criteria User
@@ -91,7 +91,7 @@ public interface PortGroupProvider {
      *
      * @return Usage string.
      */
-    public String getApplicationDrivenMatchCriteriaUsage();
+    String getApplicationDrivenMatchCriteriaUsage();
 
     /**
      * Returns the name of the Custom Application that implements
@@ -99,7 +99,7 @@ public interface PortGroupProvider {
      *
      * @return Provider Name
      */
-    public String getProviderName();
+    String getProviderName();
 
     /**
      * Controller uses this method to check with the Provider supports the
@@ -109,5 +109,5 @@ public interface PortGroupProvider {
      * @return true if the Provider supports the matchCriteria String. false
      *         otherwise.
      */
-    public boolean isMatchCriteriaSupported(String matchCriteria);
+    boolean isMatchCriteriaSupported(String matchCriteria);
 }
index 924d0717e966aa4731aa340e67a54efe18cbf991..64f4c7ef1e1d65bddcafd7310dccfe6b44278741 100644 (file)
@@ -244,10 +244,12 @@ public class Entity implements Comparable<Entity> {
     @Override
     public int compareTo(Entity o) {
         int r;
-        if (port == null)
+        if (port == null) {
             r = o.port == null ? 0 : -1;
-        else if (o.port == null)
+        }
+        else if (o.port == null) {
             r = 1;
+        }
         else {
             // XXX - the node id is only defined as an object rather
             // than something useful. We're just going to have to
index fb81cddc964c3887ad30ee030f8600140faea922..b2180297da3ca1438a522bc345aa491cccbdcc54 100755 (executable)
@@ -181,7 +181,8 @@ public class Device implements IDevice {
      * @param newEntity
      *            the entity to add. newEntity must be have the same entity
      *            class as device
-     * @param if positive indicates the index in the entities array were the new
+     * @param insertionpoint
+     *        if positive indicates the index in the entities array were the new
      *        entity should be inserted. If negative we will compute the correct
      *        insertion point
      */
@@ -240,10 +241,11 @@ public class Device implements IDevice {
 
         TreeSet<Short> vals = new TreeSet<Short>();
         for (Entity e : entities) {
-            if (e.getVlan() == null)
+            if (e.getVlan() == null) {
                 vals.add((short) -1);
-            else
+            } else {
                 vals.add(e.getVlan());
+            }
         }
         return vals.toArray(new Short[vals.size()]);
     }
@@ -313,15 +315,16 @@ public class Device implements IDevice {
             return false;
 
         for (AttachmentPoint ap : apList) {
-            if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System
-                    .currentTimeMillis())
-                expiredAPs.add(ap);
+            if (ap.getLastSeen() + AttachmentPoint.INACTIVITY_INTERVAL < System.currentTimeMillis()) {
+               expiredAPs.add(ap);
+            }
         }
         if (expiredAPs.size() > 0) {
             apList.removeAll(expiredAPs);
             return true;
-        } else
+        } else {
             return false;
+        }
     }
 
     /**
@@ -410,7 +413,6 @@ public class Device implements IDevice {
      * any change to the list of attachment points for the device -- which
      * indicates a device move.
      *
-     * @param sw
      * @param port
      * @param lastSeen
      * @return
@@ -525,7 +527,6 @@ public class Device implements IDevice {
     /**
      * Delete (sw,port) from the list of list of attachment points and oldAPs.
      *
-     * @param sw
      * @param port
      * @return
      */
@@ -703,10 +704,12 @@ public class Device implements IDevice {
         TreeSet<Short> vals = new TreeSet<Short>();
         for (Entity e : entities) {
             if (e.getPort().equals(swp.getPort())) {
-                if (e.getVlan() == null)
+                if (e.getVlan() == null) {
                     vals.add(VLAN_UNTAGGED);
-                else
+                }
+                else  {
                     vals.add(e.getVlan());
+                }
             }
         }
         return vals.toArray(new Short[vals.size()]);
index 95d33ceef90fcaf019cead9ffe9a2a97858e8e47..03909076164561b84b7685771479e515d0dbc3f4 100755 (executable)
@@ -385,11 +385,11 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener,
             long newDomain = 0;
             boolean newBD = false;
 
-            if (oldDomain < newDomain)
-                return -1;
-            else if (oldDomain > newDomain)
+            if (oldDomain < newDomain) {
+               return -1;
+            } else if (oldDomain > newDomain) {
                 return 1;
-
+            }
             // Give preference to OFPP_LOCAL always
             if (!oldAP.getPort().getType().equals(NodeConnectorIDType.SWSTACK)
                     && newAP.getPort().getType()
index 55a7ecb9cdd861a96c0f431b86823810d7a548c4..1deda7c9d0d73ff3250dbcbcb2d08c215f624954 100644 (file)
@@ -156,16 +156,20 @@ public class Subnet implements Cloneable, Serializable {
     }
 
     public boolean isSubnetOf(InetAddress ip) {
-        if (ip == null)
+        if (ip == null) {
             return false;
+        }
         InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
         InetAddress otherPrefix = getPrefixForAddress(ip);
-        if ((thisPrefix == null) || (otherPrefix == null))
+        if ((thisPrefix == null) || (otherPrefix == null)) {
             return false;
-        if (thisPrefix.equals(otherPrefix))
+        }
+        if (thisPrefix.equals(otherPrefix)) {
             return true;
-        else
+        }
+        else {
             return false;
+        }
     }
 
     public short getVlan() {
index 74e39b225cc58cd312dab0270c428211a819b2b6..361a03b92647f61e51f792c38db0010ee245c0d4 100644 (file)
@@ -128,10 +128,11 @@ public class OFError extends OFMessage implements OFMessageFactoryAware {
         // OVS apparently sends partial messages in errors
         // need to be careful of that AND can't use data.limit() as
         // a packet boundary because there could be more data queued
-        if (messages.size() > 0)
+        if (messages.size() > 0) {
             return messages.get(0);
-        else
+        } else {
             return null;
+        }
     }
 
     /**
index d5e5ab05463eac633e627cdd506909749a0708ca..f26ca51a790cc3439b024949e4f3920991a65831 100644 (file)
@@ -74,11 +74,12 @@ import org.openflow.util.HexString;
                
                public void setNextHop(InetAddress address) {
                        short actionLen;
-                       if (address instanceof Inet4Address) 
-                               actionLen = (short)ONHLength.ONH_LEN_IPV4.getValue();
-                       else
-                               actionLen = (short)ONHLength.ONH_LEN_IPV6.getValue();
-                       super.setLength(actionLen);
+                       if (address instanceof Inet4Address) {
+                actionLen = (short)ONHLength.ONH_LEN_IPV4.getValue();
+            } else {
+                actionLen = (short)ONHLength.ONH_LEN_IPV6.getValue();
+            }
+            super.setLength(actionLen);
                        this.address = address;
                }
                public InetAddress getNextHop() {