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 0e143e3..e0ac857 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
@@ -311,7 +311,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);
@@ -520,10 +520,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);
}
@@ -545,7 +542,6 @@
getAndInitDevicePipeliner(event.subject().id());
} else {
log.debug("Device is no longer available {}", event.subject().id());
- getDevicePipeliner(event.subject().id()).cleanUp();
}
});
break;
@@ -563,10 +559,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/CpqdOfdpa2Pipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/CpqdOfdpa2Pipeline.java
index 7d9deb1..980d1f6 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/CpqdOfdpa2Pipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/ofdpa/CpqdOfdpa2Pipeline.java
@@ -195,30 +195,24 @@
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
- synchronized (this) {
- if (isReady()) {
- return;
+ if (supportPuntGroup()) {
+ // 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();
}
-
- if (supportPuntGroup()) {
- // 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",
- "cpqd-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);
+ // create a new executor at each init and a new empty queue
+ groupChecker = Executors.newSingleThreadScheduledExecutor(groupedThreads("onos/driver",
+ "cpqd-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);
}
}
/*
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 2a400ba..8600210 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
@@ -144,52 +144,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) {