Fixes bug where driver gets initialized only when device is available.
More explict handling of versatile forwarding flows in corsa driver.
Moving TunnelConnectivityManager to use flowObjectives instead of flowRules.

Change-Id: If43023f30a6e7a028dfdefbe1ffbcc710a1c7be3
diff --git a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
index 79d486e..7acce65 100644
--- a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/FlowObjectiveManager.java
@@ -67,7 +67,7 @@
 @Service
 public class FlowObjectiveManager implements FlowObjectiveService {
 
-    public static final int INSTALL_RETRY_ATTEMPTS = 5;
+    public static final int INSTALL_RETRY_ATTEMPTS = 10;
     public static final long INSTALL_RETRY_INTERVAL = 1000; // ms
 
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -167,7 +167,7 @@
                         pipeliner.filter((FilteringObjective) objective);
                     }
                 } else if (numAttempts < INSTALL_RETRY_ATTEMPTS) {
-                    Thread.currentThread().sleep(INSTALL_RETRY_INTERVAL);
+                    Thread.sleep(INSTALL_RETRY_INTERVAL);
                     executorService.submit(this);
                 } else {
                     // Otherwise we've tried a few times and failed, report an
@@ -262,7 +262,9 @@
             switch (event.type()) {
                 case MASTER_CHANGED:
                     log.info("mastership changed on device {}", event.subject());
-                    setupPipelineHandler(event.subject());
+                    if (deviceService.isAvailable(event.subject())) {
+                        setupPipelineHandler(event.subject());
+                    }
                     break;
                 case BACKUPS_CHANGED:
                     break;
@@ -278,8 +280,6 @@
         public void event(DeviceEvent event) {
             switch (event.type()) {
                 case DEVICE_ADDED:
-                    setupPipelineHandler(event.subject().id());
-                    break;
                 case DEVICE_AVAILABILITY_CHANGED:
                     log.info("Device either added or availability changed {}",
                              event.subject().id());