Added comments to some functions. No logic change. Passed the 8 test cases of sanity check.

Change-Id: Iea8978ad256a1bfd9915a793380de178711ca167
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
index a2b8a56..fdbd66c 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -1087,6 +1087,9 @@
         return this.tunnelTable.values();
     }
 
+    /**
+     * Return the Policy Table
+     */
     public Collection<SegmentRoutingPolicy> getPoclicyTable() {
         return this.policyTable.values();
     }
@@ -1142,6 +1145,10 @@
         }
     }
 
+    /**
+     *  Create a policy
+     *  TODO: To be removed
+     */
     @Override
     public boolean createPolicy(String pid, MACAddress srcMac, MACAddress dstMac,
             Short etherType, IPv4Net srcIp, IPv4Net dstIp, Byte ipProto,
@@ -1152,12 +1159,10 @@
     }
 
     /**
-     * Set policy table for policy routing
+     * Create a policy
      *
-     * @param sw
-     * @param mplsLabel
-     * @return
      */
+    @Override
     public boolean createPolicy(String pid, MACAddress srcMac, MACAddress dstMac,
             Short etherType, IPv4Net srcIp, IPv4Net dstIp, Byte ipProto,
             Short srcTcpPort, Short dstTcpPort, int priority, String tid,
@@ -1315,11 +1320,22 @@
     // Utility functions
     // ************************************
 
+    /**
+     * Get the next MatchAction ID
+     *
+     * @return MatchAction ID
+     */
     public long getNextMatchActionID() {
         return this.matchActionId++;
     }
 
-
+    /**
+     * Get ports for the adjacency SID given
+     *
+     * @param nodeSid  Node SID of the adjacency SID
+     * @param adjacencySid Adjacency SID
+     * @return List of ports
+     */
     public List<Integer> getAdacencyPorts(int nodeSid, int adjacencySid) {
         HashMap<Integer, List<Integer>> adjacencySidInfo =
                 adjacencySidTable.get(Integer.valueOf(nodeSid));
@@ -1356,6 +1372,15 @@
         return adjecencyInfo.keySet();
     }
 
+    /**
+     * Send a Barrier request message and wait for the reply.
+     * It waits for the reply for 2 seconds and it cause exception when timer
+     * expires.
+     * TODO: When it does not receive the reply within timeout, recovery action
+     * is required.
+     *
+     * @param sw Switch to send the Barrier message
+     */
     private void sendBarrierAndCheckReply(Switch sw) {
         IOF13Switch sw13 = (IOF13Switch) floodlightProvider.getMasterSwitch(
                 getSwId(sw.getDpid().toString()));
@@ -1807,6 +1832,12 @@
         arpHandler.sendArpRequest(sw, destinationAddress, inPort);
     }
 
+    /**
+     * Get IOF13Switch object for the DPID
+     *
+     * @param dpid Switch DPID
+     * @return IOF13Switch object
+     */
     public IOF13Switch getIOF13Switch(String dpid) {
 
         IOF13Switch targetSw = (IOF13Switch) floodlightProvider.getMasterSwitch(
@@ -1815,6 +1846,12 @@
         return targetSw;
     }
 
+    /**
+     * Get Switch object for the DPID
+     *
+     * @param dpid Switch DPID
+     * @return Switch object
+     */
     public Switch getSwitch(String dpid) {
         return mutableTopology.getSwitch(new Dpid(dpid));
     }
@@ -1922,8 +1959,6 @@
 
     }
 
-
-
     /**
      * Debugging function to print out the Match Action Entry
      * @param sw13
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicy.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicy.java
index d795d61..9906d74 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicy.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicy.java
@@ -21,6 +21,15 @@
     protected int priority;
     protected PolicyType type;
 
+    /**
+     * Constructor
+     *
+     * @param srm Segment Routing Manager object
+     * @param pid Policy ID
+     * @param type Policy type
+     * @param match PacketMatch for the policy
+     * @param priority Priority
+     */
     public SegmentRoutingPolicy(SegmentRoutingManager srm, String pid,
             PolicyType type, PacketMatch match, int priority) {
         this.srManager = srm;
@@ -30,33 +39,56 @@
         this.type = type;
     }
 
-    public SegmentRoutingPolicy(String pid, PacketMatch match, int priority) {
-        this.policyId = pid;
-        this.match = match;
-        this.priority = priority;
-        this.type = PolicyType.TUNNEL_FLOW;
-    }
-
+    /**
+     * Get the policy ID
+     *
+     * @return policy ID
+     */
     public String getPolicyId(){
         return this.policyId;
     }
 
+    /**
+     * Get Match
+     *
+     * @return PacketMatch object
+     */
     public PacketMatch getMatch(){
         return this.match;
     }
 
+    /**
+     * Get the priority of the policy
+     *
+     * @return priority
+     */
     public int getPriority(){
         return this.priority;
     }
 
+    /**
+     * Get the policy type
+     *
+     * @return policy type
+     */
     public PolicyType getType(){
         return this.type;
     }
 
+    /**
+     * Create a policy
+     *
+     * @return true if succeeds, false otherwise
+     */
     public boolean createPolicy() {
         return false;
     }
 
+    /**
+     * Remove the policy
+     *
+     * @return true if succeeds, false otherwise
+     */
     public boolean removePolicy() {
         return false;
     }
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicyTunnel.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicyTunnel.java
index 91f3d29..5ea9b13 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicyTunnel.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingPolicyTunnel.java
@@ -32,7 +32,6 @@
             PolicyType type, PacketMatch match, int priority, String tid) {
         super(srm, pid, type, match, priority);
         this.tunnelId = tid;
-        // TODO Auto-generated constructor stub
     }
 
     @Override
@@ -128,7 +127,10 @@
         return true;
     }
 
-
+    /**
+     * Get the Tunnel ID
+     * @return tunnel ID
+     */
     public String getTunnelId(){
         return this.tunnelId;
     }
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingTunnel.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingTunnel.java
index 9eea762..e48ab0c 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingTunnel.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingTunnel.java
@@ -26,6 +26,13 @@
 
     private final int MAX_NUM_LABELS = 3;
 
+    /**
+     * Constructor
+     *
+     * @param srm SegmentRoutingManager object
+     * @param tid  Tunnel ID
+     * @param labelIds Label stack of the tunnel
+     */
     public SegmentRoutingTunnel(SegmentRoutingManager srm, String tid,
             List<Integer> labelIds) {
         this.srManager = srm;
@@ -34,18 +41,39 @@
         this.routes = new ArrayList<TunnelRouteInfo>();
     }
 
+    /**
+     * Get tunnel ID
+     *
+     * @return tunnel ID
+     */
     public String getTunnelId(){
         return this.tunnelId;
     }
 
+    /**
+     * Get Nodes IDs for the tunnel including source and destination router
+     *
+     * @return List of Node ID
+     */
     public List<Integer> getLabelids() {
         return this.labelIds;
     }
 
+    /**
+     * Get tunnel information after stitching if necessary
+     *
+     * @return List of TunnelRouteInfo object
+     */
     public List<TunnelRouteInfo> getRoutes(){
         return this.routes;
     }
 
+    /**
+     * Create a tunnel
+     * It requests the driver to create a group chaining for the tunnel.
+     *
+     * @return true if succeeds, false otherwise
+     */
     public boolean createTunnel() {
 
         if (labelIds.isEmpty() || labelIds.size() < 2) {
@@ -83,6 +111,12 @@
         return true;
     }
 
+    /**
+     * Remove the tunnel.
+     * It requests driver to remove all groups for the tunnel
+     *
+     * @return true if succeeds, false otherwise.
+     */
     public boolean removeTunnel() {
 
         for (TunnelRouteInfo route: routes) {
@@ -103,7 +137,6 @@
         return true;
     }
 
-
     /**
      * Create groups for the tunnel
      *
@@ -132,7 +165,6 @@
         return groupId;
     }
 
-
     /**
      * Split the nodes IDs into multiple tunnel if Segment Stitching is required.
      * We assume that the first node ID is the one of source router, and the last
@@ -280,7 +312,6 @@
         return rules;
     }
 
-
     /**
      * Get port numbers of the neighbor set.
      * If ECMP in transit router is not supported, then only one port should be returned
@@ -322,7 +353,6 @@
         return portList;
     }
 
-
     /**
      * Get the DPID of the router with node ID IF the node ID is the neighbor of the
      * Switch srcSW.
@@ -371,8 +401,6 @@
         return fwdSws;
     }
 
-
-
     /**
      * Check whether the router with preNodeid is connected to the router
      * with nodeId via adjacencySid or not
@@ -410,7 +438,6 @@
         return false;
     }
 
-
     /**
      * Get the destination Nodes of the adjacency Sid
      *
@@ -437,9 +464,6 @@
 
     }
 
-
-
-
     /**
      * print tunnel info - used only for debugging.
      * @param targetSw