Merge branch 'master' of https://github.com/pgreyson/ONOS into pgreyson-master
Conflicts:
web/topology_rest.py
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index f9177f2..e84a3e8 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -102,167 +102,9 @@
private static Logger log = LoggerFactory.getLogger(FlowManager.class);
// The periodic task(s)
- private final ScheduledExecutorService measureShortestPathScheduler =
- Executors.newScheduledThreadPool(1);
- private final ScheduledExecutorService measureMapReaderScheduler =
- Executors.newScheduledThreadPool(1);
private final ScheduledExecutorService mapReaderScheduler =
Executors.newScheduledThreadPool(1);
- private BlockingQueue<Runnable> shortestPathQueue = new LinkedBlockingQueue<Runnable>();
- private ThreadPoolExecutor shortestPathExecutor =
- new ThreadPoolExecutor(10, 10, 5, TimeUnit.SECONDS, shortestPathQueue);
-
- class ShortestPathTask implements Runnable {
- private int hint;
- private ITopoRouteService topoRouteService;
- private ArrayList<DataPath> dpList;
-
- public ShortestPathTask(int hint,
- ITopoRouteService topoRouteService,
- ArrayList<DataPath> dpList) {
- this.hint = hint;
- this.topoRouteService = topoRouteService;
- this.dpList = dpList;
- }
-
- @Override
- public void run() {
- /*
- String logMsg = "MEASUREMENT: Running Thread hint " + this.hint;
- log.debug(logMsg);
- long startTime = System.nanoTime();
- */
- for (DataPath dp : this.dpList) {
- topoRouteService.getTopoShortestPath(dp.srcPort(), dp.dstPort());
- }
- /*
- long estimatedTime = System.nanoTime() - startTime;
- double rate = (estimatedTime > 0)? ((double)dpList.size() * 1000000000) / estimatedTime: 0.0;
- logMsg = "MEASUREMENT: Computed Thread hint " + hint + ": " + dpList.size() + " shortest paths in " + (double)estimatedTime / 1000000000 + " sec: " + rate + " flows/s";
- log.debug(logMsg);
- */
- }
- }
-
- final Runnable measureShortestPath = new Runnable() {
- public void run() {
- log.debug("Recomputing Shortest Paths from the Network Map Flows...");
- if (floodlightProvider == null) {
- log.debug("FloodlightProvider service not found!");
- return;
- }
-
- if (topoRouteService == null) {
- log.debug("Topology Route Service not found");
- return;
- }
-
- int leftoverQueueSize = shortestPathExecutor.getQueue().size();
- if (leftoverQueueSize > 0) {
- String logMsg = "MEASUREMENT: Leftover Shortest Path Queue Size: " + leftoverQueueSize;
- log.debug(logMsg);
- return;
- }
- log.debug("MEASUREMENT: Beginning Shortest Path Computation");
-
- //
- // Recompute the Shortest Paths for all Flows
- //
- int counter = 0;
- int hint = 0;
- ArrayList<DataPath> dpList = new ArrayList<DataPath>();
- long startTime = System.nanoTime();
-
- topoRouteService.prepareShortestPathTopo();
-
- Iterable<IFlowPath> allFlowPaths = conn.utils().getAllFlowPaths(conn);
- for (IFlowPath flowPathObj : allFlowPaths) {
- FlowId flowId = new FlowId(flowPathObj.getFlowId());
-
- // log.debug("Found Path {}", flowId.toString());
- Dpid srcDpid = new Dpid(flowPathObj.getSrcSwitch());
- Port srcPort = new Port(flowPathObj.getSrcPort());
- Dpid dstDpid = new Dpid(flowPathObj.getDstSwitch());
- Port dstPort = new Port(flowPathObj.getDstPort());
- SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
- SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
-
- /*
- DataPath dp = new DataPath();
- dp.setSrcPort(srcSwitchPort);
- dp.setDstPort(dstSwitchPort);
- dpList.add(dp);
- if ((dpList.size() % 10) == 0) {
- shortestPathExecutor.execute(
- new ShortestPathTask(hint, topoRouteService,
- dpList));
- dpList = new ArrayList<DataPath>();
- hint++;
- }
- */
-
- DataPath dataPath =
- topoRouteService.getTopoShortestPath(srcSwitchPort,
- dstSwitchPort);
- counter++;
- }
- if (dpList.size() > 0) {
- shortestPathExecutor.execute(
- new ShortestPathTask(hint, topoRouteService,
- dpList));
- }
-
- /*
- // Wait for all tasks to finish
- try {
- while (shortestPathExecutor.getQueue().size() > 0) {
- Thread.sleep(100);
- }
- } catch (InterruptedException ex) {
- log.debug("MEASUREMENT: Shortest Path Computation interrupted");
- }
- */
-
- conn.endTx(Transaction.COMMIT);
- topoRouteService.dropShortestPathTopo();
-
- long estimatedTime = System.nanoTime() - startTime;
- double rate = (estimatedTime > 0)? ((double)counter * 1000000000) / estimatedTime: 0.0;
- String logMsg = "MEASUREMENT: Computed " + counter + " shortest paths in " + (double)estimatedTime / 1000000000 + " sec: " + rate + " flows/s";
- log.debug(logMsg);
- }
- };
-
- final Runnable measureMapReader = new Runnable() {
- public void run() {
- if (floodlightProvider == null) {
- log.debug("FloodlightProvider service not found!");
- return;
- }
-
- //
- // Fetch all Flow Entries
- //
- int counter = 0;
- long startTime = System.nanoTime();
- Iterable<IFlowEntry> allFlowEntries = conn.utils().getAllFlowEntries(conn);
- for (IFlowEntry flowEntryObj : allFlowEntries) {
- counter++;
- FlowEntryId flowEntryId =
- new FlowEntryId(flowEntryObj.getFlowEntryId());
- String userState = flowEntryObj.getUserState();
- String switchState = flowEntryObj.getSwitchState();
- }
- conn.endTx(Transaction.COMMIT);
-
- long estimatedTime = System.nanoTime() - startTime;
- double rate = (estimatedTime > 0)? ((double)counter * 1000000000) / estimatedTime: 0.0;
- String logMsg = "MEASUREMENT: Fetched " + counter + " flow entries in " + (double)estimatedTime / 1000000000 + " sec: " + rate + " entries/s";
- log.debug(logMsg);
- }
- };
-
final Runnable mapReader = new Runnable() {
public void run() {
long startTime = System.nanoTime();
@@ -305,14 +147,6 @@
FlowEntryId flowEntryId = new FlowEntryId(flowEntryIdStr);
Dpid dpid = new Dpid(dpidStr);
- /*
- log.debug("Found Flow Entry Id = {} {}",
- flowEntryId.toString(),
- "DPID = " + dpid.toString() +
- " User State: " + userState +
- " Switch State: " + switchState);
- */
-
if (! switchState.equals("FE_SWITCH_NOT_UPDATED"))
continue; // Ignore the entry: nothing to do
@@ -323,6 +157,9 @@
myFlowEntries.put(flowEntryId.value(), flowEntryObj);
}
+ log.debug("MEASUREMENT: Found {} My Flow Entries NOT_UPDATED",
+ myFlowEntries.size());
+
//
// Process my Flow Entries
//
@@ -337,11 +174,14 @@
continue; // Should NOT happen
// Code for measurement purpose
+ // TODO: Commented-out for now
+ /*
{
if (flowObj.getFlowId().equals(measurementFlowIdStr)) {
processed_measurement_flow = true;
}
}
+ */
//
// TODO: Eliminate the re-fetching of flowEntryId,
@@ -485,6 +325,9 @@
}
}
+ log.debug("MEASUREMENT: Found {} Flow Entries to delete",
+ deleteFlowEntries.size());
+
//
// Delete all entries marked for deletion
//
@@ -522,11 +365,6 @@
// Fetch and recompute the Shortest Path for those
// Flow Paths this controller is responsible for.
//
-
- /*
- * TODO: For now, the computation of the reconciliation is
- * commented-out.
- */
topoRouteService.prepareShortestPathTopo();
Iterable<IFlowPath> allFlowPaths = conn.utils().getAllFlowPaths(conn);
HashSet<IFlowPath> flowObjSet = new HashSet<IFlowPath>();
@@ -604,6 +442,8 @@
flowId.toString());
flowObjSet.add(flowPathObj);
}
+ log.debug("MEASUREMENT: Found {} Flows to reconcile",
+ flowObjSet.size());
reconcileFlows(flowObjSet);
topoRouteService.dropShortestPathTopo();
@@ -624,16 +464,6 @@
}
};
- /*
- final ScheduledFuture<?> measureShortestPathHandle =
- measureShortestPathScheduler.scheduleAtFixedRate(measureShortestPath, 10, 10, TimeUnit.SECONDS);
- */
-
- /*
- final ScheduledFuture<?> measureMapReaderHandle =
- measureMapReaderScheduler.scheduleAtFixedRate(measureMapReader, 10, 10, TimeUnit.SECONDS);
- */
-
final ScheduledFuture<?> mapReaderHandle =
mapReaderScheduler.scheduleAtFixedRate(mapReader, 3, 3, TimeUnit.SECONDS);
@@ -737,9 +567,12 @@
@Override
public boolean addFlow(FlowPath flowPath, FlowId flowId,
String dataPathSummaryStr) {
+ /*
+ * TODO: Commented-out for now
if (flowPath.flowId().value() == measurementFlowId) {
modifiedMeasurementFlowTime = System.nanoTime();
}
+ */
//
// Assign the FlowEntry IDs
@@ -954,9 +787,12 @@
*/
@Override
public boolean deleteFlow(FlowId flowId) {
+ /*
+ * TODO: Commented-out for now
if (flowId.value() == measurementFlowId) {
modifiedMeasurementFlowTime = System.nanoTime();
}
+ */
IFlowPath flowObj = null;
//
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index ec8051f..634f7eb 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -82,10 +82,7 @@
import net.floodlightcontroller.topology.NodePortTuple;
import net.floodlightcontroller.util.EventHistory;
import net.floodlightcontroller.util.EventHistory.EvAction;
-
import net.onrc.onos.registry.controller.IControllerRegistryService;
-import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
-import net.onrc.onos.registry.controller.RegistryException;
import org.openflow.protocol.OFMessage;
import org.openflow.protocol.OFPacketIn;
@@ -130,6 +127,12 @@
IStorageSourceListener, ILinkDiscoveryService,
IFloodlightModule, IInfoProvider, IHAListener {
protected static Logger log = LoggerFactory.getLogger(LinkDiscoveryManager.class);
+
+ protected enum NetworkMapOperation {
+ NONE,
+ INSERT,
+ UPDATE
+ }
// Names of table/fields for links in the storage API
private static final String LINK_TABLE_NAME = "controller_link";
@@ -1025,6 +1028,7 @@
NodePortTuple srcNpt, dstNpt;
boolean linkChanged = false;
+ NetworkMapOperation operation = NetworkMapOperation.NONE;
lock.writeLock().lock();
try {
@@ -1073,7 +1077,8 @@
writeLinkToStorage(lt, newInfo);
// Write link to network map
- linkStore.update(lt, newInfo, DM_OPERATION.INSERT);
+ operation = NetworkMapOperation.INSERT;
+ //linkStore.update(lt, newInfo, DM_OPERATION.INSERT);
updateOperation = UpdateOperation.LINK_UPDATED;
linkChanged = true;
@@ -1132,7 +1137,8 @@
writeLinkToStorage(lt, newInfo);
// Write link to network map
- linkStore.update(lt, newInfo, DM_OPERATION.UPDATE);
+ operation = NetworkMapOperation.UPDATE;
+ //linkStore.update(lt, newInfo, DM_OPERATION.UPDATE);
if (linkChanged) {
updateOperation = getUpdateOperation(newInfo.getSrcPortState(),
@@ -1162,6 +1168,18 @@
} finally {
lock.writeLock().unlock();
}
+
+ switch (operation){
+ case INSERT:
+ linkStore.update(lt, newInfo, DM_OPERATION.INSERT);
+ break;
+ case UPDATE:
+ linkStore.update(lt, newInfo, DM_OPERATION.UPDATE);
+ break;
+ case NONE:
+ default:
+ break;
+ }
return linkChanged;
}
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 4ed3ae5..84e12da 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -217,15 +217,15 @@
resp = Response(result, status=200, mimetype='application/json')
return resp
-@app.route("/wm/flow/getsummary/0/0/json")
-def flows():
+@app.route("/wm/flow/getsummary/<start>/<range>/json")
+def flows(start, range):
if request.args.get('proxy') == None:
host = ONOS_LOCAL_HOST
else:
host = ONOS_GUI3_HOST
try:
- command = "curl -s %s/wm/flow/getsummary/0/0/json" % (host)
+ command = "curl -s %s/wm/flow/getsummary/%s/%s/json" % (host, start, range)
# print command
result = os.popen(command).read()
except:
@@ -838,9 +838,11 @@
flow_nr += 1
command = "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", src_dpid, src_port, dst_dpid, dst_port, srcMAC, dstMAC)
+ command1 = "/home/ubuntu/ONOS/web/add_flow.py -m onos %d %s %s %s %s %s matchSrcMac %s matchDstMac %s" % (flow_nr, "dummy", dst_dpid, dst_port, src_dpid, src_port, dstMAC, srcMAC)
print command
errcode = os.popen(command).read()
- return errcode
+ errcode1 = os.popen(command1).read()
+ return errcode+" "+errcode1
#* Delete Flow
#http://localhost:9000/gui/delflow/<flow_id>
@@ -886,7 +888,7 @@
print cmd_string
os.popen(cmd_string)
- return
+ return cmd_string
#* Get Iperf Throughput
#http://localhost:9000/gui/iperf/rate/<flow_id>