Removes workaround for duplicate device_added events

Change-Id: I2144b3a6f1c226664f8c30bbb79963a570c9b4b6
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java b/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
index 22e89d8..6f497e7 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/Pipeliner.java
@@ -81,20 +81,4 @@
      */
     List<String> getNextMappings(NextGroup nextGroup);
 
-    /**
-     * Returns pipeliner status.
-     *
-     * @return true if pipeliner is ready to accept objectives. False otherwise.
-     */
-    default boolean isReady() {
-        return true;
-    }
-
-    /**
-     * Clean up internal state of the pipeliner.
-     * Implementation is pipeliner specific.
-     */
-    default void cleanUp() {
-    }
-
 }
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 4ba0d6e..9e334ad 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
@@ -306,7 +306,7 @@
             try {
                 Pipeliner pipeliner = getDevicePipeliner(deviceId);
 
-                if (pipeliner != null && pipeliner.isReady()) {
+                if (pipeliner != null) {
                     if (objective instanceof NextObjective) {
                         nextToDevice.put(objective.id(), deviceId);
                         pipeliner.next((NextObjective) objective);
@@ -515,10 +515,7 @@
     private void invalidatePipeliner(DeviceId id) {
         log.info("Invalidating cached pipeline behaviour for {}", id);
         driverHandlers.remove(id);
-        Pipeliner pipeliner = pipeliners.remove(id);
-        if (pipeliner != null) {
-            pipeliner.cleanUp();
-        }
+        pipeliners.remove(id);
         if (deviceService.isAvailable(id)) {
             getAndInitDevicePipeliner(id);
         }
@@ -540,7 +537,6 @@
                         getAndInitDevicePipeliner(event.subject().id());
                       } else {
                         log.debug("Device is no longer available {}", event.subject().id());
-                        getDevicePipeliner(event.subject().id()).cleanUp();
                       }
                     });
                     break;
@@ -558,10 +554,7 @@
                     // replace driver/pipeliner assigned to the device.
                     devEventExecutor.execute(() -> {
                         driverHandlers.remove(event.subject().id());
-                        Pipeliner pipeliner = pipeliners.remove(event.subject().id());
-                        if (pipeliner != null) {
-                            pipeliner.cleanUp();
-                        }
+                        pipeliners.remove(event.subject().id());
                     });
                     break;
                 case DEVICE_SUSPENDED:
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
index a891e40..70aafd4 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/Ofdpa2Pipeline.java
@@ -151,52 +151,27 @@
     private ScheduledExecutorService accumulatorExecutorService
         = newSingleThreadScheduledExecutor(groupedThreads("OfdpaPipeliner", "acc-%d", log));
 
-    protected AtomicBoolean ready = new AtomicBoolean(false);
-
     @Override
     public void init(DeviceId deviceId, PipelinerContext context) {
-        synchronized (this) {
-            if (isReady()) {
-                return;
-            }
+        this.deviceId = deviceId;
 
-            this.deviceId = deviceId;
-
-            serviceDirectory = context.directory();
-            coreService = serviceDirectory.get(CoreService.class);
-            flowRuleService = serviceDirectory.get(FlowRuleService.class);
-            groupService = serviceDirectory.get(GroupService.class);
-            flowObjectiveStore = context.store();
-            deviceService = serviceDirectory.get(DeviceService.class);
-            // Init the accumulator, if enabled
-            if (isAccumulatorEnabled(this)) {
-                accumulator = new ForwardingObjectiveAccumulator(context.accumulatorMaxObjectives(),
-                        context.accumulatorMaxBatchMillis(),
-                        context.accumulatorMaxIdleMillis());
-            }
-
-            initDriverId();
-            initGroupHander(context);
-
-            initializePipeline();
-            ready.set(true);
+        serviceDirectory = context.directory();
+        coreService = serviceDirectory.get(CoreService.class);
+        flowRuleService = serviceDirectory.get(FlowRuleService.class);
+        groupService = serviceDirectory.get(GroupService.class);
+        flowObjectiveStore = context.store();
+        deviceService = serviceDirectory.get(DeviceService.class);
+        // Init the accumulator, if enabled
+        if (isAccumulatorEnabled(this)) {
+            accumulator = new ForwardingObjectiveAccumulator(context.accumulatorMaxObjectives(),
+                    context.accumulatorMaxBatchMillis(),
+                    context.accumulatorMaxIdleMillis());
         }
-    }
 
-    @Override
-    public boolean isReady() {
-        return ready.get();
-    }
+        initDriverId();
+        initGroupHander(context);
 
-    @Override
-    public void cleanUp() {
-        synchronized (this) {
-            if (!isReady()) {
-                return;
-            }
-            ready.set(false);
-        }
-        log.info("Cleaning up...");
+        initializePipeline();
     }
 
     void setupAccumulatorForTests(int maxFwd, int maxBatchMS, int maxIdleMS) {
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
index 8ca774a..7e43cab 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/OvsOfdpaPipeline.java
@@ -165,29 +165,23 @@
 
     @Override
     public void init(DeviceId deviceId, PipelinerContext context) {
-        synchronized (this) {
-            if (isReady()) {
-                return;
-            }
-
-            // Terminate internal references
-            // We are terminating the references here
-            // because when the device is offline the apps
-            // are still sending flowobjectives
-            if (groupChecker != null) {
-                groupChecker.shutdown();
-            }
-            // create a new executor at each init and a new empty queue
-            groupChecker = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/driver",
-                    "ovs-ofdpa-%d", log));
-            if (flowRuleQueue != null) {
-                flowRuleQueue.clear();
-            }
-            flowRuleQueue = new ConcurrentLinkedQueue<>();
-            groupCheckerLock = new ReentrantLock();
-            groupChecker.scheduleAtFixedRate(new PopVlanPuntGroupChecker(), 20, 50, TimeUnit.MILLISECONDS);
-            super.init(deviceId, context);
+        // Terminate internal references
+        // We are terminating the references here
+        // because when the device is offline the apps
+        // are still sending flowobjectives
+        if (groupChecker != null) {
+            groupChecker.shutdown();
         }
+        // create a new executor at each init and a new empty queue
+        groupChecker = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/driver",
+                "ovs-ofdpa-%d", log));
+        if (flowRuleQueue != null) {
+            flowRuleQueue.clear();
+        }
+        flowRuleQueue = new ConcurrentLinkedQueue<>();
+        groupCheckerLock = new ReentrantLock();
+        groupChecker.scheduleAtFixedRate(new PopVlanPuntGroupChecker(), 20, 50, TimeUnit.MILLISECONDS);
+        super.init(deviceId, context);
     }
 
     protected void processFilter(FilteringObjective filteringObjective,