Javadoc and code cleanup for SDN-IP

Change-Id: I4b2cd853cb2c91ace2c710b215a7b2dca9301c28
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
index cd32101..fd7950f 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.sdnip;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -27,6 +29,7 @@
 import java.util.concurrent.Semaphore;
 
 import org.apache.commons.lang3.tuple.Pair;
+import org.onlab.packet.Ip4Prefix;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.flow.criteria.Criteria.IPCriterion;
 import org.onosproject.net.flow.criteria.Criterion;
@@ -36,14 +39,15 @@
 import org.onosproject.net.intent.IntentState;
 import org.onosproject.net.intent.MultiPointToSinglePointIntent;
 import org.onosproject.net.intent.PointToPointIntent;
-import org.onlab.packet.Ip4Prefix;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
-import static com.google.common.base.Preconditions.checkArgument;
-
+/**
+ * Synchronizes intents between the in-memory intent store and the
+ * IntentService.
+ */
 public class IntentSynchronizer {
     private static final Logger log =
         LoggerFactory.getLogger(IntentSynchronizer.class);
@@ -148,6 +152,11 @@
         }
     }
 
+    /**
+     * Signals the synchronizer that the SDN-IP leadership has changed.
+     *
+     * @param isLeader true if this instance is now the leader, otherwise false
+     */
     public void leaderChanged(boolean isLeader) {
         log.debug("SDN-IP Leader changed: {}", isLeader);
 
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
index cad0d50..c642166 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/PeerConnectivityManager.java
@@ -19,6 +19,10 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.IPv4;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -32,10 +36,6 @@
 import org.onosproject.sdnip.config.Interface;
 import org.onosproject.sdnip.config.InterfaceAddress;
 import org.onosproject.sdnip.config.SdnIpConfigurationService;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,10 +56,10 @@
     /**
      * Creates a new PeerConnectivityManager.
      *
-     * @param appId             the application ID
+     * @param appId              the application ID
      * @param intentSynchronizer the intent synchronizer
-     * @param configService     the SDN-IP config service
-     * @param interfaceService  the interface service
+     * @param configService      the SDN-IP config service
+     * @param interfaceService   the interface service
      */
     public PeerConnectivityManager(ApplicationId appId,
                                    IntentSynchronizer intentSynchronizer,
@@ -75,20 +75,12 @@
      * Starts the peer connectivity manager.
      */
     public void start() {
-        // TODO are any of these errors?
         if (interfaceService.getInterfaces().isEmpty()) {
-
-            log.warn("The interface in configuration file is empty. "
-                             + "Thus, the SDN-IP application can not be started.");
+            log.warn("No interfaces found in configuration file");
         } else if (configService.getBgpPeers().isEmpty()) {
-
-            log.warn("The BGP peer in configuration file is empty."
-                             + "Thus, the SDN-IP application can not be started.");
-        } else if (configService.getBgpSpeakers() == null) {
-
-            log.error("The BGP speaker in configuration file is empty. "
-                              + "Thus, the SDN-IP application can not be started.");
-            return;
+            log.warn("No BGP peers found in configuration file");
+        } else if (configService.getBgpSpeakers().isEmpty()) {
+            log.error("No BGP speakers found in configuration file");
         }
 
         setUpConnectivity();
@@ -174,8 +166,7 @@
 
         TrafficSelector selector;
 
-        // install intent for BGP path from BGPd to BGP peer matching
-        // destination TCP port 179
+        // Path from BGP speaker to BGP peer matching destination TCP port 179
         selector = buildSelector(IPv4.PROTOCOL_TCP,
                                  bgpdAddress,
                                  bgpdPeerAddress,
@@ -185,8 +176,7 @@
         intents.add(new PointToPointIntent(appId, selector, treatment,
                                bgpdConnectPoint, bgpdPeerConnectPoint));
 
-        // install intent for BGP path from BGPd to BGP peer matching
-        // source TCP port 179
+        // Path from BGP speaker to BGP peer matching source TCP port 179
         selector = buildSelector(IPv4.PROTOCOL_TCP,
                                  bgpdAddress,
                                  bgpdPeerAddress,
@@ -196,8 +186,7 @@
         intents.add(new PointToPointIntent(appId, selector, treatment,
                                bgpdConnectPoint, bgpdPeerConnectPoint));
 
-        // install intent for reversed BGP path from BGP peer to BGPd
-        // matching destination TCP port 179
+        // Path from BGP peer to BGP speaker matching destination TCP port 179
         selector = buildSelector(IPv4.PROTOCOL_TCP,
                                  bgpdPeerAddress,
                                  bgpdAddress,
@@ -207,8 +196,7 @@
         intents.add(new PointToPointIntent(appId, selector, treatment,
                                bgpdPeerConnectPoint, bgpdConnectPoint));
 
-        // install intent for reversed BGP path from BGP peer to BGPd
-        // matching source TCP port 179
+        // Path from BGP peer to BGP speaker matching source TCP port 179
         selector = buildSelector(IPv4.PROTOCOL_TCP,
                                  bgpdPeerAddress,
                                  bgpdAddress,
@@ -218,7 +206,7 @@
         intents.add(new PointToPointIntent(appId, selector, treatment,
                                bgpdPeerConnectPoint, bgpdConnectPoint));
 
-        // install intent for ICMP path from BGPd to BGP peer
+        // ICMP path from BGP speaker to BGP peer
         selector = buildSelector(IPv4.PROTOCOL_ICMP,
                                  bgpdAddress,
                                  bgpdPeerAddress,
@@ -228,7 +216,7 @@
         intents.add(new PointToPointIntent(appId, selector, treatment,
                                bgpdConnectPoint, bgpdPeerConnectPoint));
 
-        // install intent for reversed ICMP path from BGP peer to BGPd
+        // ICMP path from BGP peer to BGP speaker
         selector = buildSelector(IPv4.PROTOCOL_ICMP,
                                  bgpdPeerAddress,
                                  bgpdAddress,
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
index 6db770d..9018fca 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
@@ -180,6 +180,13 @@
         intentSynchronizer.leaderChanged(isPrimary);
     }
 
+    /**
+     * Converts DPIDs of the form xx:xx:xx:xx:xx:xx:xx to OpenFlow provider
+     * device URIs.
+     *
+     * @param dpid the DPID string to convert
+     * @return the URI string for this device
+     */
     static String dpidToUri(String dpid) {
         return "of:" + dpid.replace(":", "");
     }
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/config/SdnIpConfigurationService.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/config/SdnIpConfigurationService.java
index 51bffb9..3b86a22 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/config/SdnIpConfigurationService.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/config/SdnIpConfigurationService.java
@@ -20,8 +20,7 @@
 import org.onlab.packet.IpAddress;
 
 /**
- * Provides information about the layer 3 properties of the network.
- * This is based on IP addresses configured on ports in the network.
+ * Provides information about the BGP elements configured in the network.
  */
 public interface SdnIpConfigurationService {