* Don't record FLOW_MOD failure if the target node does not exist.
* Record inventory change as informational log.
Change-Id: Ic7dab1f2e1b9dcd800ab70c62c15880e5c55f7a2
Signed-off-by: Shigeru Yasuda <s-yasuda@da.jp.nec.com>
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.controller.forwardingrulesmanager.
IForwardingRulesManager;
import org.opendaylight.controller.sal.connection.ConnectionLocality;
+import org.opendaylight.controller.sal.core.Node;
/**
* This class implements flow programming task which installs a VTN flow.
VTNManagerImpl mgr = getVTNManager();
IConnectionManager cnm = mgr.getConnectionManager();
for (FlowEntry fent: entries) {
- ConnectionLocality cl = cnm.getLocalityStatus(fent.getNode());
+ Node node = fent.getNode();
+ ConnectionLocality cl = cnm.getLocalityStatus(node);
if (cl == ConnectionLocality.LOCAL) {
LocalFlowAddTask task = new LocalFlowAddTask(mgr, fent);
local.add(task);
} else if (cl == ConnectionLocality.NOT_LOCAL) {
remote.add(fent);
} else {
- LOG.error("{}: Target node of flow entry is disconnected: {}",
- mgr.getConnectionManager(), fent);
+ if (mgr.exists(node)) {
+ LOG.error("{}: " +
+ "Target node of flow entry is disconnected: {}",
+ mgr.getContainerName(), fent);
+ } else if (LOG.isTraceEnabled()) {
+ LOG.trace("{}: Target node does not exist: {}",
+ mgr.getContainerName(), fent);
+ }
+
return false;
}
}
// This class expects that the ingress flow is installed to local node.
IConnectionManager cnm = mgr.getConnectionManager();
- ConnectionLocality cl = cnm.getLocalityStatus(ingress.getNode());
+ Node node = ingress.getNode();
+ ConnectionLocality cl = cnm.getLocalityStatus(node);
if (cl != ConnectionLocality.LOCAL) {
if (cl == ConnectionLocality.NOT_LOCAL) {
LOG.error("{}: Ingress flow must be installed to " +
"local node: {}", mgr.getContainerName(),
ingress);
- } else {
+ } else if (mgr.exists(node)) {
LOG.error("{}: Target node of ingress flow entry is " +
"disconnected: {}", mgr.getContainerName(),
ingress);
+ } else if (LOG.isTraceEnabled()) {
+ LOG.trace("{}: Target node does not exist: {}",
+ mgr.getContainerName(), ingress);
}
return null;
}
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.controller.forwardingrulesmanager.
IForwardingRulesManager;
import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
+import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
Logger logger = getLogger();
if (!status.isSuccess()) {
- if (status.getCode() == StatusCode.UNDEFINED) {
- logger.error("{}: Failed to install flow entry: Timed Out:" +
- "entry={}", vtnManager.getContainerName(),
- fent);
- } else {
- logger.error("{}: Failed to install flow entry: " +
- "status={}, entry={}",
- vtnManager.getContainerName(), status, fent);
+ Node node = fent.getNode();
+ if (vtnManager.exists(node)) {
+ if (status.getCode() == StatusCode.UNDEFINED) {
+ logger.error("{}: Failed to install flow entry: " +
+ "Timed Out: entry={}",
+ vtnManager.getContainerName(), fent);
+ } else {
+ logger.error("{}: Failed to install flow entry: " +
+ "status={}, entry={}",
+ vtnManager.getContainerName(), status, fent);
+ }
+ } else if (logger.isTraceEnabled()) {
+ logger.error("{}: Failed to install flow entry: No node: " +
+ "entry={}", vtnManager.getContainerName(), fent);
}
return false;
}
Logger logger = getLogger();
if (!status.isSuccess()) {
- if (status.getCode() == StatusCode.UNDEFINED) {
- logger.error("{}: Failed to uninstall flow entry: " +
- "Timed Out: entry={}",
- vtnManager.getContainerName(), status, fent);
- } else {
- logger.error("{}: Failed to uninstall flow entry: " +
- "status={}, entry={}",
- vtnManager.getContainerName(), status, fent);
+ Node node = fent.getNode();
+ if (vtnManager.exists(node)) {
+ if (status.getCode() == StatusCode.UNDEFINED) {
+ logger.error("{}: Failed to uninstall flow entry: " +
+ "Timed Out: entry={}",
+ vtnManager.getContainerName(), status, fent);
+ } else {
+ logger.error("{}: Failed to uninstall flow entry: " +
+ "status={}, entry={}",
+ vtnManager.getContainerName(), status, fent);
+ }
+ } else if (logger.isTraceEnabled()) {
+ logger.trace("{}: Failed to uninstall flow entry: No node: " +
+ "entry={}", vtnManager.getContainerName(), fent);
}
return false;
}
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
import org.opendaylight.controller.sal.connection.ConnectionLocality;
+import org.opendaylight.controller.sal.core.Node;
/**
* This class implements flow programming task which uninstalls VTN flows.
ArrayList<LocalFlowRemoveTask> local =
new ArrayList<LocalFlowRemoveTask>();
for (FlowEntry fent: entries) {
- ConnectionLocality cl = cnm.getLocalityStatus(fent.getNode());
+ Node node = fent.getNode();
+ ConnectionLocality cl = cnm.getLocalityStatus(node);
if (cl == ConnectionLocality.LOCAL) {
LocalFlowRemoveTask task =
new LocalFlowRemoveTask(mgr, fent);
} else if (cl == ConnectionLocality.NOT_LOCAL) {
remote.add(fent);
} else {
- LOG.warn("{}: Target node of flow entry is not connected: {}",
- mgr.getConnectionManager(), fent);
+ if (mgr.exists(node)) {
+ LOG.warn("{}: " +
+ "Target node of flow entry is not connected: {}",
+ mgr.getContainerName(), fent);
+ } else if (LOG.isTraceEnabled()) {
+ LOG.trace("{}: Target node does not exist: {}",
+ mgr.getContainerName(), fent);
+ }
}
}
* separating ingress flow from others.
* </p>
*/
- protected class FlowCollector {
+ private final class FlowCollector {
/**
* List of ingress flow entries.
*/
}
FlowEntry ingress = it.next();
- if (match(ingress)) {
+ if (match(mgr, ingress)) {
ingressFlows.add(ingress);
}
while (it.hasNext()) {
FlowEntry fent = it.next();
- if (match(fent)) {
+ if (match(mgr, fent)) {
flowEntries.add(fent);
}
}
/**
* Determine whether the given flow entry should be collected or not.
*
+ * @param mgr VTN Manager service.
* @param fent A flow entry.
* @return {@code true} is returned if the given flow entry should
* be collected.
*/
- public boolean match(FlowEntry fent) {
- // Collect all flow entries.
- return true;
- }
- }
-
- /**
- * Flow collector that excludes flow entries in the specified node.
- */
- private final class ExcludeNodeCollector extends FlowCollector {
- /**
- * A node to be excluded.
- */
- private final Node excludeNode;
-
- /**
- * Construct a new collector.
- *
- * @param node A node to be excluded.
- */
- private ExcludeNodeCollector(Node node) {
- excludeNode = node;
- }
+ private boolean match(VTNManagerImpl mgr, FlowEntry fent) {
+ // Don't collect flow entry in the removed node.
+ Node node = fent.getNode();
+ boolean ret = mgr.exists(node);
+ if (!ret && LOG.isTraceEnabled()) {
+ LOG.trace("{}: Ignore flow entry in the removed node: {}",
+ mgr.getContainerName(), fent);
+ }
- /**
- * Determine whether the given flow entry should be handled or not.
- *
- * @param fent A flow entry.
- * @return {@code true} is returned if the given flow entry should
- * be handled.
- */
- public boolean match(FlowEntry fent) {
- return !excludeNode.equals(fent.getNode());
+ return ret;
}
}
}
}
- /**
- * Remove all VTN flows related to the given node.
- *
- * <p>
- * This method assumes that the given node is no longer available.
- * So this method never tries to remove flow entries from the given node.
- * </p>
- *
- * @param mgr VTN Manager service.
- * @param node A node associated with a switch.
- * @return A {@link FlowRemoveTask} object that will execute the actual
- * work is returned. {@code null} is returned if there is no flow
- * entry to be removed.
- */
- public synchronized FlowRemoveTask removeFlows(VTNManagerImpl mgr,
- Node node) {
- return removeFlows(mgr, node, false);
- }
-
/**
* Remove all VTN flows related to the given node.
*
* @param mgr VTN Manager service.
* @param node A node associated with a switch.
- * @param available Specifying {@code true} means that the given node is
- * still available.
- * Otherwise this method assumes that the given node is
- * no longer available. In this case this method never
- * tries to remove flow entries from the given node.
* @return A {@link FlowRemoveTask} object that will execute the actual
* work is returned. {@code null} is returned if there is no flow
* entry to be removed.
*/
public synchronized FlowRemoveTask removeFlows(VTNManagerImpl mgr,
- Node node,
- boolean available) {
+ Node node) {
Set<VTNFlow> vflows = nodeFlows.remove(node);
if (vflows == null) {
return null;
}
// Eliminate flow entries in the specified node.
- FlowCollector collector = (available)
- ? new FlowCollector() : new ExcludeNodeCollector(node);
+ FlowCollector collector = new FlowCollector();
for (VTNFlow vflow: vflows) {
if (LOG.isDebugEnabled()) {
LOG.debug("{}:{}: Remove VTN flow related to node {}: " +
}
if (nodeDB.putIfAbsent(node, VNodeState.UP) == null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: addNode: New node {}", containerName, node);
- }
+ LOG.info("{}: addNode: New node {}", containerName, node);
addDisabledNode(node);
return true;
}
*/
private boolean removeNode(Node node) {
if (nodeDB.remove(node) != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: removeNode: Removed {}", containerName, node);
- }
-
TimerTask task = disabledNodes.remove(node);
if (task != null) {
task.cancel();
new HashSet<NodeConnector>(portDB.keySet());
for (NodeConnector nc: ports) {
if (node.equals(nc.getNode())) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: removeNode({}): Remove port {}",
- containerName, node, nc);
- }
+ LOG.info("{}: removeNode({}): Remove port {}",
+ containerName, node, nc);
if (portDB.remove(nc) != null) {
removeISLPort(nc);
}
}
}
+ LOG.info("{}: removeNode: Removed {}", containerName, node);
+
return true;
}
PortProperty old = portDB.putIfAbsent(nc, pp);
if (old == null) {
addNode(nc.getNode(), false);
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: addPort: New port: port={}, prop={}",
- containerName, nc, pp);
- }
+ LOG.info("{}: addPort: New port: port={}, prop={}",
+ containerName, nc, pp);
return UpdateType.ADDED;
}
if (!old.equals(pp)) {
portDB.put(nc, pp);
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: addPort: Property has been changed: " +
- "port={}, prop={} -> {}", containerName, nc,
- old, pp);
- }
+ LOG.info("{}: addPort: Property has been changed: " +
+ "port={}, prop={} -> {}", containerName, nc, old, pp);
return UpdateType.CHANGED;
}
*/
private boolean removePort(NodeConnector nc) {
if (portDB.remove(nc) != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: removePort: Removed {}", containerName, nc);
- }
+ LOG.info("{}: removePort: Removed {}", containerName, nc);
removeISLPort(nc);
return true;
}
*/
private boolean addISLPort(NodeConnector nc) {
if (islDB.putIfAbsent(nc, VNodeState.UP) == null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: addISLPort: New ISL port {}",
- containerName, nc);
- }
+ LOG.info("{}: addISLPort: New ISL port {}",
+ containerName, nc);
return true;
}
*/
private boolean removeISLPort(NodeConnector nc) {
if (islDB.remove(nc) != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("{}: removeISLPort: Removed {}", containerName, nc);
- }
+ LOG.info("{}: removeISLPort: Removed {}", containerName, nc);
return true;
}
/**
* Return a set of existing nodes.
*
- * <p>
- * This method must be called with holding {@link #rwLock}.
- * </p>
- *
* @return A set of existing nodes.
*/
public Set<Node> getNodes() {
/**
* Determine whether the given node exists or not.
*
- * <p>
- * This method must be called with holding {@link #rwLock}.
- * </p>
- *
* @param node Node associated with SDN switch.
* @return {@code true} is returned if the given node exists.
* Otherwise {@code false} is returned.
TimerTask task = new TimerTask() {
@Override
public void run() {
- if (disabledNodes.remove(node) != null &&
- LOG.isDebugEnabled()) {
- LOG.debug("{}: {}: Start packet service",
- containerName, node);
+ if (disabledNodes.remove(node) != null) {
+ LOG.info("{}: {}: Start packet service",
+ containerName, node);
}
}
};
// all flow entries in this node should be removed by
// protocol plugin.
for (VTNFlowDatabase fdb: vtnFlowMap.values()) {
- fdb.removeFlows(this, node, true);
+ fdb.removeFlows(this, node);
}
}
import org.opendaylight.controller.sal.utils.NodeCreator;
import org.opendaylight.vtn.manager.VBridgeIfPath;
import org.opendaylight.vtn.manager.VBridgePath;
+import org.opendaylight.vtn.manager.VNodeState;
import org.opendaylight.vtn.manager.VTenantPath;
import org.opendaylight.vtn.manager.internal.cluster.FlowGroupId;
import org.opendaylight.vtn.manager.internal.cluster.MacVlan;
Node node0 = NodeCreator.createOFNode(Long.valueOf(0L));
Node node1 = NodeCreator.createOFNode(Long.valueOf(1L));
Node node2 = NodeCreator.createOFNode(Long.valueOf(2L));
+
+ // Register nodes to node DB except node2.
+ ConcurrentMap<Node, VNodeState> nodeDB = vtnMgr.getNodeDB();
+ nodeDB.put(node0, VNodeState.UP);
+ nodeDB.put(node1, VNodeState.UP);
+
Set<Short> portIds0 = new HashSet<Short>(createShorts((short) 10, (short) 5,
false));
Set<Short> portIds1 = new HashSet<Short>(createShorts((short) 10, (short) 4,
// remove Flows related to node1.
// flow entries in switch are also removed.
- FlowRemoveTask task = fdb.removeFlows(vtnMgr, node1, true);
+ FlowRemoveTask task = fdb.removeFlows(vtnMgr, node1);
assertNotNull(task);
flushFlowTasks();
task = fdb.removeFlows(vtnMgr, node0);
assertNull(task);
flushFlowTasks();
- assertEquals(0, stubObj.getFlowEntries().size());
+ // Flow entry in node 2 must be retained.
+ Set<FlowEntry> flows = stubObj.getFlowEntries();
+ assertFalse(flows.isEmpty());
+ for (FlowEntry fent: flows) {
+ assertEquals(node2, fent.getNode());
+ }
}
/**
Node node0 = NodeCreator.createOFNode(Long.valueOf(0L));
Node node1 = NodeCreator.createOFNode(Long.valueOf(1L));
Node node2 = NodeCreator.createOFNode(Long.valueOf(2L));
+ ConcurrentMap<Node, VNodeState> nodeDB = vtnMgr.getNodeDB();
+ nodeDB.put(node0, VNodeState.UP);
+ nodeDB.put(node1, VNodeState.UP);
+ nodeDB.put(node2, VNodeState.UP);
+
Set<Short> portIds0 = new HashSet<Short>(createShorts((short) 10, (short) 5,
false));
Set<Short> portIds1 = new HashSet<Short>(createShorts((short) 10, (short) 4,
Node node0 = NodeCreator.createOFNode(Long.valueOf(0L));
Node node1 = NodeCreator.createOFNode(Long.valueOf(1L));
+ ConcurrentMap<Node, VNodeState> nodeDB = vtnMgr.getNodeDB();
+ nodeDB.put(node0, VNodeState.UP);
+ nodeDB.put(node1, VNodeState.UP);
// ingress
NodeConnector innc
VTNFlowDatabase fdb = vtnMgr.getTenantFlowDB(path.getTenantName());
Node node0 = NodeCreator.createOFNode(Long.valueOf(0L));
- Set<Node> nodeSet = new HashSet<Node>();
- nodeSet.add(node0);
+ ConcurrentMap<Node, VNodeState> nodeDB = vtnMgr.getNodeDB();
+ nodeDB.put(node0, VNodeState.UP);
Set<VTNFlow> flows = new HashSet<VTNFlow>();
VTNFlow flow = fdb.create(vtnMgr);