[SDFAB-633][SDFAB-634][SDFAB-445] Collection of improvements for SR

Firstly, this patch deeply rewrites the load sharing of the SR instances,
before we were using an hybrid approach based on MastershipService.
With this patch we get rid of completely of the MastershipService
for any task. We just use the MastershipEvent as way to perform rerouting
if it happens near a cluster event. The aim is to make more stable the forwarding,
and the phased recovery.

Then, the patch contains a fix for an issue related to the phased recovery.
pr.init() can be called when there are still no masters (on device config
for example) and when this happens the portstate commands are dropped.

Last but not least, there is a fix for missing device routes in DefaultRoutingHandler.
Device routes (seenBeforeRoutes) are cleaned on DEVICE UP/ADDED events, this can lead
to purge some routes when the device events are handled in different moments by the
ONOS instances and there already some programmed routes.

Change-Id: Ia03b7c7c5b8a1b80c4b6d17053c2e2e7abf13d17
diff --git a/impl/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java b/impl/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
index 0002948..d82908c 100644
--- a/impl/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
+++ b/impl/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
@@ -29,13 +29,16 @@
 public class MockDefaultRoutingHandler extends DefaultRoutingHandler {
     private Map<ConnectPoint, Set<IpPrefix>> subnetTable;
     private Map<MockRoutingTableKey, MockRoutingTableValue> routingTable;
+    private Set<DeviceId> ledDevices;
 
     MockDefaultRoutingHandler(SegmentRoutingManager srManager,
                               Map<ConnectPoint, Set<IpPrefix>> subnetTable,
-                              Map<MockRoutingTableKey, MockRoutingTableValue> routingTable) {
+                              Map<MockRoutingTableKey, MockRoutingTableValue> routingTable,
+                              Set<DeviceId> ledDevices) {
         super(srManager);
         this.subnetTable = subnetTable;
         this.routingTable = routingTable;
+        this.ledDevices = ledDevices;
     }
 
     @Override
@@ -65,7 +68,7 @@
     }
 
     @Override
-    protected boolean shouldProgram(DeviceId deviceId) {
-        return true;
+    public boolean shouldProgram(DeviceId deviceId) {
+        return ledDevices.contains(deviceId);
     }
 }
\ No newline at end of file