Merge branch 'ONOS-ONRC2014-Measurements' of https://github.com/OPENNETWORKINGLAB/ONOS into topodev
Conflicts:
src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
index 6483121..d6c870d 100644
--- a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
@@ -73,6 +73,12 @@
private MapFlowEntryListener mapFlowEntryListener = null;
private String mapFlowEntryListenerId = null;
+ // State related to the Flow ID map
+ protected static final String mapFlowIdName = "mapFlowId";
+ private IMap<Long, byte[]> mapFlowId = null;
+ private MapFlowIdListener mapFlowIdListener = null;
+ private String mapFlowIdListenerId = null;
+
// State related to the Network Topology map
protected static final String mapTopologyName = "mapTopology";
private IMap<String, byte[]> mapTopology = null;
@@ -230,6 +236,78 @@
}
/**
+ * Class for receiving notifications for FlowId state.
+ *
+ * The datagrid map is:
+ * - Key : FlowId (Long)
+ * - Value : Serialized FlowId (byte[])
+ */
+ class MapFlowIdListener implements EntryListener<Long, byte[]> {
+ /**
+ * Receive a notification that an entry is added.
+ *
+ * @param event the notification event for the entry.
+ */
+ public void entryAdded(EntryEvent<Long, byte[]> event) {
+ byte[] valueBytes = (byte[])event.getValue();
+
+ //
+ // Decode the value and deliver the notification
+ //
+ Kryo kryo = kryoFactory.newKryo();
+ Input input = new Input(valueBytes);
+ FlowId flowId = kryo.readObject(input, FlowId.class);
+ kryoFactory.deleteKryo(kryo);
+ flowEventHandlerService.notificationRecvFlowIdAdded(flowId);
+ }
+
+ /**
+ * Receive a notification that an entry is removed.
+ *
+ * @param event the notification event for the entry.
+ */
+ public void entryRemoved(EntryEvent<Long, byte[]> event) {
+ byte[] valueBytes = (byte[])event.getValue();
+
+ //
+ // Decode the value and deliver the notification
+ //
+ Kryo kryo = kryoFactory.newKryo();
+ Input input = new Input(valueBytes);
+ FlowId flowId = kryo.readObject(input, FlowId.class);
+ kryoFactory.deleteKryo(kryo);
+ flowEventHandlerService.notificationRecvFlowIdRemoved(flowId);
+ }
+
+ /**
+ * Receive a notification that an entry is updated.
+ *
+ * @param event the notification event for the entry.
+ */
+ public void entryUpdated(EntryEvent<Long, byte[]> event) {
+ byte[] valueBytes = (byte[])event.getValue();
+
+ //
+ // Decode the value and deliver the notification
+ //
+ Kryo kryo = kryoFactory.newKryo();
+ Input input = new Input(valueBytes);
+ FlowId flowId = kryo.readObject(input, FlowId.class);
+ kryoFactory.deleteKryo(kryo);
+ flowEventHandlerService.notificationRecvFlowIdUpdated(flowId);
+ }
+
+ /**
+ * Receive a notification that an entry is evicted.
+ *
+ * @param event the notification event for the entry.
+ */
+ public void entryEvicted(EntryEvent<Long, byte[]> event) {
+ // NOTE: We don't use eviction for this map
+ }
+ }
+
+ /**
* Class for receiving notifications for Network Topology state.
*
* The datagrid map is:
@@ -504,6 +582,11 @@
mapFlowEntry = hazelcastInstance.getMap(mapFlowEntryName);
mapFlowEntryListenerId = mapFlowEntry.addEntryListener(mapFlowEntryListener, true);
+ // Initialize the FlowId-related map state
+ mapFlowIdListener = new MapFlowIdListener();
+ mapFlowId = hazelcastInstance.getMap(mapFlowIdName);
+ mapFlowIdListenerId = mapFlowId.addEntryListener(mapFlowIdListener, true);
+
// Initialize the Topology-related map state
mapTopologyListener = new MapTopologyListener();
mapTopology = hazelcastInstance.getMap(mapTopologyName);
@@ -531,6 +614,11 @@
mapFlowEntry = null;
mapFlowEntryListener = null;
+ // Clear the FlowId-related map state
+ mapFlowId.removeEntryListener(mapFlowIdListenerId);
+ mapFlowId = null;
+ mapFlowIdListener = null;
+
// Clear the Topology-related map state
mapTopology.removeEntryListener(mapTopologyListenerId);
mapTopology = null;
@@ -788,6 +876,101 @@
}
/**
+ * Get all Flow IDs that are currently in the datagrid.
+ *
+ * @return all Flow IDs that are currently in the datagrid.
+ */
+ @Override
+ public Collection<FlowId> getAllFlowIds() {
+ Collection<FlowId> allFlowIds = new LinkedList<FlowId>();
+
+ //
+ // Get all current entries
+ //
+ Collection<byte[]> values = mapFlowId.values();
+ Kryo kryo = kryoFactory.newKryo();
+ for (byte[] valueBytes : values) {
+ //
+ // Decode the value
+ //
+ Input input = new Input(valueBytes);
+ FlowId flowId = kryo.readObject(input, FlowId.class);
+ allFlowIds.add(flowId);
+ }
+ kryoFactory.deleteKryo(kryo);
+
+ return allFlowIds;
+ }
+
+ /**
+ * Send a notification that a FlowId is added.
+ *
+ * @param flowId the FlowId that is added.
+ */
+ @Override
+ public void notificationSendFlowIdAdded(FlowId flowId) {
+ //
+ // Encode the value
+ //
+ byte[] buffer = new byte[MAX_BUFFER_SIZE];
+ Kryo kryo = kryoFactory.newKryo();
+ Output output = new Output(buffer, -1);
+ kryo.writeObject(output, flowId);
+ byte[] valueBytes = output.toBytes();
+ kryoFactory.deleteKryo(kryo);
+
+ //
+ // Put the entry:
+ // - Key : FlowId (Long)
+ // - Value : Serialized FlowId (byte[])
+ //
+ mapFlowId.putAsync(flowId.value(), valueBytes);
+ }
+
+ /**
+ * Send a notification that a FlowId is removed.
+ *
+ * @param flowId the FlowId that is removed.
+ */
+ @Override
+ public void notificationSendFlowIdRemoved(FlowId flowId) {
+ //
+ // Remove the entry:
+ // - Key : FlowId (Long)
+ // - Value : Serialized FlowId (byte[])
+ //
+ mapFlowId.removeAsync(flowId.value());
+ }
+
+ /**
+ * Send a notification that a FlowId is updated.
+ *
+ * @param flowId the FlowId that is updated.
+ */
+ @Override
+ public void notificationSendFlowIdUpdated(FlowId flowId) {
+ // NOTE: Adding an entry with an existing key automatically updates it
+ notificationSendFlowIdAdded(flowId);
+ }
+
+ /**
+ * Send a notification that all Flow IDs are removed.
+ */
+ @Override
+ public void notificationSendAllFlowIdsRemoved() {
+ //
+ // Remove all entries
+ // NOTE: We remove the entries one-by-one so the per-entry
+ // notifications will be delivered.
+ //
+ // mapFlowId.clear();
+ Set<Long> keySet = mapFlowId.keySet();
+ for (Long key : keySet) {
+ mapFlowId.removeAsync(key);
+ }
+ }
+
+ /**
* Get all Topology Elements that are currently in the datagrid.
*
* @return all Topology Elements that are currently in the datagrid.
diff --git a/src/main/java/net/onrc/onos/datagrid/IDatagridService.java b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
index 0f03d77..d4e7b00 100644
--- a/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
+++ b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
@@ -134,6 +134,39 @@
void notificationSendAllFlowEntriesRemoved();
/**
+ * Get all Flow IDs that are currently in the datagrid.
+ *
+ * @return all Flow IDs that are currently in the datagrid.
+ */
+ Collection<FlowId> getAllFlowIds();
+
+ /**
+ * Send a notification that a FlowId is added.
+ *
+ * @param flowId the FlowId that is added.
+ */
+ void notificationSendFlowIdAdded(FlowId flowId);
+
+ /**
+ * Send a notification that a FlowId is removed.
+ *
+ * @param flowId the FlowId that is removed.
+ */
+ void notificationSendFlowIdRemoved(FlowId flowId);
+
+ /**
+ * Send a notification that a FlowId is updated.
+ *
+ * @param flowId the FlowId that is updated.
+ */
+ void notificationSendFlowIdUpdated(FlowId flowId);
+
+ /**
+ * Send a notification that all Flow IDs are removed.
+ */
+ void notificationSendAllFlowIdsRemoved();
+
+ /**
* Get all Topology Elements that are currently in the datagrid.
*
* @return all Topology Elements that are currently in the datagrid.
diff --git a/src/main/java/net/onrc/onos/datagrid/web/GetMapResource.java b/src/main/java/net/onrc/onos/datagrid/web/GetMapResource.java
index 8c8e1cd..6a56b2f 100644
--- a/src/main/java/net/onrc/onos/datagrid/web/GetMapResource.java
+++ b/src/main/java/net/onrc/onos/datagrid/web/GetMapResource.java
@@ -47,7 +47,7 @@
// Extract the arguments
String mapNameStr = (String)getRequestAttributes().get("map-name");
- log.debug("Get Datagrid Map: " + mapNameStr);
+ log.debug("Get Datagrid Map: {}", mapNameStr);
//
// Get the Flows
diff --git a/src/main/java/net/onrc/onos/graph/GraphDBConnection.java b/src/main/java/net/onrc/onos/graph/GraphDBConnection.java
index 7938bb6..16869c5 100644
--- a/src/main/java/net/onrc/onos/graph/GraphDBConnection.java
+++ b/src/main/java/net/onrc/onos/graph/GraphDBConnection.java
@@ -167,7 +167,7 @@
try {
commit();
} catch (Exception e) {
- log.error("{}", e.toString());
+ log.error("close() failed with exception", e);
}
}
}
diff --git a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
index 40f5044..932d422 100644
--- a/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
+++ b/src/main/java/net/onrc/onos/graph/LocalTopologyEventListener.java
@@ -38,7 +38,7 @@
// TODO Auto-generated method stub
// Fire NetMapEvents (LinkRemoved, FlowEntryRemoved, HostRemoved, PortRemoved)
TitanEdge edge = (TitanEdge) e;
- log.debug("TopologyEvents: Received edge removed event: {}",edge.toString());
+ log.debug("TopologyEvents: Received edge removed event: {}",edge);
String label = edge.getLabel();
if (label.equals("link")) {
Vertex v = edge.getVertex(Direction.IN);
@@ -76,7 +76,7 @@
// TODO Auto-generated method stub
// Generate NetMapEvents
String type = (String) vertex.getProperty("type");
- log.debug("TopologyEvents: Received vertex removed event: {}",vertex.toString());
+ log.debug("TopologyEvents: Received vertex removed event: {}",vertex);
if (type.equals("port")) {
// port is removed...lets fire reconcile here directly for now
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
index b084be6..ee08177 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/DeviceStorageImpl.java
@@ -231,8 +231,8 @@
port.setDevice(obj);
}
- log.debug("port number is {}", port.getNumber().toString());
- log.debug("port desc is {}", port.getDesc());
+ log.debug("port number is {}", port.getNumber());
+ log.debug("port desc is {}", port.getDesc());
}
}
@@ -333,8 +333,10 @@
onosDevice.getSwitchDPID()), onosDevice.getSwitchPort());
if ((portObject1 != null) && portObject1.getLinkedPorts().iterator().hasNext()) {
- log.debug("stop adding OnosDevice: {} due to there is a link to: {}",
- onosDevice, portObject1.getLinkedPorts().iterator().next().getPortId());
+ if (log.isDebugEnabled()) {
+ log.debug("stop adding OnosDevice: {} due to there is a link to: {}",
+ onosDevice, portObject1.getLinkedPorts().iterator().next().getPortId());
+ }
return;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
index a9088de..5818462 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/LinkStorageImpl.java
@@ -477,7 +477,7 @@
vportSrc.setLinkPort(vportDst);
success = true;
} else {
- log.debug("LinkStorageImpl:addLinkImpl failed link exists {} {} src {} dst {}",
+ log.debug("LinkStorageImpl:addLinkImpl failed link exists {} {} src {} dst {}",
new Object[]{op, lt, vportSrc, vportDst});
}
}
@@ -500,13 +500,13 @@
vportDst = op.searchPort(dpid, port);
// FIXME: This needs to remove all edges
- if (vportSrc != null && vportDst != null) {
- vportSrc.removeLink(vportDst);
- log.debug("deleteLinkImpl(): deleted edges src {} dst {}", new Object[]{
- lt, vportSrc, vportDst});
- success = true;
- }
-
- return success;
+ if (vportSrc != null && vportDst != null) {
+ vportSrc.removeLink(vportDst);
+ log.debug("deleteLinkImpl(): deleted edge {} src {} dst {}", new Object[]{
+ lt, vportSrc, vportDst});
+ success = true;
+ }
+
+ return success;
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
index a92ab72..be015d3 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/internal/SwitchStorageImpl.java
@@ -169,7 +169,7 @@
success = true;
} catch (Exception e) {
op.rollback();
- log.error("SwitchStorage:addSwitch dpid:{} failed", dpid, e);
+ log.error("SwitchStorage:addSwitch dpid:"+dpid+" failed", e);
}
return success;
@@ -202,7 +202,7 @@
} catch (Exception e) {
op.rollback();
e.printStackTrace();
- log.error("SwitchStorage:addSwitch dpid:{} failed", dpid, e);
+ log.error("SwitchStorage:addSwitch dpid:"+dpid+" failed", e);
}
return success;
@@ -253,7 +253,7 @@
} catch (Exception e) {
// TODO what type of exception is thrown when we can't commit?
op.rollback();
- log.error("SwitchStorage:deactivateSwitch {} failed", dpid, e);
+ log.error("SwitchStorage:deactivateSwitch "+dpid+" failed", e);
}
return success;
@@ -407,7 +407,7 @@
if (sw != null && state != null) {
sw.setState(state.toString());
log.info("SwitchStorage:setSwitchStateImpl dpid:{} updated {}",
- sw.getDPID(), state.toString());
+ sw.getDPID(), state);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index 9969cfc..e075bad 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -49,13 +49,13 @@
String stacktrace = sw.toString();
log.error(":addFlow FlowId:{} failed: {}",
- flowPath.flowId().toString(),
+ flowPath.flowId(),
stacktrace);
return false;
}
if (flowObj == null) {
log.error(":addFlow FlowId:{} failed: Flow object not created",
- flowPath.flowId().toString());
+ flowPath.flowId());
dbHandler.rollback();
return false;
}
@@ -205,12 +205,12 @@
}
} catch (Exception e) {
log.error(":addFlow FlowEntryId:{} failed",
- flowEntry.flowEntryId().toString());
+ flowEntry.flowEntryId());
return null;
}
if (flowEntryObj == null) {
log.error(":addFlow FlowEntryId:{} failed: FlowEntry object not created",
- flowEntry.flowEntryId().toString());
+ flowEntry.flowEntryId());
return null;
}
@@ -344,7 +344,7 @@
flowEntryObj = dbHandler.searchFlowEntry(flowEntry.flowEntryId());
} catch (Exception e) {
log.error(":deleteFlowEntry FlowEntryId:{} failed",
- flowEntry.flowEntryId().toString());
+ flowEntry.flowEntryId());
return false;
}
//
@@ -354,7 +354,7 @@
/*
if (flowEntryObj == null) {
log.error(":deleteFlowEntry FlowEntryId:{} failed: FlowEntry object not found",
- flowEntry.flowEntryId().toString());
+ flowEntry.flowEntryId());
return false;
}
*/
@@ -409,7 +409,7 @@
} catch (Exception e) {
// TODO: handle exceptions
dbHandler.rollback();
- log.error(":deleteFlow FlowId:{} failed", flowId.toString());
+ log.error(":deleteFlow FlowId:{} failed", flowId);
return false;
}
if (flowObj == null) {
@@ -446,7 +446,7 @@
} catch (Exception e) {
// TODO: handle exceptions
dbHandler.rollback();
- log.error(":getFlow FlowId:{} failed", flowId.toString());
+ log.error(":getFlow FlowId:{} failed", flowId);
return null;
}
if (flowObj == null) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
index 98db9b9..4c801d6 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
@@ -68,6 +68,8 @@
new LinkedList<EventEntry<FlowPath>>();
private List<EventEntry<FlowEntry>> flowEntryEvents =
new LinkedList<EventEntry<FlowEntry>>();
+ private List<EventEntry<FlowId>> flowIdEvents =
+ new LinkedList<EventEntry<FlowId>>();
// All internally computed Flow Paths
private Map<Long, FlowPath> allFlowPaths = new HashMap<Long, FlowPath>();
@@ -144,6 +146,16 @@
flowEntryEvents.add(eventEntry);
}
+ //
+ // Obtain the initial FlowId state
+ //
+ Collection<FlowId> flowIds = datagridService.getAllFlowIds();
+ for (FlowId flowId : flowIds) {
+ EventEntry<FlowId> eventEntry =
+ new EventEntry<FlowId>(EventEntry.Type.ENTRY_ADD, flowId);
+ flowIdEvents.add(eventEntry);
+ }
+
// Process the initial events (if any)
synchronized (allFlowPaths) {
processEvents();
@@ -173,6 +185,7 @@
// - EventEntry<TopologyElement>
// - EventEntry<FlowPath>
// - EventEntry<FlowEntry>
+ // - EventEntry<FlowId>
//
for (EventEntry<?> event : collection) {
// Topology event
@@ -199,6 +212,14 @@
flowEntryEvents.add(flowEntryEventEntry);
continue;
}
+
+ // FlowId event
+ if (event.eventData() instanceof FlowId) {
+ EventEntry<FlowId> flowIdEventEntry =
+ (EventEntry<FlowId>)event;
+ flowIdEvents.add(flowIdEventEntry);
+ continue;
+ }
}
collection.clear();
@@ -223,6 +244,7 @@
return; // Nothing to do
}
+ processFlowIdEvents();
processFlowPathEvents();
processTopologyEvents();
processUnmatchedFlowEntryAdd();
@@ -262,6 +284,7 @@
topologyEvents.clear();
flowPathEvents.clear();
flowEntryEvents.clear();
+ flowIdEvents.clear();
//
shouldRecomputeFlowPaths.clear();
modifiedFlowPaths.clear();
@@ -354,6 +377,41 @@
}
/**
+ * Process the Flow ID events.
+ */
+ private void processFlowIdEvents() {
+ //
+ // Process all Flow ID events and update the appropriate state
+ //
+ for (EventEntry<FlowId> eventEntry : flowIdEvents) {
+ FlowId flowId = eventEntry.eventData();
+
+ log.debug("Flow ID Event: {} {}", eventEntry.eventType(), flowId);
+
+ switch (eventEntry.eventType()) {
+ case ENTRY_ADD: {
+ //
+ // Add a new Flow ID
+ //
+ // TODO: Implement it!
+
+ break;
+ }
+
+ case ENTRY_REMOVE: {
+ //
+ // Remove an existing Flow ID.
+ //
+ // TODO: Implement it!
+
+ break;
+ }
+ }
+ }
+ }
+
+
+ /**
* Process the Flow Path events.
*/
private void processFlowPathEvents() {
@@ -363,8 +421,7 @@
for (EventEntry<FlowPath> eventEntry : flowPathEvents) {
FlowPath flowPath = eventEntry.eventData();
- log.debug("Flow Event: {} {}", eventEntry.eventType(),
- flowPath.toString());
+ log.debug("Flow Event: {} {}", eventEntry.eventType(), flowPath);
switch (eventEntry.eventType()) {
case ENTRY_ADD: {
@@ -523,7 +580,7 @@
FlowEntry flowEntry = eventEntry.eventData();
log.debug("Flow Entry Event: {} {}", eventEntry.eventType(),
- flowEntry.toString());
+ flowEntry);
if ((! flowEntry.isValidFlowId()) ||
(! flowEntry.isValidFlowEntryId())) {
@@ -989,6 +1046,43 @@
}
/**
+ * Receive a notification that a FlowId is added.
+ *
+ * @param flowId the FlowId that is added.
+ */
+ @Override
+ public void notificationRecvFlowIdAdded(FlowId flowId) {
+ EventEntry<FlowId> eventEntry =
+ new EventEntry<FlowId>(EventEntry.Type.ENTRY_ADD, flowId);
+ networkEvents.add(eventEntry);
+ }
+
+ /**
+ * Receive a notification that a FlowId is removed.
+ *
+ * @param flowId the FlowId that is removed.
+ */
+ @Override
+ public void notificationRecvFlowIdRemoved(FlowId flowId) {
+ EventEntry<FlowId> eventEntry =
+ new EventEntry<FlowId>(EventEntry.Type.ENTRY_REMOVE, flowId);
+ networkEvents.add(eventEntry);
+ }
+
+ /**
+ * Receive a notification that a FlowId is updated.
+ *
+ * @param flowId the FlowId that is updated.
+ */
+ @Override
+ public void notificationRecvFlowIdUpdated(FlowId flowId) {
+ // NOTE: The ADD and UPDATE events are processed in same way
+ EventEntry<FlowId> eventEntry =
+ new EventEntry<FlowId>(EventEntry.Type.ENTRY_ADD, flowId);
+ networkEvents.add(eventEntry);
+ }
+
+ /**
* Receive a notification that a Topology Element is added.
*
* @param topologyElement the Topology Element that is added.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index 9cf68d6..388035a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -533,7 +533,7 @@
flowEntry.setFlowEntryId(new FlowEntryId(id));
}
- log.debug("Pushing Flow Entry To Switch: {}", flowEntry.toString());
+ log.debug("Pushing Flow Entry To Switch: {}", flowEntry);
entries.add(new Pair<IOFSwitch, FlowEntry>(mySwitch, flowEntry));
}
@@ -579,7 +579,7 @@
if (mySwitch != null)
continue;
- log.debug("Pushing cleanup of Flow Entry To Datagrid: {}", flowEntry.toString());
+ log.debug("Pushing cleanup of Flow Entry To Datagrid: {}", flowEntry);
//
// Write the Flow Entry to the Datagrid
@@ -693,8 +693,7 @@
//
if (flowPath.flowPathUserState() ==
FlowPathUserState.FP_USER_DELETE) {
- log.debug("Deleting Flow Path From Database: {}",
- flowPath.toString());
+ log.debug("Deleting Flow Path From Database: {}", flowPath);
boolean retry = false;
do {
@@ -740,7 +739,7 @@
if (! allValid)
continue;
- log.debug("Pushing Flow Path To Database: {}", flowPath.toString());
+ log.debug("Pushing Flow Path To Database: {}", flowPath);
//
// Write the Flow Path to the Network Map
@@ -750,9 +749,7 @@
retry = false;
try {
if (! FlowDatabaseOperation.addFlow(dbHandlerInner, flowPath)) {
- String logMsg = "Cannot write to Network Map Flow Path " +
- flowPath.flowId();
- log.error(logMsg);
+ log.error("Cannot write to Network Map Flow Path {}", flowPath.flowId());
retry = true;
}
} catch (TitanException te) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowEventHandlerService.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowEventHandlerService.java
index 78562e1..62edf70 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowEventHandlerService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowEventHandlerService.java
@@ -2,6 +2,7 @@
import net.onrc.onos.ofcontroller.topology.TopologyElement;
import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.util.FlowPath;
/**
@@ -51,6 +52,27 @@
void notificationRecvFlowEntryUpdated(FlowEntry flowEntry);
/**
+ * Receive a notification that a FlowId is added.
+ *
+ * @param flowId the FlowId that is added.
+ */
+ void notificationRecvFlowIdAdded(FlowId flowId);
+
+ /**
+ * Receive a notification that a FlowId is removed.
+ *
+ * @param flowId the FlowId that is removed.
+ */
+ void notificationRecvFlowIdRemoved(FlowId flowId);
+
+ /**
+ * Receive a notification that a FlowId is updated.
+ *
+ * @param flowId the FlowId that is updated.
+ */
+ void notificationRecvFlowIdUpdated(FlowId flowId);
+
+ /**
* Receive a notification that a Topology Element is added.
*
* @param topologyElement the Topology Element that is added.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
index 2a7574b..4f4c1e4 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/AddFlowResource.java
@@ -51,7 +51,7 @@
ObjectMapper mapper = new ObjectMapper();
String flowPathStr = flowJson;
FlowPath flowPath = null;
- log.debug("Add Flow Path: " + flowPathStr);
+ log.debug("Add Flow Path: {}", flowPathStr);
try {
flowPath = mapper.readValue(flowPathStr, FlowPath.class);
} catch (JsonGenerationException e) {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
index d0991e8..ab68584 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/DeleteFlowResource.java
@@ -46,7 +46,7 @@
result = flowService.deleteAllFlows();
} else {
FlowId flowId = new FlowId(flowIdStr);
- log.debug("Delete Flow Id: " + flowIdStr);
+ log.debug("Delete Flow Id: {}", flowIdStr);
result = flowService.deleteFlow(flowId);
}
return result;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
index 1bfb6a3..1cbeece 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetFlowByIdResource.java
@@ -41,7 +41,7 @@
String flowIdStr = (String) getRequestAttributes().get("flow-id");
FlowId flowId = new FlowId(flowIdStr);
- log.debug("Get Flow Id: " + flowIdStr);
+ log.debug("Get Flow Id: {}", flowIdStr);
result = flowService.getFlow(flowId);
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
index 9cffb56..aa31abd 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/web/GetSummaryFlowsResource.java
@@ -47,8 +47,8 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
String maxFlowStr = (String) getRequestAttributes().get("max-flows");
- log.debug("Get Summary Flows starting flow-id: " + flowIdStr + " max-flows: " + maxFlowStr);
-
+ log.debug("Get Summary Flows starting flow-id: {} max-flows: {}" ,flowIdStr, maxFlowStr);
+
flowId = new FlowId(flowIdStr);
maxFlows = Integer.parseInt(maxFlowStr);
if (maxFlows < 0) maxFlows = 0;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java
index 641faaf..e94d948 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java
@@ -140,7 +140,7 @@
case FLOW_REMOVED:
OFFlowRemoved flowMsg = (OFFlowRemoved) msg;
FlowEntryId id = new FlowEntryId(flowMsg.getCookie());
- log.debug("Got flow entry removed from " + sw.getId() + ": " + id);
+ log.debug("Got flow entry removed from {}: {}",sw.getId(), id);
flowManager.flowEntryOnSwitchExpired(sw, id);
break;
default:
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
index 4529382..f2a1828 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
@@ -505,7 +505,7 @@
// Unknown user state. Ignore the entry
log.debug(
"Flow Entry ignored (FlowEntryId = {}): unknown user state {}",
- flowEntry.flowEntryId().toString(),
+ flowEntry.flowEntryId(),
flowEntry.flowEntryUserState());
return false;
}
@@ -747,13 +747,16 @@
//
// Write the message to the switch
//
- log.debug("Installing flow entry "
- + flowEntry.flowEntryUserState() + " into switch DPID: "
- + sw.getStringId() + " flowEntryId: "
- + flowEntry.flowEntryId().toString() + " srcMac: "
- + matchSrcMac + " dstMac: " + matchDstMac + " inPort: "
- + matchInPort + " outPort: " + actionOutputPort);
-
+ log.debug("Installing flow entry {} into switch DPID: {} flowEntryId: {} srcMac: {} dstMac: {} inPort: {} outPort: {}"
+ , flowEntry.flowEntryUserState()
+ , sw.getStringId()
+ , flowEntry.flowEntryId()
+ , matchSrcMac
+ , matchDstMac
+ , matchInPort
+ , actionOutputPort
+ );
+
return add(sw, fm);
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
index 6ef44be..740e782 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -124,14 +124,14 @@
extractTime /= div;
pushTime /= div;
totalTime /= div;
- log.debug("Sync time (ms):" +
- graphIDTime + "," +
- switchTime + "," +
- compareTime + "," +
- graphEntryTime + "," +
- extractTime + "," +
- pushTime + "," +
- totalTime);
+ log.debug("Sync time (ms):{},{},{},{},{},{},{}"
+ , graphIDTime
+ , switchTime
+ , compareTime
+ , graphEntryTime
+ , extractTime
+ , pushTime
+ , totalTime);
}
/**
@@ -161,11 +161,14 @@
extractTime += entry.extractTime;
pushTime += entry.pushTime;
added++;
- }
- log.debug("Flow entries added "+ added + ", " +
- "Flow entries removed "+ removed + ", " +
- "Flow entries skipped " + skipped);
-
+ }
+ log.debug("Flow entries added {}, " +
+ "Flow entries removed {}, " +
+ "Flow entries skipped {}"
+ , added
+ , removed
+ , skipped );
+
return new SyncResult(added, removed, skipped);
}
@@ -258,7 +261,7 @@
double dbTime, extractTime, pushTime;
public void addToSwitch(IOFSwitch sw) {
if (statisticsReply != null) {
- log.error("Error adding existing flow entry {} to sw {}",
+ log.error("Error adding existing flow entry {} to sw {}",
statisticsReply.getCookie(), sw.getId());
return;
}
@@ -289,19 +292,19 @@
return;
}
extractTime = System.nanoTime() - startExtract;
-
+
double startPush = System.nanoTime();
pusher.pushFlowEntry(sw, flowEntry);
pushTime = System.nanoTime() - startPush;
}
-
+
/**
* Remove this FlowEntry from a switch via FlowPusher.
* @param sw Switch from which flow will be removed.
*/
public void removeFromSwitch(IOFSwitch sw) {
if (statisticsReply == null) {
- log.error("Error removing non-existent flow entry {} from sw {}",
+ log.error("Error removing non-existent flow entry {} from sw {}",
flowEntryId, sw.getId());
return;
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index 8077201..1dbfdcb 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -664,8 +664,7 @@
iofSwitch.write(po, null);
iofSwitch.flush();
} catch (IOException e) {
- log.error("Failure sending LLDP out port {} on switch {}",
- new Object[]{ port, iofSwitch.getStringId() }, e);
+ log.error("Failure sending LLDP out port "+port+" on switch "+iofSwitch.getStringId(), e);
}
}
@@ -675,7 +674,7 @@
*/
protected void discoverOnAllPorts() {
if (log.isTraceEnabled()) {
- log.trace("Sending LLDP packets out of all the enabled ports on switch {}");
+ log.trace("Sending LLDP packets out of all the enabled ports on switch");
}
Set<Long> switches = floodlightProvider.getSwitches().keySet();
// Send standard LLDPs
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
index 32b2e9c..289e0e2 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
@@ -226,7 +226,9 @@
if (targetDevice != null) {
deviceStorage.removeDevice(targetDevice);
- log.debug("RemoveDevice: {} due to no have not recieve the ARP reply", targetDevice.toString());
+ if (log.isDebugEnabled()) {
+ log.debug("RemoveDevice: {} due to no have not recieve the ARP reply", targetDevice);
+ }
}
it.remove();
@@ -351,10 +353,10 @@
MACAddress macAddress = MACAddress.valueOf(targetDevice.getMACAddress());
if (log.isTraceEnabled()) {
- log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}",
+ log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}",
new Object [] {
inetAddressToString(arp.getTargetProtocolAddress()),
- macAddress.toString(),
+ macAddress,
HexString.toHexString(sw.getId()), pi.getInPort()});
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
index d8997dc..540c47d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/topology/web/RouteResource.java
@@ -40,7 +40,7 @@
String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
String dstPortStr = (String) getRequestAttributes().get("dst-port");
- log.debug( srcDpidStr + "--" + srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
+ log.debug( "{}--{}--{}--{}", srcDpidStr, srcPortStr, dstDpidStr, dstPortStr);
Dpid srcDpid = new Dpid(srcDpidStr);
Port srcPort = new Port(Short.parseShort(srcPortStr));
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/DpidDeserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/DpidDeserializer.java
index fe93245..695bb1a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/DpidDeserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/DpidDeserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
dpid = new Dpid(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/FlowIdDeserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/FlowIdDeserializer.java
index f341027..e6c46aa 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/FlowIdDeserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/FlowIdDeserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
flowId = new FlowId(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4Deserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4Deserializer.java
index 2969e60..ff2238a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4Deserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4Deserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv4 = new IPv4(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4NetDeserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4NetDeserializer.java
index b2592af..edec8ad 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4NetDeserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv4NetDeserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv4Net = new IPv4Net(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6Deserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6Deserializer.java
index c825377..6689024 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6Deserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6Deserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv6 = new IPv6(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6NetDeserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6NetDeserializer.java
index 7191fa9..0d41c21 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6NetDeserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/IPv6NetDeserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
ipv6Net = new IPv6Net(value);
}
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/MACAddressDeserializer.java b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/MACAddressDeserializer.java
index 5253dce..1436f28 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/util/serializers/MACAddressDeserializer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/serializers/MACAddressDeserializer.java
@@ -31,7 +31,7 @@
String fieldname = jp.getCurrentName();
if ("value".equals(fieldname)) {
String value = jp.getText();
- log.debug("Fieldname: " + fieldname + " Value: " + value);
+ log.debug("Fieldname: {} Value: {}", fieldname, value);
mac = MACAddress.valueOf(value);
}
}
diff --git a/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java b/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
index 82af20c..319ea48 100644
--- a/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
+++ b/src/main/java/net/onrc/onos/registry/controller/StandaloneRegistry.java
@@ -101,7 +101,7 @@
new HashMap<String, List<ControllerRegistryEntry>>();
for (String strSwitch : switchCallbacks.keySet()){
- log.debug("Swtich _{}", strSwitch);
+ log.debug("Switch _{}", strSwitch);
List<ControllerRegistryEntry> list = new ArrayList<ControllerRegistryEntry>();
list.add(new ControllerRegistryEntry(controllerId, 0));