Merge branch 'bgproute'
diff --git a/scripts/all-linkup-hw.sh b/scripts/all-linkup-hw.sh
new file mode 100755
index 0000000..41d6be8
--- /dev/null
+++ b/scripts/all-linkup-hw.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+# BRINGS BACK UP ALL THE LINKS FOR THE HARDWARE DEMO AS SHOWN IN ONS 2013
+# link-hw.sh %s %s %s % (src_dpid, port1, cmd)
+
+./link-hw.sh 00:00:00:00:ba:5e:ba:11 24 up
+./link-hw.sh 00:00:00:00:ba:5e:ba:11 23 up
+
+./link-hw.sh 00:00:00:00:ba:5e:ba:13 22 up
+./link-hw.sh 00:00:00:00:ba:5e:ba:13 23 up
+
+./link-hw.sh 00:00:00:00:00:00:ba:12 23 up
+./link-hw.sh 00:00:00:00:00:00:ba:12 22 up
+./link-hw.sh 00:00:00:00:00:00:ba:12 24 up
+
+./link-hw.sh 00:01:00:16:97:08:9a:46 23 up
+./link-hw.sh 00:01:00:16:97:08:9a:46 24 up
+
+./link-hw.sh 00:00:20:4e:7f:51:8a:35 21 up
+./link-hw.sh 00:00:20:4e:7f:51:8a:35 22 up
+./link-hw.sh 00:00:20:4e:7f:51:8a:35 24 up
+./link-hw.sh 00:00:20:4e:7f:51:8a:35 23 up
diff --git a/scripts/neclink.exp b/scripts/neclink.exp
index a09ed11..0815843 100755
--- a/scripts/neclink.exp
+++ b/scripts/neclink.exp
@@ -1,6 +1,6 @@
#!/usr/bin/expect -f
# ./neclink.exp <ip of port> <'no' or blank>
-set timeout -1
+set timeout 5
set port [lindex $argv 0]
set no [lindex $argv 1]
diff --git a/scripts/prontolink.exp b/scripts/prontolink.exp
index 7786701..501cccd 100755
--- a/scripts/prontolink.exp
+++ b/scripts/prontolink.exp
@@ -1,6 +1,6 @@
#!/usr/bin/expect -f
# ./prontolink.exp <ip of switch> <port> <0 or 1 (on or off)>
-set timeout -1
+set timeout 5
set arg0 [lindex $argv 0]
set port [lindex $argv 1]
set onoff [lindex $argv 2]
diff --git a/scripts/runiperf.sh b/scripts/runiperf.sh
index 7066bc6..4e26bd2 100755
--- a/scripts/runiperf.sh
+++ b/scripts/runiperf.sh
@@ -45,7 +45,7 @@
if (testbed == "SW"):
cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -u -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid)
else:
- cmd="~/mininet/util/m g%sh%02d '/home/ubuntu/ONOS/scripts/iperf -u -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_nwid, src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid + 1)
+ cmd="~/mininet/util/m g%sh%02d '/home/ubuntu/ONOS/scripts/iperf -u -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_nwid, src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid )
killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
print killcmd
print cmd
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index 251620c..57c136c 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -1,6 +1,8 @@
package net.floodlightcontroller.flowcache;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -11,6 +13,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -93,7 +96,6 @@
private long modifiedMeasurementFlowTime = 0;
//
private LinkedList<FlowPath> measurementStoredPaths = new LinkedList<FlowPath>();
- private LinkedList<FlowPath> measurementProcessingPaths = null;
private long measurementStartTimeProcessingPaths = 0;
private long measurementEndTimeProcessingPaths = 0;
@@ -537,8 +539,14 @@
} catch (Exception e) {
// TODO: handle exceptions
conn.endTx(Transaction.ROLLBACK);
- log.error(":addFlow FlowId:{} failed",
- flowPath.flowId().toString());
+
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String stacktrace = sw.toString();
+
+ log.error(":addFlow FlowId:{} failed: {}",
+ flowPath.flowId().toString(),
+ stacktrace);
}
if (flowObj == null) {
log.error(":addFlow FlowId:{} failed: Flow object not created",
@@ -757,13 +765,63 @@
*/
@Override
public boolean deleteAllFlows() {
+ List<Thread> threads = new LinkedList<Thread>();
+ final ConcurrentLinkedQueue<FlowId> concurrentAllFlowIds =
+ new ConcurrentLinkedQueue<FlowId>();
- // Get all flows and delete them one-by-one
- ArrayList<FlowPath> allFlows = getAllFlows();
- for (FlowPath flowPath : allFlows) {
- deleteFlow(flowPath.flowId());
+ // Get all Flow IDs
+ Iterable<IFlowPath> allFlowPaths = conn.utils().getAllFlowPaths(conn);
+ for (IFlowPath flowPathObj : allFlowPaths) {
+ if (flowPathObj == null)
+ continue;
+ String flowIdStr = flowPathObj.getFlowId();
+ if (flowIdStr == null)
+ continue;
+ FlowId flowId = new FlowId(flowIdStr);
+ concurrentAllFlowIds.add(flowId);
}
+ // Delete all flows one-by-one
+ for (FlowId flowId : concurrentAllFlowIds)
+ deleteFlow(flowId);
+
+ /*
+ * TODO: A faster mechanism to delete the Flow Paths by using
+ * a number of threads. Commented-out for now.
+ */
+ /*
+ //
+ // Create the threads to delete the Flow Paths
+ //
+ for (int i = 0; i < 10; i++) {
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ FlowId flowId = concurrentAllFlowIds.poll();
+ if (flowId == null)
+ return;
+ deleteFlow(flowId);
+ }
+ }}, "Delete All Flow Paths");
+ threads.add(thread);
+ }
+
+ // Start processing
+ for (Thread thread : threads) {
+ thread.start();
+ }
+
+ // Want for all threads to complete
+ for (Thread thread : threads) {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ log.debug("Exception waiting for a thread to delete a Flow Path: ", e);
+ }
+ }
+ */
+
return true;
}
@@ -836,11 +894,23 @@
*/
@Override
public boolean clearAllFlows() {
+ List<FlowId> allFlowIds = new LinkedList<FlowId>();
- // Get all flows and clear them one-by-one
- ArrayList<FlowPath> allFlows = getAllFlows();
- for (FlowPath flowPath : allFlows) {
- clearFlow(flowPath.flowId());
+ // Get all Flow IDs
+ Iterable<IFlowPath> allFlowPaths = conn.utils().getAllFlowPaths(conn);
+ for (IFlowPath flowPathObj : allFlowPaths) {
+ if (flowPathObj == null)
+ continue;
+ String flowIdStr = flowPathObj.getFlowId();
+ if (flowIdStr == null)
+ continue;
+ FlowId flowId = new FlowId(flowIdStr);
+ allFlowIds.add(flowId);
+ }
+
+ // Clear all flows one-by-one
+ for (FlowId flowId : allFlowIds) {
+ clearFlow(flowId);
}
return true;
@@ -1816,7 +1886,7 @@
* @return the stored shortest-path flow on success, otherwise null.
*/
@Override
- public FlowPath measurementStorePathFlow(FlowPath flowPath) {
+ public synchronized FlowPath measurementStorePathFlow(FlowPath flowPath) {
//
// Prepare the Shortest Path computation if the first Flow Path
//
@@ -1867,10 +1937,13 @@
computedFlowPath.setFlowEntryMatch(new FlowEntryMatch(flowPath.flowEntryMatch()));
//
- // Add the computed Flow Path the the internal storage
+ // Add the computed Flow Path to the internal storage
//
measurementStoredPaths.add(computedFlowPath);
+ log.debug("Measurement storing path {}",
+ computedFlowPath.flowId().toString());
+
return (computedFlowPath);
}
@@ -1885,8 +1958,12 @@
public boolean measurementInstallPaths(Integer numThreads) {
List<Thread> threads = new LinkedList<Thread>();
- // Create a copy of the paths to install
- measurementProcessingPaths = new LinkedList<FlowPath>(measurementStoredPaths);
+ // Create a copy of the Flow Paths to install
+ final ConcurrentLinkedQueue<FlowPath> measurementProcessingPaths =
+ new ConcurrentLinkedQueue<FlowPath>(measurementStoredPaths);
+
+ log.debug("Measurement Installing {} flows",
+ measurementProcessingPaths.size());
//
// Create the threads to install the Flow Paths
@@ -1896,7 +1973,7 @@
@Override
public void run() {
while (true) {
- FlowPath flowPath = measurementPollFirstFlowPath();
+ FlowPath flowPath = measurementProcessingPaths.poll();
if (flowPath == null)
return;
// Install the Flow Path
@@ -1918,17 +1995,18 @@
thread.start();
}
- //
- // Wait until the end of processing time
- //
- while (measurementEndTimeProcessingPaths == 0) {
+ // Want for all threads to complete
+ for (Thread thread : threads) {
try {
- Thread.sleep(100);
+ thread.join();
} catch (InterruptedException e) {
- // Continue waiting
+ log.debug("Exception waiting for a thread to install a Flow Path: ", e);
}
}
+ // Record the end of processing
+ measurementEndTimeProcessingPaths = System.nanoTime();
+
return true;
}
@@ -1945,24 +2023,6 @@
}
/**
- * Get a Flow Path that needs to be installed for measurement purpose.
- *
- * If there is no next Flow Path to install, the end time measurement
- * is recorded.
- *
- * @return the next Flow Path to install if exists, otherwise null.
- */
- private synchronized FlowPath measurementPollFirstFlowPath() {
- FlowPath flowPath = measurementProcessingPaths.pollFirst();
-
- // Record the end of processing, if the first call
- if ((flowPath == null) && (measurementEndTimeProcessingPaths == 0))
- measurementEndTimeProcessingPaths = System.nanoTime();
-
- return flowPath;
- }
-
- /**
* Clear the path flows stored for measurement purpose.
*
* @return true on success, otherwise false.
@@ -1976,5 +2036,4 @@
return true;
}
-
}