Merge "Refactored YANG types resolving."
authorGiovanni Meo <gmeo@cisco.com>
Thu, 18 Apr 2013 05:37:51 +0000 (05:37 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 18 Apr 2013 05:37:51 +0000 (05:37 +0000)
22 files changed:
opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.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/FlowProgrammerService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Error.java [new file with mode: 0644]
opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct_combined/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoYangFiles/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/ConfigArg.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToResourcesMojo.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/main/java/org/opendaylight/controller/yang2sources/spi/CodeGenerator.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/main/java/org/opendaylight/controller/yang2sources/spi/ResourceGenerator.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 7046e343e726658d37ec1ea9e49006136c4b261c..371dca69698f8616178e18af522a310ab12e2c1d 100644 (file)
@@ -201,7 +201,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         logger.debug("Retrieving cache for HostTrackerIH");
         inactiveStaticHosts = (ConcurrentMap<NodeConnector, HostNodeConnector>) this.clusterContainerService
                 .getCache("hostTrackerIH");
-        if (hostsDB == null) {
+        if (inactiveStaticHosts == null) {
             logger.error("Cache couldn't be retrieved for HostTrackerIH");
         }
         logger.debug("Cache was successfully retrieved for HostTrackerIH");
index f3004acaba5a3cb6c9ffb287bd968599283f1001..32cdeaa614e55264e397085c1e9ff05174fd6aff 100644 (file)
@@ -9,6 +9,7 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -338,6 +339,28 @@ public class Controller implements IController, CommandProvider {
         }
     }
 
+    public void _controllerShowConnConfig(CommandInterpreter ci) {
+       String str = System.getProperty("secureChannelEnabled");
+        if ((str != null) && (str.trim().equalsIgnoreCase("true"))) { 
+            ci.print("The Controller and Switch should communicate through TLS connetion.\n");         
+
+               String keyStoreFile = System.getProperty("controllerKeyStore");
+               String trustStoreFile = System.getProperty("controllerTrustStore");
+               if ((keyStoreFile == null) || keyStoreFile.trim().isEmpty()) {          
+                ci.print("controllerKeyStore not specified in ./configuration/config.ini\n");                                  
+               } else {
+                ci.print("controllerKeyStore=" + keyStoreFile + "\n");         
+               }
+               if ((trustStoreFile == null) || trustStoreFile.trim().isEmpty()) {      
+                ci.print("controllerTrustStore not specified in ./configuration/config.ini\n");                                                                
+               } else {
+                ci.print("controllerTrustStore=" + trustStoreFile + "\n");             
+               }
+        } else {
+            ci.print("The Controller and Switch should communicate through TCP connetion.\n");         
+        }
+    }
+
     private void registerWithOSGIConsole() {
         BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass())
                 .getBundleContext();
@@ -351,6 +374,7 @@ public class Controller implements IController, CommandProvider {
         help.append("--Open Flow Controller --\n");
         help.append("\tcontrollerShowSwitches\n");
         help.append("\tcontrollerReset\n");
+        help.append("\tcontrollerShowConnConfig\n");
         return help.toString();
     }
 }
index fb34b0f06371538930abc6fed698e4f6df12a735..8e611924e41ae8b6ce5951397e002f3b5f16cf81 100644 (file)
@@ -69,6 +69,8 @@ public class MessageReadWriteService implements IMessageReadWrite {
                        newBuffer.put(outBuffer);
                        outBuffer = newBuffer;
                }
+       }
+       synchronized (outBuffer) {
                msg.writeTo(outBuffer);
 
                if (!socket.isOpen()) {
index ddc87bc530a719fc3b6c3439ad6851bdeebf78bc..bb8ba04fb8cab97ede7cd7d03d3c4aa25a4800fc 100644 (file)
@@ -10,6 +10,7 @@
 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
 
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.AsynchronousCloseException;
@@ -74,11 +75,36 @@ public class SecureMessageReadWriteService implements IMessageReadWrite {
         * @throws Exception
         */
     private void createSecureChannel(SocketChannel socket) throws Exception {
-       String keyStoreFile = System.getProperty("controllerKeyStore").trim();
-       String keyStorePassword = System.getProperty("controllerKeyStorePassword").trim();
-       String trustStoreFile = System.getProperty("controllerTrustStore").trim();
-       String trustStorePassword = System.getProperty("controllerTrustStorePassword").trim();
-
+       String keyStoreFile = System.getProperty("controllerKeyStore");
+       String keyStorePassword = System.getProperty("controllerKeyStorePassword");
+       String trustStoreFile = System.getProperty("controllerTrustStore");
+       String trustStorePassword = System.getProperty("controllerTrustStorePassword");
+       
+       if (keyStoreFile != null) {
+               keyStoreFile = keyStoreFile.trim();
+       }
+       if ((keyStoreFile == null) || keyStoreFile.isEmpty()) {
+               throw new FileNotFoundException("controllerKeyStore not specified in ./configuration/config.ini");
+       }
+       if (keyStorePassword != null) {
+               keyStorePassword = keyStorePassword.trim();
+       } 
+       if ((keyStorePassword == null) || keyStorePassword.isEmpty()) {
+               throw new FileNotFoundException("controllerKeyStorePassword not specified in ./configuration/config.ini");
+       }
+       if (trustStoreFile != null) {
+               trustStoreFile = trustStoreFile.trim();
+       }
+       if ((trustStoreFile == null) || trustStoreFile.isEmpty()) {     
+               throw new FileNotFoundException("controllerTrustStore not specified in ./configuration/config.ini");
+       }
+       if (trustStorePassword != null) {
+               trustStorePassword = trustStorePassword.trim();
+       }
+        if ((trustStorePassword == null) || trustStorePassword.isEmpty()) {
+               throw new FileNotFoundException("controllerTrustStorePassword not specified in ./configuration/config.ini");
+       }
+       
         KeyStore ks = KeyStore.getInstance("JKS");
         KeyStore ts = KeyStore.getInstance("JKS");
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
@@ -126,6 +152,8 @@ public class SecureMessageReadWriteService implements IMessageReadWrite {
                        newBuffer.put(myAppData);
                        myAppData = newBuffer;
                }
+       }
+       synchronized (myAppData) {
                msg.writeTo(myAppData);
                myAppData.flip();
                sslEngineResult = sslEngine.wrap(myAppData, myNetData);
index cba8b1d4f17c38a9d232e1b54a3463c96cfe8dbf..5913ad0dd960036f3362c5e2325d0af5209529ab 100644 (file)
@@ -9,7 +9,7 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
 
-import java.io.IOException;
+import java.net.SocketException;
 import java.nio.channels.AsynchronousCloseException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -249,7 +249,9 @@ public class SwitchHandler implements ISwitch {
     @Override
     public Integer asyncSend(OFMessage msg, int xid) {
        msg.setXid(xid);
-       transmitQ.add(new PriorityMessage(msg, 0));
+       if (transmitQ != null) {
+               transmitQ.add(new PriorityMessage(msg, 0));
+       }
         return xid;
     }
 
@@ -280,13 +282,17 @@ public class SwitchHandler implements ISwitch {
     @Override
     public Integer asyncFastSend(OFMessage msg, int xid) {
        msg.setXid(xid);
-       transmitQ.add(new PriorityMessage(msg, 1));
+       if (transmitQ != null) {
+               transmitQ.add(new PriorityMessage(msg, 1));
+       }
         return xid;
     }
 
    public void resumeSend() {
         try {
-                       msgReadWriteService.resumeSend();
+               if (msgReadWriteService != null) {
+                       msgReadWriteService.resumeSend();
+               }
                } catch (Exception e) {
                        reportError(e);
                }
@@ -445,7 +451,9 @@ public class SwitchHandler implements ISwitch {
     }
 
     private void reportError(Exception e) {
-       if (e instanceof AsynchronousCloseException) {
+       if (e instanceof AsynchronousCloseException ||
+               e instanceof InterruptedException ||
+               e instanceof SocketException) {
                logger.debug("Caught exception {}", e.getMessage());
        } else {
                logger.warn("Caught exception {}", e.getMessage());
@@ -739,6 +747,8 @@ public class SwitchHandler implements ISwitch {
                                logger.trace("Message sent: {}", pmsg.toString());
                        }
                        Thread.sleep(10);
+               } catch (InterruptedException ie) {
+                       reportError(new InterruptedException("PriorityMessageTransmit thread interrupted"));
                } catch (Exception e) {
                        reportError(e);
                }
index b30b5c76c10470655f94a30827fe8bebca49638b..983c7c2190e09d19298f7454a093615956f91299 100644 (file)
@@ -9,8 +9,10 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.internal;
 
+import java.nio.ByteBuffer;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
+import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Error;
 import org.openflow.protocol.OFError;
 import org.openflow.protocol.OFFlowMod;
 import org.openflow.protocol.OFMessage;
@@ -22,6 +24,8 @@ import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.controller.sal.utils.Status;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Represents the openflow plugin component in charge of programming the flows
@@ -31,6 +35,8 @@ import org.opendaylight.controller.sal.utils.Status;
  *
  */
 public class FlowProgrammerService implements IPluginInFlowProgrammerService {
+       private static final Logger log = LoggerFactory
+    .getLogger(FlowProgrammerService.class);
     private IController controller;
 
     public FlowProgrammerService() {
@@ -107,9 +113,21 @@ public class FlowProgrammerService implements IPluginInFlowProgrammerService {
                                     errorString(null, action,
                                             "Request Timed Out"));
                 } else if (result instanceof OFError) {
+                       OFError res = (OFError) result;
+                       if (res.getErrorType() == V6Error.NICIRA_VENDOR_ERRORTYPE) {
+                               V6Error er = new V6Error(res);
+                               byte[] b = res.getError();
+                               ByteBuffer bb = ByteBuffer.allocate(b.length);
+                               bb.put(b);
+                               bb.rewind();
+                               er.readFrom(bb);
+                               log.trace("V6Error {}",er);
+                               return new Status(StatusCode.INTERNALERROR,
+                                errorString("program", action, "Vendor Extension Internal Error"));
+                       }
                     return new Status(StatusCode.INTERNALERROR,
                             errorString("program", action, Utils
-                            .getOFErrorString((OFError) result)));
+                            .getOFErrorString(res)));
                 } else {
                     return new Status(StatusCode.INTERNALERROR,
                             errorString("send", action, "Internal Error"));
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Error.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Error.java
new file mode 100644 (file)
index 0000000..4f0dbd5
--- /dev/null
@@ -0,0 +1,80 @@
+package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
+
+import java.nio.ByteBuffer;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.openflow.protocol.OFError;
+
+public class V6Error extends OFError {
+       private static final long serialVersionUID = 1L;
+       public static int MINIMUM_LENGTH = 20;//OfHdr(8) + NXET_VENDOR(2) + NXEC_VENDOR_ERROR(2) + struct nx_vendor_error(8)
+       public static final short NICIRA_VENDOR_ERRORTYPE = (short)0xb0c2;
+       protected int V6VendorId;
+    protected short V6VendorErrorType;
+    protected short V6VendorErrorCode;
+    protected byte[] V6ErrorData;
+    
+    public V6Error(OFError e) {
+        this.length = (short)e.getLengthU();
+        this.errorType = e.getErrorType();
+        this.errorCode = e.getErrorCode();
+        this.xid = e.getXid();
+    }
+    
+    @Override
+    public void readFrom(ByteBuffer data) {
+        this.V6VendorId = data.getInt();
+        this.V6VendorErrorType = data.getShort();
+        this.V6VendorErrorCode = data.getShort();
+        int dataLength = this.getLengthU() - MINIMUM_LENGTH;
+        if (dataLength > 0) {
+            this.V6ErrorData = new byte[dataLength];
+            data.get(this.V6ErrorData);
+        }   
+    }
+    
+    /**
+     * @return the V6VendorId
+     */
+    public int getVendorId() {
+        return V6VendorId;
+    }
+    
+    /**
+     * @return the V6VendorErrorType
+     */
+    public short getVendorErrorType() {
+        return V6VendorErrorType;
+    }
+    
+    /**
+     * @return the VendorErrorType
+     */
+    public short getVendorErrorCode() {
+        return V6VendorErrorCode;
+    }
+    
+    /**
+     * @return the Error Bytes
+     */
+    public byte[] getError() {
+        return V6ErrorData;
+    }
+    
+    @Override
+    public int hashCode() {
+        return HashCodeBuilder.reflectionHashCode(this);
+    }
+
+    @Override
+    public String toString() {
+        return "V6Error[" + ReflectionToStringBuilder.toString(this) + "]";
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return EqualsBuilder.reflectionEquals(this, obj);
+    }
+}
index 05ec5d40530919941dd69f67a197111c7a565687..64cc3fbe01045f8e2bf372fbae0ee8e360f9f908 100644 (file)
@@ -111,22 +111,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                             .getNodeConnectorProp(dstNC,
                                     Bandwidth.BandwidthPropName);
 
-                    if ((bwSrc == null) || (bwDst == null)) {
-                        log.error("bwSrc:{} or bwDst:{} is null", bwSrc, bwDst);
-                        return (double) -1;
-                    }
-
-                    long srcLinkSpeed = bwSrc.getValue();
-                    if (srcLinkSpeed == 0) {
-                        log.trace("Edge {}: srcLinkSpeed is 0. Setting to {}!",
-                                e, DEFAULT_LINK_SPEED);
-                        srcLinkSpeed = DEFAULT_LINK_SPEED;
+                    long srcLinkSpeed = 0, dstLinkSpeed = 0;
+                    if ((bwSrc == null) || ((srcLinkSpeed = bwSrc.getValue()) == 0)) {
+                        log.debug("srcNC: {} - Setting srcLinkSpeed to Default!",srcNC);
+                         srcLinkSpeed = DEFAULT_LINK_SPEED;
                     }
-
-                    long dstLinkSpeed = bwDst.getValue();
-                    if (dstLinkSpeed == 0) {
-                        log.trace("Edge {}: dstLinkSpeed is 0. Setting to {}!",
-                                e, DEFAULT_LINK_SPEED);
+                    if ((bwDst == null) || ((dstLinkSpeed = bwDst.getValue()) == 0)) {
+                        log.debug("dstNC: {} - Setting dstLinkSpeed to Default!",dstNC);
                         dstLinkSpeed = DEFAULT_LINK_SPEED;
                     }
 
index 5584cd9461abc54d3e79a5c57737f576c0b9e816..5f2dc92aee8c06dd8e204a10af04910cf426bafb 100644 (file)
@@ -11,7 +11,7 @@
  * @file   Path.java
  *
  * @brief  Describe a path as a sequence of Edge such that from
- * each of its Tail Node there is an link to the next Head Node in the sequence
+ * each of its Head Node there is an link to the next Tail Node in the sequence
  *
  */
 package org.opendaylight.controller.sal.core;
@@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlElement;
 
 /**
  * Describe a path as a sequence of Edge such that from
- * each of its Tail Node there is an link to the next Head Node in the
+ * each of its Head Node there is an link to the next Tail Node in the
  * sequence
  *
  */
@@ -50,15 +50,15 @@ public class Path implements Serializable {
     /**
      * Construct an object representing a path, the constructor will
      * check if the passed list of edges is such that for every
-     * consecutive edges the tailnode of the first edge coincide with
-     * the head node of the subsequent in order for connectivity to be there.
+     * consecutive edges the head node of the first edge coincide with
+     * the tail node of the subsequent in order for connectivity to be there.
      *
      * @param edges Edges of the path
      *
      */
     public Path(List<Edge> edges) throws ConstructionException {
-        // Lets check if the list of edges is such that the tail node
-        // of an edge is also the head node of the subsequent one
+        // Lets check if the list of edges is such that the head node
+        // of an edge is also the tail node of the subsequent one
         boolean sequential = true;
         if (edges.size() >= 2) {
             for (int i = 0; i < edges.size() - 1; i++) {
index f7810fec78718949d0190df98084075ffaeeae8b..33d1053f7dccc4c1ac7554c7c482d736428fb3f9 100644 (file)
@@ -38,7 +38,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 190e2c184bdceab587d7ea3cbc5822c77982a8ba..4fd10ea70f0aeccbdc316a6505b668d379f1ad39 100644 (file)
@@ -49,7 +49,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 03ae399362f34aada1bc22fdf34b56b58ddeb078..acb8e6036a65a415776679a8bdbf49113cdccdaa 100644 (file)
@@ -38,7 +38,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 561946e71bef4522d13057f2d44829cf887c477f..a64c7593943c657bca8b9b58ebf6d7f19fc951af 100644 (file)
@@ -38,7 +38,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 54b1c748a41698e2eb009736e8434a849c32eea8..88829dff0c03e8ece2b0be3f9d72d3943bab2924 100644 (file)
@@ -46,7 +46,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 503b45f478024c3edf0bd239a5caeb6d0b7af7c6..9d4175d2df287a2ebc754b36e4a992960324bf3e 100644 (file)
@@ -46,7 +46,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
-                        <artifactId>yang-to-sources</artifactId>
+                        <artifactId>maven-yang</artifactId>
                         <version>1.0</version>
                         <type>test-jar</type>
                     </dependency>
index 1dd56914115732c6675cfbb70bf77cfda7e25f65..f9e3a9a6ffe65afad1e117e2634114ef547a01cd 100644 (file)
@@ -9,6 +9,14 @@
 
     <artifactId>maven-yang-plugin</artifactId>
     <packaging>maven-plugin</packaging>
+    <description>
+        This plugin is a wrapper for "yang to source code" generation.
+        It can be configured by a set of third-party code generators and resource providers.
+        For further info see available goals.
+        Sample usage:
+
+        TODO: add sample usage when finished
+    </description>
 
     <dependencies>
         <dependency>
         </dependency>
     </dependencies>
 
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>3.2</version>
+            </plugin>
+        </plugins>
+    </reporting>
+
     <build>
         <plugins>
             <plugin>
index f6602e6aae5bf029773cefb38cc1162bfa29aa2f..85f2d8905dd51e48e648a495c85dc8f8d93afaf1 100644 (file)
@@ -12,7 +12,7 @@ import java.io.File;
 import com.google.common.base.Preconditions;
 
 /**
- * Complex configuration arguments
+ * Base complex configuration arguments
  */
 public abstract class ConfigArg {
 
@@ -31,6 +31,9 @@ public abstract class ConfigArg {
 
     public abstract void check();
 
+    /**
+     * Configuration argument for resource generator class and output directory.
+     */
     public static final class ResourceProviderArg extends ConfigArg {
         private String resourceProviderClass;
 
@@ -59,7 +62,7 @@ public abstract class ConfigArg {
     }
 
     /**
-     * Transfer object for code generator class and output directory.
+     * Configuration argument for code generator class and output directory.
      */
     public static final class CodeGeneratorArg extends ConfigArg {
         private String codeGeneratorClass;
index 7bb49dc0dff1abb78d6d893b198077dc28425659..b4490499cfd43dcc3d727240d0ccb5b2aa9a9b16 100644 (file)
@@ -23,14 +23,40 @@ import org.opendaylight.controller.yang2sources.spi.ResourceGenerator;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
 
+/**
+ * Generate resources from yang files using user provided set of
+ * {@link ResourceGenerator}s. Can be used to copy yang files that served as
+ * blueprint for code generation into resources directory. Steps of this
+ * process:
+ * <ol>
+ * <li>List yang files from {@link #yangFilesRootDir} (If this goal is in the
+ * same execution as generate-sources, the same cached list will be used and the
+ * root folder will not be searched for yang files twice)</li>
+ * <li>For each {@link ResourceGenerator} from {@link #resourceProviders}:</li>
+ * <ol>
+ * <li>Instantiate using default constructor</li>
+ * <li>Call {@link ResourceGenerator#generateResourceFiles(Collection, File)}</li>
+ * </ol>
+ * </ol>
+ */
 @Mojo(name = "generate-resources", defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
 public final class YangToResourcesMojo extends AbstractMojo {
 
     private static final String LOG_PREFIX = "yang-to-resources:";
 
+    /**
+     * Classes implementing {@link ResourceGenerator} interface. An instance
+     * will be created out of every class using default constructor. Method
+     * {@link ResourceGenerator#generateResourceFiles(Collection, File)} will be
+     * called on every instance.
+     */
     @Parameter(required = true)
     private ResourceProviderArg[] resourceProviders;
 
+    /**
+     * Source directory that will be recursively searched for yang files (ending
+     * with .yang suffix).
+     */
     @Parameter(required = true)
     private String yangFilesRootDir;
 
index 29282988d6ef267b82f2e1383ca8eb1653d716be..32ad2abb104c65a9cfe78aec8acb4bb310796961 100644 (file)
@@ -29,14 +29,37 @@ import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
 
+/**
+ * Generate sources from yang files using user provided set of
+ * {@link CodeGenerator}s. Steps of this process:
+ * <ol>
+ * <li>List yang files from {@link #yangFilesRootDir}</li>
+ * <li>Process yang files using {@link YangModelParserImpl}</li>
+ * <li>For each {@link CodeGenerator} from {@link #codeGenerators}:</li>
+ * <ol>
+ * <li>Instantiate using default constructor</li>
+ * <li>Call {@link CodeGenerator#generateSources(SchemaContext, File)}</li>
+ * </ol>
+ * </ol>
+ */
 @Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
 public final class YangToSourcesMojo extends AbstractMojo {
 
     private static final String LOG_PREFIX = "yang-to-sources:";
 
+    /**
+     * Classes implementing {@link CodeGenerator} interface. An instance will be
+     * created out of every class using default constructor. Method
+     * {@link CodeGenerator#generateSources(SchemaContext, File)} will be called
+     * on every instance.
+     */
     @Parameter(required = true)
     private CodeGeneratorArg[] codeGenerators;
 
+    /**
+     * Source directory that will be recursively searched for yang files (ending
+     * with .yang suffix).
+     */
     @Parameter(required = true)
     private String yangFilesRootDir;
 
index 2b39320989e542e4c55a4d83f330562a8404809a..534c37de10399447b95a06962ce99e88d0303a96 100644 (file)
@@ -12,7 +12,21 @@ import java.util.Collection;
 
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 
+/**
+ * Classes implementing this interface can be submitted to maven-yang-plugin's
+ * generate-sources goal.
+ */
 public interface CodeGenerator {
 
+    /**
+     * Generate sources from provided {@link SchemaContext}
+     * 
+     * @param context
+     *            parsed from yang files
+     * @param outputBaseDir
+     *            expected output directory for generated sources configured by
+     *            user
+     * @return collection of files that were generated from schema context
+     */
     Collection<File> generateSources(SchemaContext context, File outputBaseDir);
 }
index 9095155b0ccf5b52021771f8ce491a1c8eefa434..2638dc33b021fae8bec0261719da95c27109bbe9 100644 (file)
@@ -10,7 +10,20 @@ package org.opendaylight.controller.yang2sources.spi;
 import java.io.File;
 import java.util.Collection;
 
+/**
+ * Classes implementing this interface can be submitted to maven-yang-plugin's
+ * generate-resources goal.
+ */
 public interface ResourceGenerator {
 
+    /**
+     * Generate resources (e.g. copy files into resources folder) from provided
+     * list of yang files
+     * 
+     * @param resources
+     *            list of parsed yang files
+     * @param outputBaseDir
+     *            expected output directory for resources configured by user
+     */
     void generateResourceFiles(Collection<File> resources, File outputBaseDir);
 }
index 227df54944b115107079a93058c4845824110713..0eb7bdbc5c3ac57bc44f8168189456614e8eff98 100644 (file)
@@ -95,23 +95,26 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     void setTopologyManagerAware(ITopologyManagerAware s) {
         if (this.topologyManagerAware != null) {
-               log.debug("Adding ITopologyManagerAware: " + s);
+               log.debug("Adding ITopologyManagerAware: {}", s);
             this.topologyManagerAware.add(s);
         }
     }
 
     void unsetTopologyManagerAware(ITopologyManagerAware s) {
         if (this.topologyManagerAware != null) {
+               log.debug("Removing ITopologyManagerAware: {}", s);
             this.topologyManagerAware.remove(s);
         }
     }
 
     void setTopoService(ITopologyService s) {
+       log.debug("Adding ITopologyService: {}", s);
         this.topoService = s;
     }
 
     void unsetTopoService(ITopologyService s) {
         if (this.topoService == s) {
+               log.debug("Removing ITopologyService: {}", s);
             this.topoService = null;
         }
     }
@@ -229,7 +232,7 @@ public class TopologyManagerImpl implements ITopologyManager,
         this.clusterContainerService
                 .destroyCache("topologymanager.nodeConnectorDB");
         this.nodeConnectorsDB = null;
-        log.debug("Topology Manager DB DE-allocated");
+        log.debug("Topology Manager DB Deallocated");
     }
 
     @SuppressWarnings("unchecked")
@@ -408,7 +411,7 @@ public class TopologyManagerImpl implements ITopologyManager,
         if (this.hostsDB == null) {
             return;
         }
-
+        
         switch (t) {
         case ADDED:
         case CHANGED:
@@ -470,6 +473,7 @@ public class TopologyManagerImpl implements ITopologyManager,
                     new HashSet<Property>());
             this.nodeConnectorsDB.put(e.getTailNodeConnector(),
                     new HashSet<Property>());
+            log.trace("Edge {}  {}", e.toString(), type.name());
             break;
         case REMOVED:
             // Now remove the edge from edgesDB
@@ -484,6 +488,7 @@ public class TopologyManagerImpl implements ITopologyManager,
             // should be safe to assume that won't happen.
             this.nodeConnectorsDB.remove(e.getHeadNodeConnector());
             this.nodeConnectorsDB.remove(e.getTailNodeConnector());
+            log.trace("Edge {}  {}", e.toString(), type.name());
             break;
         case CHANGED:
             Set<Property> old_props = this.edgesDB.get(e);
@@ -530,6 +535,7 @@ public class TopologyManagerImpl implements ITopologyManager,
 
             // Finally update
             this.edgesDB.put(e, props);
+            log.trace("Edge {}  {}", e.toString(), type.name());
             break;
         }
 
@@ -675,16 +681,16 @@ public class TopologyManagerImpl implements ITopologyManager,
                 //oneTopology.deleteUserConfiguredLink(linkTuple);
             } catch (Exception e) {
                 log
-                        .warn("Harmless : Exception while Deleting User Configured link "
-                                + link + " " + e.toString());
+                        .warn("Harmless : Exception while Deleting User Configured link {} {}",
+                                link, e.toString());
             }
             linkTuple = getReverseLinkTuple(link);
             try {
                 //oneTopology.deleteUserConfiguredLink(linkTuple);
             } catch (Exception e) {
                 log
-                        .error("Harmless : Exception while Deleting User Configured Reverse link "
-                                + link + " " + e.toString());
+                        .warn("Harmless : Exception while Deleting User Configured Reverse link {} {}",
+                                link, e.toString());
             }
         }
         return new Status(StatusCode.SUCCESS, null);
@@ -822,12 +828,12 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     @Override
     public void edgeOverUtilized(Edge edge) {
-        log.warn("Link Utilization above normal: " + edge);
+        log.warn("Link Utilization above normal: {}", edge);
     }
 
     @Override
     public void edgeUtilBackToNormal(Edge edge) {
-        log.warn("Link Utilization back to normal: " + edge);
+        log.warn("Link Utilization back to normal: {}", edge);
     }
 
 }