*/
package org.opendaylight.netvirt.elan.l2gw.listeners;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.genius.datastoreutils.AsyncClusteredDataChangeListenerBase;
+import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepClusteredDataTreeChangeListener;
+import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
import org.opendaylight.netvirt.elan.l2gw.jobs.LogicalSwitchAddedJob;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
* @see LogicalSwitches
*/
public class HwvtepLogicalSwitchListener extends
- AsyncClusteredDataChangeListenerBase<LogicalSwitches, HwvtepLogicalSwitchListener> {
+ HwvtepClusteredDataTreeChangeListener<LogicalSwitches, HwvtepLogicalSwitchListener> {
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(HwvtepLogicalSwitchListener.class);
/** The node id. */
- private NodeId nodeId;
+ private final NodeId nodeId;
/** The logical switch name. */
- private String logicalSwitchName;
+ private final String logicalSwitchName;
/** The physical device. */
- private Devices physicalDevice;
+ private final Devices physicalDevice;
/** The l2 gateway device. */
- private L2GatewayDevice l2GatewayDevice;
+ private final L2GatewayDevice l2GatewayDevice;
// The default vlan id
- private Integer defaultVlanId;
+ private final Integer defaultVlanId;
// Id of L2 Gateway connection responsible for this logical switch creation
- private Uuid l2GwConnId;
+ private final Uuid l2GwConnId;
private final DataBroker broker;
private final ElanL2GatewayUtils elanL2GatewayUtils;
- private final EntityOwnershipService entityOwnershipService;
+ private final EntityOwnershipUtils entityOwnershipUtils;
private final ElanUtils elanUtils;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
*
* @param dataBroker DataBroker
* @param elanL2GatewayUtils l2 gateway utils
- * @param entityOwnershipService the entity ownership service
+ * @param entityOwnershipUtils the entity ownership utils
* @param elanUtils the ELAN utilities
* @param elanL2GatewayMulticastUtils l2 gateway multicast utils
* @param l2GatewayDevice the l2 gateway device
* @param l2GwConnId l2 gateway connection id
*/
public HwvtepLogicalSwitchListener(DataBroker dataBroker, ElanL2GatewayUtils elanL2GatewayUtils,
- EntityOwnershipService entityOwnershipService, ElanUtils elanUtils,
+ EntityOwnershipUtils entityOwnershipUtils, ElanUtils elanUtils,
ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
L2GatewayDevice l2GatewayDevice,
String logicalSwitchName,
super(LogicalSwitches.class, HwvtepLogicalSwitchListener.class);
this.broker = dataBroker;
this.elanL2GatewayUtils = elanL2GatewayUtils;
- this.entityOwnershipService = entityOwnershipService;
+ this.entityOwnershipUtils = entityOwnershipUtils;
this.elanUtils = elanUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
new HwvtepNodeName(logicalSwitchName));
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opendaylight.genius.datastoreutils.AsyncClusteredDataChangeListenerBase#
- * getDataChangeListener()
- */
- @Override
- protected ClusteredDataChangeListener getDataChangeListener() {
- return HwvtepLogicalSwitchListener.this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opendaylight.genius.datastoreutils.AsyncClusteredDataChangeListenerBase#
- * getDataChangeScope()
- */
@Override
- protected AsyncDataBroker.DataChangeScope getDataChangeScope() {
- return AsyncDataBroker.DataChangeScope.BASE;
+ protected HwvtepLogicalSwitchListener getDataTreeChangeListener() {
+ return this;
}
/*
* org.opendaylight.yangtools.yang.binding.DataObject)
*/
@Override
- protected void remove(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches deletedLogicalSwitch) {
+ protected void removed(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches deletedLogicalSwitch) {
LOG.trace("Received Remove DataChange Notification for identifier: {}, LogicalSwitches: {}", identifier,
deletedLogicalSwitch);
}
* org.opendaylight.yangtools.yang.binding.DataObject)
*/
@Override
- protected void update(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches logicalSwitchOld,
+ protected void updated(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches logicalSwitchOld,
LogicalSwitches logicalSwitchNew) {
LOG.trace("Received Update DataChange Notification for identifier: {}, LogicalSwitches old: {}, new: {}."
+ "No Action Performed.", identifier, logicalSwitchOld, logicalSwitchNew);
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
- protected void add(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches logicalSwitchNew) {
+ protected void added(InstanceIdentifier<LogicalSwitches> identifier, LogicalSwitches logicalSwitchNew) {
LOG.debug("Received Add DataChange Notification for identifier: {}, LogicalSwitches: {}", identifier,
logicalSwitchNew);
try {
- L2GatewayDevice elanDevice = L2GatewayConnectionUtils.addL2DeviceToElanL2GwCache(
- logicalSwitchNew.getHwvtepNodeName().getValue(), l2GatewayDevice, l2GwConnId);
+ L2GatewayDevice elanDevice = L2GatewayConnectionUtils.addL2DeviceToElanL2GwCache(broker,
+ logicalSwitchNew.getHwvtepNodeName().getValue(), elanL2GatewayUtils,
+ l2GatewayDevice, l2GwConnId, physicalDevice);
- LogicalSwitchAddedJob logicalSwitchAddedWorker = new LogicalSwitchAddedJob(broker, elanL2GatewayUtils,
- elanUtils, elanL2GatewayMulticastUtils, logicalSwitchName, physicalDevice, elanDevice,
+ LogicalSwitchAddedJob logicalSwitchAddedWorker = new LogicalSwitchAddedJob(elanL2GatewayUtils,
+ elanL2GatewayMulticastUtils, logicalSwitchName, physicalDevice, elanDevice,
defaultVlanId);
- ElanClusterUtils.runOnlyInLeaderNode(entityOwnershipService, logicalSwitchAddedWorker.getJobKey() ,
- "create vlan mappings and mcast configurations",
- logicalSwitchAddedWorker);
+ ElanClusterUtils.runOnlyInOwnerNode(entityOwnershipUtils, logicalSwitchAddedWorker.getJobKey(),
+ "create vlan mappings and mcast configurations", logicalSwitchAddedWorker);
} catch (RuntimeException e) {
LOG.error("Failed to handle HwVTEPLogicalSwitch - add for: {}", identifier, e);
} finally {
// TODO use https://git.opendaylight.org/gerrit/#/c/44145/ when merged, and remove @SuppressWarnings
close();
} catch (Exception e) {
- LOG.warn("Failed to close HwVTEPLogicalSwitchListener: {}", e);
+ LOG.warn("Failed to close HwVTEPLogicalSwitchListener", e);
}
}
}