Skip to content
Snippets Groups Projects
Commit feb55e3f authored by Kanzhe Jiang's avatar Kanzhe Jiang
Browse files

BSC-3006: make the count an tomicInteger.

parent 423c5532
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
......@@ -64,7 +65,8 @@ public class FlowReconcileManager
/** a minimum flow reconcile rate so that it won't stave */
protected static int MIN_FLOW_RECONCILE_PER_SECOND = 200;
/** once per second */
/** start flow reconcile in 10ms after a new reconcile request is received.
* The max delay is 1 second. */
protected static int FLOW_RECONCILE_DELAY_MILLISEC = 10;
protected Date lastReconcileTime;
......@@ -72,7 +74,7 @@ public class FlowReconcileManager
protected static final String EnableConfigKey = "enable";
protected boolean flowReconcileEnabled;
volatile public int flowReconcileThreadRunCount;
public AtomicInteger flowReconcileThreadRunCount;
@Override
public synchronized void addFlowReconcileListener(
......@@ -215,7 +217,7 @@ public class FlowReconcileManager
flowReconcileEnabled = false;
}
flowReconcileThreadRunCount = 0;
flowReconcileThreadRunCount = new AtomicInteger(0);
lastReconcileTime = new Date(0);
logger.debug("FlowReconcile is {}", flowReconcileEnabled);
}
......@@ -313,7 +315,7 @@ public class FlowReconcileManager
}
// Flush the flowCache counters.
updateFlush();
flowReconcileThreadRunCount++;
flowReconcileThreadRunCount.incrementAndGet();
} else {
if (logger.isTraceEnabled()) {
logger.trace("No flow to be reconciled.");
......
......@@ -117,7 +117,7 @@ public class FlowReconcileMgrTest extends FloodlightTestCase {
flowReconcileMgr.addFlowReconcileListener(r3);
int pre_flowReconcileThreadRunCount =
flowReconcileMgr.flowReconcileThreadRunCount;
flowReconcileMgr.flowReconcileThreadRunCount.get();
Date startTime = new Date();
OFMatchReconcile ofmRcIn = new OFMatchReconcile();
try {
......@@ -147,11 +147,11 @@ public class FlowReconcileMgrTest extends FloodlightTestCase {
}).anyTimes();
pre_flowReconcileThreadRunCount =
flowReconcileMgr.flowReconcileThreadRunCount;
flowReconcileMgr.flowReconcileThreadRunCount.get();
startTime = new Date();
replay(r1, r2, r3);
flowReconcileMgr.reconcileFlow(ofmRcIn);
while (flowReconcileMgr.flowReconcileThreadRunCount <=
while (flowReconcileMgr.flowReconcileThreadRunCount.get() <=
pre_flowReconcileThreadRunCount) {
Thread.sleep(10);
Date currTime = new Date();
......@@ -174,12 +174,12 @@ public class FlowReconcileMgrTest extends FloodlightTestCase {
}).anyTimes();
pre_flowReconcileThreadRunCount =
flowReconcileMgr.flowReconcileThreadRunCount;
flowReconcileMgr.flowReconcileThreadRunCount.get();
startTime = new Date();
replay(r1, r2, r3);
flowReconcileMgr.reconcileFlow(ofmRcIn);
while (flowReconcileMgr.flowReconcileThreadRunCount <=
while (flowReconcileMgr.flowReconcileThreadRunCount.get() <=
pre_flowReconcileThreadRunCount) {
Thread.sleep(10);
Date currTime = new Date();
......@@ -197,12 +197,12 @@ public class FlowReconcileMgrTest extends FloodlightTestCase {
.andReturn(Command.STOP).times(1);
pre_flowReconcileThreadRunCount =
flowReconcileMgr.flowReconcileThreadRunCount;
flowReconcileMgr.flowReconcileThreadRunCount.get();
startTime = new Date();
replay(r1, r2, r3);
flowReconcileMgr.reconcileFlow(ofmRcIn);
while (flowReconcileMgr.flowReconcileThreadRunCount <=
while (flowReconcileMgr.flowReconcileThreadRunCount.get() <=
pre_flowReconcileThreadRunCount) {
Thread.sleep(10);
Date currTime = new Date();
......@@ -227,11 +227,11 @@ public class FlowReconcileMgrTest extends FloodlightTestCase {
.andReturn(Command.STOP).times(1);
pre_flowReconcileThreadRunCount =
flowReconcileMgr.flowReconcileThreadRunCount;
flowReconcileMgr.flowReconcileThreadRunCount.get();
startTime = new Date();
replay(r1, r2, r3);
flowReconcileMgr.reconcileFlow(ofmRcIn);
while (flowReconcileMgr.flowReconcileThreadRunCount <=
while (flowReconcileMgr.flowReconcileThreadRunCount.get() <=
pre_flowReconcileThreadRunCount) {
Thread.sleep(10);
Date currTime = new Date();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment