Bgp and Pcep maintaiability

Change-Id: I2c14cc29d4900ef2f0fbffd4761b0d78e282910f
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
index 0294c9c..e80fd13 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
@@ -83,15 +83,15 @@
      * @throws BgpParseException while parsing link identifier
      */
     public static BgpLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BgpParseException {
-        //Parse local node descriptor
+        log.debug("Parse local node descriptor");
         NodeDescriptors localNodeDescriptors = new NodeDescriptors();
         localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId);
 
-        //Parse remote node descriptor
+        log.debug("Parse remote node descriptor");
         NodeDescriptors remoteNodeDescriptors = new NodeDescriptors();
         remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId);
 
-        //Parse link descriptor
+        log.debug("Parse link descriptor");
         LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
         linkDescriptor = parseLinkDescriptors(cb);
         return new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
@@ -108,7 +108,7 @@
      */
     public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
             throws BgpParseException {
-        log.debug("parse Node descriptors");
+        log.debug("Parse node descriptors");
         ChannelBuffer tempBuf = cb.copy();
         short type = cb.readShort();
         short length = cb.readShort();
@@ -166,8 +166,8 @@
                 break;
             case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
                 tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
-                count++;
-                //MultiTopologyId TLV cannot repeat more than once
+                count = count++;
+                log.debug("MultiTopologyId TLV cannot repeat more than once");
                 if (count > 1) {
                     //length + 4 implies data contains type, length and value
                     throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
index 2cecf0c..a1035e2 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
@@ -135,7 +135,7 @@
         byte protocolId = cb.readByte();
         long identifier = cb.readLong();
 
-        // Parse Local Node Descriptors
+        log.debug("Parse local node descriptors");
         BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
         localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
         return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
index fbfc781..eb795b4 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
@@ -51,6 +51,7 @@
     public BgpPrefixLSIdentifier() {
         this.localNodeDescriptors = null;
         this.prefixDescriptor = null;
+        log.debug("Parameters are reset");
     }
 
     /**
@@ -74,11 +75,11 @@
      */
     public static BgpPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
             throws BgpParseException {
-        //Parse Local Node descriptor
+        log.debug("Parse local node descriptor");
         NodeDescriptors localNodeDescriptors = new NodeDescriptors();
         localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
 
-        //Parse Prefix descriptor
+        log.debug("MultiTopologyId TLV cannot repeat more than once");
         List<BgpValueType> prefixDescriptor = new LinkedList<>();
         prefixDescriptor = parsePrefixDescriptors(cb);
         return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
index ac44c54..7cb13aa 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
@@ -124,13 +124,13 @@
         @Override
         public void write(ChannelBuffer cb, BgpKeepaliveMsgVer4 message) {
 
-            // write marker
+            log.debug("Write marker");
             cb.writeBytes(marker, 0, MARKER_LENGTH);
 
-            // write length of header
+            log.debug("Write length of header");
             cb.writeShort(PACKET_MINIMUM_LENGTH);
 
-            // write the type of message
+            log.debug("Write the type of message");
             cb.writeByte(MSG_TYPE.getType());
         }
     }
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
index b252de8..382f123 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
@@ -198,7 +198,7 @@
                 cb.writeBytes(message.data);
             }
 
-            //Update message length field in notification message
+            log.debug("Update message length field in notification message");
             int length = cb.writerIndex() - msgStartIndex;
             cb.setShort(headerLenIndex, (short) length);
             message.bgpHeader.setLength((short) length);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
index 5ab79fe..d8900ad 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
@@ -193,14 +193,19 @@
             // Read AS number
             asNumber = cb.getUnsignedShort(cb.readerIndex());
             cb.readShort();
+            log.debug("AS number read");
+
             // Read Hold timer
             holdTime = cb.readShort();
+            log.debug("Holding time read");
 
             // Read BGP Identifier
             bgpId = cb.readInt();
+            log.debug("BGP identifier read");
 
             // Read optional parameter length
             optParaLen = cb.readByte();
+            log.debug("OPtional parameter length read");
 
             // Read Capabilities if optional parameter length is greater than 0
             if (optParaLen != 0) {
@@ -263,7 +268,7 @@
                     throw new BgpParseException("Invalid length received for RpdCapability.");
                 }
                 if (length > cb.readableBytes()) {
-                    throw new BgpParseException("Four octet as num tlv length"
+                    throw new BgpParseException("Four octet as num TLV length"
                             + " is more than readableBytes.");
                 }
                 short rpdAfi = cb.readShort();
@@ -559,7 +564,7 @@
         while (listIterator.hasNext()) {
             BgpValueType tlv = listIterator.next();
             if (tlv == null) {
-                log.debug("Warning: tlv is null from CapabilityTlv list");
+                log.debug("Warning: TLV is null from CapabilityTlv list");
                 continue;
             }
             tlv.write(cb);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
index 9f8ec82..6847dd6 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
@@ -154,7 +154,7 @@
                 pathAttribute = WideCommunity.read(cb);
                 break;
             default:
-                //skip bytes for unsupported attribute types
+                log.debug("Skip bytes for unsupported attribute types");
                 UnSupportedAttribute.read(cb);
             }
             pathAttributeList.add(pathAttribute);
@@ -263,19 +263,19 @@
         }
 
         if (!isOrigin) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     Origin.ORIGIN_TYPE);
         }
         if (!isAsPath) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     AsPath.ASPATH_TYPE);
         }
         if (!isMpUnReach && !isMpReach && !isNextHop) {
-            log.debug("Mandatory Attributes not Present");
+            log.debug("Mandatory attributes not Present");
             Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                     BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                     NextHop.NEXTHOP_TYPE);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
index 7062a7d..b6576a3 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
@@ -130,7 +130,7 @@
             LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
             LinkedList<IpPrefix> nlri = new LinkedList<>();
             BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
-            // Reading Withdrawn Routes Length
+
             Short withDrwLen = cb.readShort();
 
             if (cb.readableBytes() < withDrwLen) {
@@ -138,13 +138,15 @@
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                         cb.readableBytes());
             }
+            log.debug("Reading withdrawn routes length");
             ChannelBuffer tempCb = cb.readBytes(withDrwLen);
             if (withDrwLen != 0) {
                 // Parsing WithdrawnRoutes
                 withDrwRoutes = parseWithdrawnRoutes(tempCb);
+                log.debug("Withdrawn routes parsed");
             }
             if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
-                log.debug("Bgp Path Attribute len field not present");
+                log.debug("Bgp path attribute len field not present");
                 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
             }
@@ -156,6 +158,7 @@
                 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                         BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
             }
+            log.debug("Total path attribute length read");
             if (totPathAttrLen != 0) {
                 // Parsing BGPPathAttributes
                 if (cb.readableBytes() < totPathAttrLen) {