org.opendaylight.controller.sal.inventory,
org.opendaylight.controller.sal.match,
org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.sal.connection,
org.apache.commons.lang3.builder,
org.apache.commons.lang3.tuple,
org.apache.felix.dm,
<artifactId>sal</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal.connection</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller.thirdparty</groupId>
<artifactId>org.openflow.openflowj</artifactId>
import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener;
+import org.opendaylight.controller.sal.connection.ConnectionConstants;
+import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
import org.openflow.protocol.OFMessage;
import org.openflow.protocol.OFType;
import org.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class Controller implements IController, CommandProvider {
+public class Controller implements IController, CommandProvider, IPluginInConnectionService {
private static final Logger logger = LoggerFactory
.getLogger(Controller.class);
private ControllerIO controllerIO;
// create new switch
int i = this.switchInstanceNumber.addAndGet(1);
String instanceName = "SwitchHandler-" + i;
- SwitchHandler switchHandler = new SwitchHandler(this, sc,
- instanceName);
+ SwitchHandler switchHandler = new SwitchHandler(this, sc, instanceName);
switchHandler.start();
if (sc.isConnected()) {
logger.info("Switch:{} is connected to the Controller",
help.append("\t controllerShowConnConfig\n");
return help.toString();
}
+
+ @Override
+ public Status disconnect(Node node) {
+ ISwitch sw = getSwitch((Long) node.getID());
+ if (sw != null) disconnectSwitch(sw);
+ return new Status(StatusCode.SUCCESS);
+ }
+
+ @Override
+ public Node connect(String connectionIdentifier, Map<ConnectionConstants, String> params) {
+ return null;
+ }
+
+ /**
+ * View Change notification
+ */
+ public void notifyClusterViewChanged() {
+ for (ISwitch sw : switches.values()) {
+ notifySwitchAdded(sw);
+ }
+ }
+
+ /**
+ * Node Disconnected from the node's master controller.
+ */
+ @Override
+ public void notifyNodeDisconnectFromMaster(Node node) {
+ ISwitch sw = switches.get((Long)node.getID());
+ if (sw != null) notifySwitchAdded(sw);
+ }
}
import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.internal.Controller;
+import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
import org.opendaylight.controller.sal.core.IContainerListener;
import org.opendaylight.controller.sal.core.Node;
.setCallbacks("setPluginOutDataPacketService",
"unsetPluginOutDataPacketService")
.setRequired(false));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
if (imp.equals(ReadService.class)) {
.setService(IReadServiceFilter.class)
.setCallbacks("setService", "unsetService")
.setRequired(true));
+
c.add(createContainerServiceDependency(containerName)
.setService(IPluginOutReadService.class)
.setCallbacks("setPluginOutReadServices",
"unsetPluginOutReadServices")
.setRequired(false));
+
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
if (imp.equals(FlowProgrammerNotifier.class)) {
.setCallbacks("setPluginOutFlowProgrammerService",
"unsetPluginOutFlowProgrammerService")
.setRequired(true));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
}
public Object[] getGlobalImplementations() {
Object[] res = { Controller.class, OFStatisticsManager.class,
FlowProgrammerService.class, ReadServiceFilter.class,
- DiscoveryService.class, DataPacketMuxDemux.class,
+ DiscoveryService.class, DataPacketMuxDemux.class, InventoryService.class,
InventoryServiceShim.class, TopologyServiceShim.class };
return res;
}
logger.debug("Activator configureGlobalInstance( ) is called");
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("name", "Controller");
- c.setInterface(IController.class.getName(), props);
+ props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), Node.NodeIDType.OPENFLOW);
+ c.setInterface(new String[] { IController.class.getName(),
+ IPluginInConnectionService.class.getName()},
+ props);
}
if (imp.equals(FlowProgrammerService.class)) {
"unsetsetFlowProgrammerNotifier")
.setRequired(false));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
if (imp.equals(ReadServiceFilter.class)) {
.setCallbacks("setReadFilterInternalListener",
"unsetReadFilterInternalListener")
.setRequired(false));
-
}
if (imp.equals(OFStatisticsManager.class)) {
.setService(IDiscoveryListener.class)
.setCallbacks("setDiscoveryListener",
"unsetDiscoveryListener").setRequired(true));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
// DataPacket mux/demux services, which is teh actual engine
.setService(IDataPacketListen.class)
.setCallbacks("setIDataPacketListen",
"unsetIDataPacketListen").setRequired(false));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
+ }
+
+ if (imp.equals(InventoryService.class)) {
+ // export the service
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put("scope", "Global");
+
+ c.setInterface(
+ new String[] { IPluginInInventoryService.class.getName(),
+ IInventoryShimInternalListener.class.getName(),
+ IInventoryProvider.class.getName() }, props);
+
+ // Now lets add a service dependency to make sure the
+ // provider of service exists
+ c.add(createServiceDependency()
+ .setService(IController.class, "(name=Controller)")
+ .setCallbacks("setController", "unsetController")
+ .setRequired(true));
+ c.add(createServiceDependency()
+ .setService(IPluginOutInventoryService.class, "(scope=Global)")
+ .setCallbacks("setPluginOutInventoryServices",
+ "unsetPluginOutInventoryServices")
+ .setRequired(false));
}
if (imp.equals(InventoryServiceShim.class)) {
.setCallbacks("setController", "unsetController")
.setRequired(true));
c.add(createServiceDependency()
- .setService(IInventoryShimInternalListener.class)
+ .setService(IInventoryShimInternalListener.class, "(!(scope=Global))")
.setCallbacks("setInventoryShimInternalListener",
"unsetInventoryShimInternalListener")
.setRequired(true));
+ c.add(createServiceDependency()
+ .setService(IInventoryShimInternalListener.class, "(scope=Global)")
+ .setCallbacks("setInventoryShimGlobalInternalListener",
+ "unsetInventoryShimGlobalInternalListener")
+ .setRequired(true));
c.add(createServiceDependency()
.setService(IInventoryShimExternalListener.class)
.setCallbacks("setInventoryShimExternalListener",
"unsetInventoryShimExternalListener")
.setRequired(false));
+ c.add(createServiceDependency()
+ .setService(IPluginOutConnectionService.class)
+ .setCallbacks("setIPluginOutConnectionService",
+ "unsetIPluginOutConnectionService")
+ .setRequired(false));
}
if (imp.equals(TopologyServiceShim.class)) {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.ContainerFlow;
import org.opendaylight.controller.sal.core.IContainerListener;
private ConcurrentMap<String, List<ContainerFlow>> container2FlowSpecs = new ConcurrentHashMap<String, List<ContainerFlow>>();
// Track local data packet listener
private List<IDataPacketListen> iDataPacketListen = new CopyOnWriteArrayList<IDataPacketListen>();
+ private IPluginOutConnectionService connectionOutService;
void setIDataPacketListen(IDataPacketListen s) {
if (this.iDataPacketListen != null) {
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
new Object[] { sw, msg, this.pluginOutDataPacketServices });
return;
}
+
+ Long ofSwitchID = Long.valueOf(sw.getId());
+ try {
+ Node n = new Node(Node.NodeIDType.OPENFLOW, ofSwitchID);
+ if (!connectionOutService.isLocal(n)) {
+ logger.debug("Connection service refused DataPacketMuxDemux receive {} {}", sw, msg);
+ return;
+ }
+ }
+ catch (Exception e) {
+ return;
+ }
+
if (msg instanceof OFPacketIn) {
OFPacketIn ofPacket = (OFPacketIn) msg;
- Long ofSwitchID = Long.valueOf(sw.getId());
Short ofPortID = Short.valueOf(ofPacket.getInPort());
try {
return;
}
+ if (!connectionOutService.isLocal(outPort.getNode())) {
+ logger.debug("data packets will not be sent to {} in a non-master controller", outPort.toString());
+ return;
+ }
+
+
if (!outPort.getType().equals(
NodeConnector.NodeConnectorIDType.OPENFLOW)) {
// The output Port is not of type OpenFlow
import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
+import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.packet.IPluginInDataPacketService;
import org.opendaylight.controller.sal.packet.RawPacket;
protected static final Logger logger = LoggerFactory
.getLogger(DataPacketServices.class);
private IDataPacketMux iDataPacketMux = null;
+ private IPluginOutConnectionService connectionOutService;
void setIDataPacketMux(IDataPacketMux s) {
this.iDataPacketMux = s;
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
@Override
public void transmitDataPacket(RawPacket outPkt) {
- this.iDataPacketMux.transmitDataPacket(outPkt);
+ NodeConnector nc = outPkt.getOutgoingNodeConnector();
+ if (connectionOutService != null && connectionOutService.isLocal(nc.getNode())) {
+ this.iDataPacketMux.transmitDataPacket(outPkt);
+ } else {
+ logger.debug("{} is dropped in the controller "+outPkt);
+ }
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Config;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.utils.NetUtils;
import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
/**
* The class describes neighbor discovery service for an OpenFlow network.
private volatile Boolean shuttingDown = false;
private LLDPTLV chassisIdTlv, portIdTlv, ttlTlv, customTlv;
+ private IPluginOutConnectionService connectionOutService;
class DiscoveryTransmit implements Runnable {
private final BlockingQueue<NodeConnector> transmitQ;
return;
}
+ if (!connectionOutService.isLocal(nodeConnector.getNode())) {
+ logger.debug("Discoery packets will not be sent to {} in a non-master controller", nodeConnector.toString());
+ return;
+ }
+
if (outPkt == null) {
logger.debug("Can not send discovery packet out since outPkt is null");
return;
return PacketResult.IGNORED;
}
- if (((Short) inPkt.getIncomingNodeConnector().getID()).equals(NodeConnector.SPECIALNODECONNECTORID)) {
+ NodeConnector nodeConnector = inPkt.getIncomingNodeConnector();
+ if (((Short) nodeConnector.getID()).equals(NodeConnector.SPECIALNODECONNECTORID)) {
logger.trace("Ignoring ethernet packet received on special port: "
+ inPkt.getIncomingNodeConnector().toString());
return PacketResult.IGNORED;
}
+ if (!connectionOutService.isLocal(nodeConnector.getNode())) {
+ logger.debug("Discoery packets will not be processed from {} in a non-master controller", nodeConnector.toString());
+ return PacketResult.IGNORED;
+ }
+
Ethernet ethPkt = new Ethernet();
try {
ethPkt.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
// Allow one more retry
readyListLo.add(nodeConnector);
elapsedTime.remove(nodeConnector);
+ if (connectionOutService.isLocal(nodeConnector.getNode())) {
+ transmitQ.add(nodeConnector);
+ }
}
}
}
private void doDiscovery() {
if (++discoveryTimerTickCount <= discoveryBatchPauseTicks) {
for (NodeConnector nodeConnector : getWorkingSet()) {
- transmitQ.add(nodeConnector);
- // Move to staging area after it's served
- if (!stagingList.contains(nodeConnector)) {
- stagingList.add(nodeConnector);
+ if (connectionOutService.isLocal(nodeConnector.getNode())) {
+ transmitQ.add(nodeConnector);
+ // Move to staging area after it's served
+ if (!stagingList.contains(nodeConnector)) {
+ stagingList.add(nodeConnector);
+ }
}
}
} else if (discoveryTimerTickCount >= discoveryBatchRestartTicks) {
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
private void initDiscoveryPacket() {
// Create LLDP ChassisID TLV
chassisIdTlv = new LLDPTLV();
import org.apache.felix.dm.Component;
import org.opendaylight.controller.protocol_plugin.openflow.IFlowProgrammerNotifier;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.flowprogrammer.Flow;
import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
protected static final Logger logger = LoggerFactory
.getLogger(FlowProgrammerNotifier.class);
private IPluginOutFlowProgrammerService salNotifier;
+ private IPluginOutConnectionService connectionOutService;
public FlowProgrammerNotifier() {
salNotifier = null;
@Override
public void flowRemoved(Node node, Flow flow) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("flow removed will not be notified in a non-master controller for node "+node);
+ return;
+ }
+
if (salNotifier != null) {
salNotifier.flowRemoved(node, flow);
} else {
@Override
public void flowErrorReported(Node node, long rid, Object err) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("flow error will not be notified in a non-master controller for node "+node);
+ return;
+ }
+
if (salNotifier != null) {
salNotifier.flowErrorReported(node, rid, err);
} else {
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
}
import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.ContainerFlow;
import org.opendaylight.controller.sal.core.IContainerListener;
import org.opendaylight.controller.sal.core.Node;
private Map<String, Set<NodeConnector>> containerToNc;
private ConcurrentMap<Long, Map<Integer, Long>> xid2rid;
private int barrierMessagePriorCount = getBarrierMessagePriorCount();
+ private IPluginOutConnectionService connectionOutService;
public FlowProgrammerService() {
controller = null;
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
public void setFlowProgrammerNotifier(Map<String, ?> props,
IFlowProgrammerNotifier s) {
if (props == null || props.get("containerName") == null) {
@Override
public Status addFlow(Node node, Flow flow) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Add flow will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return addFlowInternal(node, flow, 0);
}
@Override
public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Modify flow will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return modifyFlowInternal(node, oldFlow, newFlow, 0);
}
@Override
public Status removeFlow(Node node, Flow flow) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Remove flow will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return removeFlowInternal(node, flow, 0);
}
@Override
public Status addFlowAsync(Node node, Flow flow, long rid) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Add flow Async will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return addFlowInternal(node, flow, rid);
}
@Override
public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow,
long rid) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Modify flow async will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return modifyFlowInternal(node, oldFlow, newFlow, rid);
}
@Override
public Status removeFlowAsync(Node node, Flow flow, long rid) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Remove flow async will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return removeFlowInternal(node, flow, rid);
}
@Override
public Status removeAllFlows(Node node) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Remove all flows will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
return new Status(StatusCode.SUCCESS);
}
@Override
public Status syncSendBarrierMessage(Node node) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("Sync Send Barrier will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
if (!node.getType().equals(NodeIDType.OPENFLOW)) {
return new Status(StatusCode.NOTACCEPTABLE,
"The node does not support Barrier message.");
@Override
public Status asyncSendBarrierMessage(Node node) {
+ if (!connectionOutService.isLocal(node)) {
+ log.debug("ASync Send Barrier will not be processed in a non-master controller for node " + node);
+ return new Status(StatusCode.NOTALLOWED, "This is not the master controller for " + node);
+ }
+
if (!node.getType().equals(NodeIDType.OPENFLOW)) {
return new Status(StatusCode.NOTACCEPTABLE,
"The node does not support Barrier message.");
import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
Dictionary props = c.getServiceProperties();
if (props != null) {
containerName = (String) props.get("containerName");
- isDefaultContainer = containerName.equals(GlobalConstants.DEFAULT
- .toString());
+ if (containerName != null) {
+ isDefaultContainer = containerName.equals(GlobalConstants.DEFAULT
+ .toString());
+ }
}
nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
return;
}
- Set<Node> nodeSet = nodeProps.keySet();
- if (((props == null) || props.isEmpty()) && (nodeSet != null)
- && nodeSet.contains(node)) {
- // node already added
- return;
- }
-
logger.trace("addNode: {} added, props: {} for container {}",
new Object[] { node, props, containerName });
break;
}
}
-
}
import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Actions;
import org.opendaylight.controller.sal.core.Buffers;
import org.opendaylight.controller.sal.core.Capabilities;
.getLogger(InventoryServiceShim.class);
private IController controller = null;
private final ConcurrentMap<String, IInventoryShimInternalListener> inventoryShimInternalListeners = new ConcurrentHashMap<String, IInventoryShimInternalListener>();
+ private final Set<IInventoryShimInternalListener> globalInventoryShimInternalListeners = new HashSet<IInventoryShimInternalListener>();
private final List<IInventoryShimExternalListener> inventoryShimExternalListeners = new CopyOnWriteArrayList<IInventoryShimExternalListener>();
private final ConcurrentMap<NodeConnector, Set<String>> nodeConnectorContainerMap = new ConcurrentHashMap<NodeConnector, Set<String>>();
private final ConcurrentMap<Node, Set<String>> nodeContainerMap = new ConcurrentHashMap<Node, Set<String>>();
private final ConcurrentMap<NodeConnector, Set<Property>> nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Set<Property>>();
private final ConcurrentMap<Node, Set<Property>> nodeProps = new ConcurrentHashMap<Node, Set<Property>>();
+ private IPluginOutConnectionService connectionOutService;
void setController(IController s) {
this.controller = s;
}
}
+ void setInventoryShimGlobalInternalListener(Map<?, ?> props,
+ IInventoryShimInternalListener s) {
+ if ((this.globalInventoryShimInternalListeners != null)) {
+ this.globalInventoryShimInternalListeners.add(s);
+ }
+ }
+
+ void unsetInventoryShimGlobalInternalListener(Map<?, ?> props,
+ IInventoryShimInternalListener s) {
+ if ((this.globalInventoryShimInternalListeners != null)) {
+ this.globalInventoryShimInternalListeners.remove(s);
+ }
+ }
+
void setInventoryShimInternalListener(Map<?, ?> props,
IInventoryShimInternalListener s) {
if (props == null) {
}
String containerName = (String) props.get("containerName");
if (containerName == null) {
- logger.error("unsetInventoryShimInternalListener containerName not supplied");
+ logger.error("setInventoryShimInternalListener containerName not supplied");
return;
}
if ((this.inventoryShimInternalListeners != null)
}
}
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
+
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
this.inventoryShimInternalListeners.clear();
this.nodeConnectorContainerMap.clear();
this.nodeContainerMap.clear();
+ this.globalInventoryShimInternalListeners.clear();
this.controller = null;
}
* Notify all internal and external listeners
*/
private void notifyInventoryShimListener(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
+ notifyGlobalInventoryShimInternalListener(nodeConnector, type, props);
+ /*
+ * isLocal is intentionally moved after the GlobalInventory listener call.
+ * The above notification to GlobalInventory will make sure that the connectionOutService be ready
+ * to reply to isLocal query.
+ */
+ if (!connectionOutService.isLocal(nodeConnector.getNode())) {
+ logger.debug("Connection service dropped the inventory notification for {} {}", nodeConnector.toString(), type);
+ return;
+ } else {
+ logger.debug("Connection service accepted the inventory notification for {} {}", nodeConnector.toString(), type);
+ }
+
// notify other containers
Set<String> containers = (nodeConnectorContainerMap.get(nodeConnector) == null) ? new HashSet<String>()
: new HashSet<String>(nodeConnectorContainerMap.get(nodeConnector));
* Notify all internal and external listeners
*/
private void notifyInventoryShimListener(Node node, UpdateType type, Set<Property> props) {
- // Now notify other containers
+ notifyGlobalInventoryShimInternalListener(node, type, props);
+ /*
+ * isLocal is intentionally moved after the GlobalInventory listener call.
+ * The above notification to GlobalInventory will make sure that the connectionOutService be ready
+ * to reply to isLocal query.
+ */
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("Connection service dropped the inventory notification for {} {}", node.toString(), type);
+ return;
+ } else {
+ logger.debug("Connection service accepted the inventory notification for {} {}", node.toString(), type);
+ }
+ // Now notify other containers
Set<String> containers = (nodeContainerMap.get(node) == null) ? new HashSet<String>() : new HashSet<String>(
nodeContainerMap.get(node));
containers.add(GlobalConstants.DEFAULT.toString());
notifyInventoryShimExternalListener(node, type, props);
}
+ private void notifyGlobalInventoryShimInternalListener(Node node, UpdateType type, Set<Property> props) {
+ for (IInventoryShimInternalListener globalListener : globalInventoryShimInternalListeners) {
+ globalListener.updateNode(node, type, props);
+ logger.trace(
+ "notifyGlobalInventoryShimInternalListener {} type {}",
+ new Object[] { node, type });
+ }
+ }
+
+ private void notifyGlobalInventoryShimInternalListener(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
+ for (IInventoryShimInternalListener globalListener : globalInventoryShimInternalListeners) {
+ globalListener.updateNodeConnector(nodeConnector, type, props);
+ logger.trace(
+ "notifyGlobalInventoryShimInternalListener {} type {}",
+ new Object[] { nodeConnector, type });
+ }
+ }
+
private void notifyInventoryShimInternalListener(String container,
Node node, UpdateType type, Set<Property> props) {
IInventoryShimInternalListener inventoryShimInternalListener = inventoryShimInternalListeners
import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsReply;
import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsRequest;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
}
return statsQueueSize;
}
+
+ IPluginOutConnectionService connectionPluginOutService;
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionPluginOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionPluginOutService == s) {
+ connectionPluginOutService = null;
+ }
+ }
+
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
import org.apache.felix.dm.Component;
import org.opendaylight.controller.protocol_plugin.openflow.IReadFilterInternalListener;
import org.opendaylight.controller.protocol_plugin.openflow.IReadServiceFilter;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Node.NodeIDType;
import org.opendaylight.controller.sal.core.NodeConnector;
private IReadServiceFilter filter;
private Set<IPluginOutReadService> pluginOutReadServices;
private String containerName;
+ private IPluginOutConnectionService connectionOutService;
/**
* Function called by the dependency manager when all the required
return null;
}
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for the node : " + node);
+ return null;
+ }
return filter.readFlow(containerName, node, flow, cached);
}
return null;
}
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for the node : " + node);
+ return null;
+ }
+
return filter.readAllFlow(containerName, node, cached);
}
return null;
}
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for the node : " + node);
+ return null;
+ }
+
return filter.readDescription(node, cached);
}
logger.error("Invalid node type");
return null;
}
+
+ if (!connectionOutService.isLocal(connector.getNode())) {
+ logger.debug("This Controller is not the master for connector : "+connector);
+ return null;
+ }
+
return filter.readNodeConnector(containerName, connector, cached);
}
return null;
}
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return null;
+ }
+
return filter.readAllNodeConnector(containerName, node, cached);
}
logger.error("Invalid node type");
return 0;
}
+
+ if (!connectionOutService.isLocal(connector.getNode())) {
+ logger.debug("This Controller is not the master for connector : "+connector);
+ return 0;
+ }
+
return filter.getTransmitRate(containerName, connector);
}
logger.error("Invalid node type");
return null;
}
+
+ if (!connectionOutService.isLocal(table.getNode())) {
+ logger.debug("This Controller is not the master for connector : "+table);
+ return null;
+ }
+
return filter.readNodeTable(containerName, table, cached);
}
return null;
}
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return null;
+ }
+
return filter.readAllNodeTable(containerName, node, cached);
}
@Override
public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return;
+ }
for (IPluginOutReadService service : pluginOutReadServices) {
service.nodeFlowStatisticsUpdated(node, flowStatsList);
}
@Override
public void nodeConnectorStatisticsUpdated(Node node, List<NodeConnectorStatistics> ncStatsList) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return;
+ }
for (IPluginOutReadService service : pluginOutReadServices) {
service.nodeConnectorStatisticsUpdated(node, ncStatsList);
}
@Override
public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return;
+ }
for (IPluginOutReadService service : pluginOutReadServices) {
service.nodeTableStatisticsUpdated(node, tableStatsList);
}
@Override
public void nodeDescriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
+ if (!connectionOutService.isLocal(node)) {
+ logger.debug("This Controller is not the master for node : " + node);
+ return;
+ }
for (IPluginOutReadService service : pluginOutReadServices) {
service.descriptionStatisticsUpdated(node, nodeDescription);
}
}
+
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
}
import org.opendaylight.controller.sal.action.Action;
import org.opendaylight.controller.sal.action.ActionType;
import org.opendaylight.controller.sal.action.Output;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.ContainerFlow;
import org.opendaylight.controller.sal.core.IContainerListener;
import org.opendaylight.controller.sal.core.Node;
this.statsMgr = null;
}
+ IPluginOutConnectionService connectionPluginOutService;
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionPluginOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionPluginOutService == s) {
+ connectionPluginOutService = null;
+ }
+ }
+
@Override
public FlowOnNode readFlow(String container, Node node, Flow flow, boolean cached) {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Bandwidth;
import org.opendaylight.controller.sal.core.Config;
import org.opendaylight.controller.sal.core.ContainerFlow;
}
}
+ IPluginOutConnectionService connectionPluginOutService;
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionPluginOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionPluginOutService == s) {
+ connectionPluginOutService = null;
+ }
+ }
+
private void removeNodeConnector(String container,
NodeConnector nodeConnector) {
List<TopoEdgeUpdate> teuList = new ArrayList<TopoEdgeUpdate>();
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
.getLogger(TopologyServices.class);
private IPluginOutTopologyService salTopoService = null;
private IRefreshInternalProvider topoRefreshService = null;
+ private IPluginOutConnectionService connectionOutService;
private String containerName;
/**
this.salTopoService.edgeUtilBackToNormal(edge);
}
}
+
+ void setIPluginOutConnectionService(IPluginOutConnectionService s) {
+ connectionOutService = s;
+ }
+
+ void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
+ if (connectionOutService == s) {
+ connectionOutService = null;
+ }
+ }
}