--- /dev/null
+Directory where the opendaylight controller modules store their configuration files
package org.opendaylight.controller.forwardingrulesmanager;
import java.io.Serializable;
-import java.lang.reflect.Field;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.ArrayList;
/**
* Configuration Java Object which represents a flow configuration information
- * for Forwarding Rrules Manager.
+ * for Forwarding Rules Manager.
*/
@XmlRootElement
public boolean isInternalFlow() {
// Controller generated static flows have name starting with "**"
- if (this.name == null)
- return false;
- return this.name.startsWith("**");
+ return (this.name != null && this.name.startsWith("**"));
}
public String getName() {
this.actions = actions;
}
- public static List<String> getFieldsNames() {
- List<String> fieldList = new ArrayList<String>();
- for (Field fld : FlowConfig.class.getDeclaredFields()) {
- fieldList.add(fld.getName());
- }
- // Remove 4 static fields + 2 internal field
- for (int i = 0; i < 6; i++)
- fieldList.remove(0);
-
- return fieldList;
- }
-
public boolean isPortGroupEnabled() {
return (portGroup != null);
}
IConfigurationContainerAware, IInventoryListener, IObjectReader,
ICacheUpdateAware<Long, String>, CommandProvider {
private static final String SAVE = "Save";
+ private static final String NODEDOWN = "Node is Down";
private static final Logger log = LoggerFactory
.getLogger(ForwardingRulesManagerImpl.class);
private Map<Long, String> flowsSaveEvent;
private void updateStaticFlowConfigsOnNodeDown(Node node) {
log.trace("Updating Static Flow configs on node down: " + node);
- for (FlowConfig config : staticFlows.values()) {
+ List<Integer> toRemove = new ArrayList<Integer>();
+ for (Entry<Integer,FlowConfig> entry : staticFlows.entrySet()) {
+
+ FlowConfig config = entry.getValue();
+
if (config.isPortGroupEnabled()) {
continue;
}
+
if (config.installInHw() && config.getNode().equals(node)) {
- config.setStatus("Node is down");
+ if (config.isInternalFlow()) {
+ // Take note of this controller generated static flow
+ toRemove.add(entry.getKey());
+ } else {
+ config.setStatus(NODEDOWN);
+ }
}
}
+ // Remove controller generated static flows for this node
+ for (Integer index : toRemove) {
+ staticFlows.remove(index);
+ }
}
private void updateStaticFlowConfigsOnContainerModeChange(UpdateType update) {
ConcurrentHashMap<Integer, FlowConfig> nonDynamicFlows = new ConcurrentHashMap<Integer, FlowConfig>();
for (Integer ordinal : staticFlows.keySet()) {
FlowConfig config = staticFlows.get(ordinal);
- if (config.isDynamic())
+ // Do not save dynamic and controller generated static flows
+ if (config.isDynamic() || config.isInternalFlow()) {
continue;
+ }
nonDynamicFlows.put(ordinal, config);
}
objWriter.write(nonDynamicFlows, frmFileName);
public void notifyNode(Node node, UpdateType type,
Map<String, Property> propMap) {
switch (type) {
- case ADDED:
+ case ADDED:
addStaticFlowsToSwitch(node);
break;
- case REMOVED:
+ case REMOVED:
cleanDatabaseForNode(node);
updateStaticFlowConfigsOnNodeDown(node);
break;
@Override
public void notifyNodeConnector(NodeConnector nodeConnector,
- UpdateType type, Map<String, Property> propMap) {
+ UpdateType type, Map<String, Property> propMap) {
}
private FlowConfig getDerivedFlowConfig(FlowConfig original,
*
*/
void init() {
- log.info("Init");
frmAware = Collections
.synchronizedSet(new HashSet<IForwardingRulesManagerAware>());
frmFileName = GlobalConstants.STARTUPHOME.toString() + "frm_staticflows_"
*
*/
void destroy() {
- log.info("Destroy");
destroyCaches();
}
*
*/
void start() {
- log.info("Start");
/*
* Read startup and build database if we have not already gotten the
* configurations synced from another node
*
*/
void stop() {
- log.info("Stop");
}
public void setFlowProgrammerService(IFlowProgrammerService service) {
boolean verbose = false;
String verboseCheck = ci.nextArgument();
if (verboseCheck != null) {
- verbose = verboseCheck.equals("true");
+ verbose = verboseCheck.equalsIgnoreCase("true");
}
// Dump per node database
return mode;
}
+ public boolean isProactive() {
+ return Integer.parseInt(mode) != 0;
+ }
+
public static long getSerialversionuid() {
return serialVersionUID;
}
boolean modeChange = false;
SwitchConfig sc = nodeConfigList.get(cfgObject.getNodeId());
- if ((sc == null) || !cfgObject.getMode().equals(sc.getMode()))
+ if ((sc == null) || !cfgObject.getMode().equals(sc.getMode())) {
modeChange = true;
+ }
nodeConfigList.put(cfgObject.getNodeId(), cfgObject);
try {
.getMode());
if (modeChange) {
- notifyModeChange(node, (Integer.parseInt(cfgObject
- .getMode()) != 0));
+ notifyModeChange(node, cfgObject.isProactive());
}
}
} catch (Exception e) {
private void addNode(Node node, Set<Property> props) {
log.trace("{} added", node);
- if (nodeProps == null)
+ if (nodeProps == null) {
return;
+ }
Map<String, Property> propMap;
if (nodeProps.get(node) != null) {
}
// copy node properties from config
+ boolean proactiveForwarding = false;
if (nodeConfigList != null) {
String nodeId = node.getNodeIDString();
for (SwitchConfig conf : nodeConfigList.values()) {
propMap.put(name.getName(), name);
Property tier = new Tier(Integer.parseInt(conf.getTier()));
propMap.put(tier.getName(), tier);
+ proactiveForwarding = conf.isProactive();
break;
}
}
// check if span ports are configed
addSpanPorts(node);
- /* notify node listeners */
+ // notify node listeners
notifyNode(node, UpdateType.ADDED, propMap);
+
+ // notify proactive mode forwarding
+ if (proactiveForwarding) {
+ notifyModeChange(node, true);
+ }
}
private void removeNode(Node node) {
log.trace("{} {}", nodeConnector, type);
- if (nodeConnectorProps == null)
+ if (nodeConnectorProps == null) {
return;
+ }
switch (type) {
case ADDED:
Set<Node> nodes = getNodes();
if (nodes != null) {
for (Node node : nodes) {
- if (id == (Long) node.getID()) {
+ if (id.equals((Long)node.getID())) {
return node;
}
}
for (Node node : getNodes()) {
SwitchConfig sc = getSwitchConfig(node.toString());
if ((sc != null) && isDefaultContainer) {
- service.modeChangeNotify(node,
- (Integer.parseInt(sc.getMode()) != 0));
+ service.modeChangeNotify(node, sc.isProactive());
}
}
}
@Override
public boolean isSpecial(NodeConnector p) {
- if (p.equals(NodeConnectorIDType.CONTROLLER) ||
- p.equals(NodeConnectorIDType.ALL) ||
- p.equals(NodeConnectorIDType.SWSTACK) ||
- p.equals(NodeConnectorIDType.HWPATH)) {
+ if (p.getType().equals(NodeConnectorIDType.CONTROLLER) ||
+ p.getType().equals(NodeConnectorIDType.ALL) ||
+ p.getType().equals(NodeConnectorIDType.SWSTACK) ||
+ p.getType().equals(NodeConnectorIDType.HWPATH)) {
return true;
}
return false;