Cleanup a few of the CORD apps.

* Removed or turned per-packet logs down to trace in the PIM app
* Can now reconfigure remote sync host in CordMcast
* CordMcast catches REST exceptions rather than bombing

Change-Id: Iae027d5ce1d9047827ea80b071dc77ca49c65206
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMApplication.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMApplication.java
index 82adfad..ee65f5a 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMApplication.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMApplication.java
@@ -109,7 +109,6 @@
      * they arrived on, then forward them on to be processed by the appropriate entity.
      */
     public class PIMPacketProcessor implements PacketProcessor {
-        private final Logger log = getLogger(getClass());
 
         @Override
         public void process(PacketContext context) {
@@ -131,14 +130,13 @@
             Ethernet eth = pkt.parsed();
             if (eth == null) {
                 // problem getting the ethernet pkt.  Log it debug to avoid spamming log file
-                log.debug("Could not retrieve ethnernet packet from the parsed packet");
+                log.debug("Could not retrieve ethernet packet from the parsed packet");
                 return;
             }
 
             // Get the PIM Interface the packet was received on.
             PIMInterface pimi = pimInterfaceManager.getPIMInterface(pkt.receivedFrom());
             if (pimi == null) {
-                log.debug("We received PIM packet from a non PIM interface: " + pkt.receivedFrom().toString());
                 return;
             }
 
@@ -148,8 +146,7 @@
              * TODO: Is it possible that PIM interface processing should move to the
              * PIMInterfaceManager directly?
              */
-            PIMPacketHandler ph = new PIMPacketHandler();
-            ph.processPacket(eth, pimi);
+            pimPacketHandler.processPacket(eth, pimi);
         }
     }
 
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
index 1d09e35..0eed893 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.pim.impl;
 
+import com.google.common.collect.ImmutableList;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.IPv4;
 import org.onlab.packet.Ip4Address;
@@ -38,7 +39,6 @@
 
 import java.nio.ByteBuffer;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
@@ -87,7 +87,7 @@
     private IpAddress drIpaddress;
 
     // A map of all our PIM neighbors keyed on our neighbors IP address
-    private Map<IpAddress, PIMNeighbor> pimNeighbors = new HashMap<>();
+    private Map<IpAddress, PIMNeighbor> pimNeighbors = new ConcurrentHashMap<>();
 
     private Map<McastRoute, RouteData> routes = new ConcurrentHashMap<>();
 
@@ -224,7 +224,7 @@
      * @return PIM neighbors
      */
     public Collection<PIMNeighbor> getNeighbors() {
-        return pimNeighbors.values();
+        return ImmutableList.copyOf(pimNeighbors.values());
     }
 
     public Collection<McastRoute> getRoutes() {
@@ -297,6 +297,9 @@
      * @param ethPkt the Ethernet packet header
      */
     public void processHello(Ethernet ethPkt) {
+        if (log.isTraceEnabled()) {
+            log.trace("Received a PIM hello packet");
+        }
 
         // We'll need to save our neighbors MAC address
         MacAddress nbrmac = ethPkt.getSourceMAC();
@@ -476,39 +479,6 @@
         data.timestamp = System.currentTimeMillis();
     }
 
-    /*private void sendPrune(McastRoute route, RouteData data) {
-        PIMJoinPrune jp = new PIMJoinPrune();
-
-        jp.addJoinPrune(route.source().toIpPrefix(), route.group().toIpPrefix(), false);
-        jp.setHoldTime((short) 0);
-        jp.setUpstreamAddr(new PIMAddrUnicast(data.ipAddress.toString()));
-
-        PIM pim = new PIM();
-        pim.setPIMType(PIM.TYPE_JOIN_PRUNE_REQUEST);
-        pim.setPayload(jp);
-
-        IPv4 ipv4 = new IPv4();
-        ipv4.setDestinationAddress(PIM.PIM_ADDRESS.getIp4Address().toInt());
-        ipv4.setSourceAddress(getIpAddress().getIp4Address().toInt());
-        ipv4.setProtocol(IPv4.PROTOCOL_PIM);
-        ipv4.setTtl((byte) 1);
-        ipv4.setDiffServ((byte) 0xc0);
-        ipv4.setPayload(pim);
-
-        Ethernet eth = new Ethernet();
-        eth.setSourceMACAddress(onosInterface.mac());
-        eth.setDestinationMACAddress(MacAddress.valueOf("01:00:5E:00:00:0d"));
-        eth.setEtherType(Ethernet.TYPE_IPV4);
-        eth.setPayload(ipv4);
-
-        TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-                .setOutput(onosInterface.connectPoint().port())
-                .build();
-
-        packetService.emit(new DefaultOutboundPacket(onosInterface.connectPoint().deviceId(),
-                treatment, ByteBuffer.wrap(eth.serialize())));
-    }*/
-
     /**
      * Returns a builder for a PIM interface.
      *
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceManager.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceManager.java
index 342ef14..547a82e 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceManager.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceManager.java
@@ -177,17 +177,11 @@
         log.info("Stopped");
     }
 
-    /**
-     * Return the PIMInterface that corresponds to the given ConnectPoint.
-     *
-     * @param cp The ConnectPoint we want to get the PIMInterface for
-     * @return The PIMInterface if it exists, NULL if it does not exist.
-     */
     @Override
     public PIMInterface getPIMInterface(ConnectPoint cp) {
-        PIMInterface pi = pimInterfaces.getOrDefault(cp, null);
-        if (pi == null) {
-            log.warn("We have been asked for an Interface we don't have: " + cp.toString());
+        PIMInterface pi = pimInterfaces.get(cp);
+        if (pi == null && log.isTraceEnabled()) {
+            log.trace("We have been asked for an Interface we don't have: {}", cp);
         }
         return pi;
     }
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceService.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceService.java
index 53db001..b0ceba5 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceService.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaceService.java
@@ -29,12 +29,12 @@
 public interface PIMInterfaceService {
 
     /**
-     * Return the PIMInterface associated with the given ConnectPoint.
+     * Returns the PIM interface associated with the given connect point.
      *
-     * @param cp The ConnectPoint we want to get the PIMInterface for.
-     * @return the PIMInterface if it exists, NULL if it does not exist.
+     * @param cp the connect point we want to get the PIM interface for
+     * @return the PIM interface if it exists, otherwise null
      */
-    public PIMInterface getPIMInterface(ConnectPoint cp);
+    PIMInterface getPIMInterface(ConnectPoint cp);
 
     /**
      * Retrieves the set of all interfaces running PIM.
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java
index afc57fd..fa7e0ea 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java
@@ -50,20 +50,20 @@
 
         // Sanitize the ethernet header to ensure it is IPv4.  IPv6 we'll deal with later
         if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) {
-            log.debug("Recieved a non IPv4 packet");
             return;
         }
 
         // Get the IP header
         IPv4 ip = (IPv4) ethPkt.getPayload();
         if (ip.getProtocol() != IPv4.PROTOCOL_PIM) {
-            log.debug("Received a non PIM IP packet");
             return;
         }
 
         // Get the address of our the neighbor that sent this packet to us.
         IpAddress nbraddr = IpAddress.valueOf(ip.getDestinationAddress());
-        log.debug("Packet " + nbraddr.toString() + " received on port " + pimi.toString());
+        if (log.isTraceEnabled()) {
+            log.trace("Packet {} received on port {}", nbraddr, pimi);
+        }
 
         // Get the PIM header
         PIM pim = (PIM) ip.getPayload();
@@ -71,19 +71,15 @@
 
         // Process the pim packet
         switch (pim.getPimMsgType()) {
-
             case PIM.TYPE_HELLO:
                 pimi.processHello(ethPkt);
-                log.debug("Received a PIM hello packet");
                 break;
-
             case PIM.TYPE_JOIN_PRUNE_REQUEST:
                 pimi.processJoinPrune(ethPkt);
                 log.debug("Received a PIM Join/Prune message");
                 break;
-
             default:
-                log.debug("Recieved unsupported PIM type: " + pim.getPimMsgType());
+                log.debug("Received unsupported PIM type: {}", pim.getPimMsgType());
                 break;
         }
     }