2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
10 import java.util.concurrent.ExecutionException;
11 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
14 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
15 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalAugmentationMerger;
16 import org.opendaylight.netvirt.elan.l2gw.ha.merge.GlobalNodeMerger;
17 import org.opendaylight.netvirt.elan.l2gw.ha.merge.PSAugmentationMerger;
18 import org.opendaylight.netvirt.elan.l2gw.ha.merge.PSNodeMerger;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 public class ConfigNodeUpdatedHandler {
25 GlobalAugmentationMerger globalAugmentationMerger = GlobalAugmentationMerger.getInstance();
26 PSAugmentationMerger psAugmentationMerger = PSAugmentationMerger.getInstance();
27 GlobalNodeMerger globalNodeMerger = GlobalNodeMerger.getInstance();
28 PSNodeMerger psNodeMerger = PSNodeMerger.getInstance();
31 * Copy updated data from HA node to child node of config data tree.
33 * @param haUpdated HA node updated
34 * @param haOriginal HA node original
35 * @param haChildNodeId HA child node which needs to be updated
36 * @param tx Transaction
37 * @throws ReadFailedException Exception thrown if read fails
38 * @throws ExecutionException Exception thrown if Execution fail
39 * @throws InterruptedException Thread interrupted Exception
41 public void copyHAGlobalUpdateToChild(Node haUpdated,
43 InstanceIdentifier<Node> haChildNodeId,
44 ReadWriteTransaction tx)
45 throws InterruptedException, ExecutionException, ReadFailedException {
47 Node existingNode = HwvtepHAUtil.readNode(tx, LogicalDatastoreType.CONFIGURATION, haChildNodeId);
48 HwvtepGlobalAugmentation updatedGlobal = HwvtepHAUtil.getGlobalAugmentationOfNode(haUpdated);
49 HwvtepGlobalAugmentation origGlobal = HwvtepHAUtil.getGlobalAugmentationOfNode(haOriginal);
50 HwvtepGlobalAugmentation existingData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingNode);
52 globalAugmentationMerger.mergeConfigUpdate(existingData, updatedGlobal, origGlobal, haChildNodeId, tx);
53 globalNodeMerger.mergeConfigUpdate(existingNode, haUpdated, haOriginal, haChildNodeId, tx);
57 * Copy HA ps node update to HA child ps node of config data tree.
59 * @param haUpdated HA node updated
60 * @param haOriginal HA node original
61 * @param haChildNodeId HA child node which needs to be updated
62 * @param tx Transaction
63 * @throws ReadFailedException Exception thrown if read fails
64 * @throws ExecutionException Exception thrown if Execution fail
65 * @throws InterruptedException Thread interrupted Exception
67 public void copyHAPSUpdateToChild(Node haUpdated,
69 InstanceIdentifier<Node> haChildNodeId,
70 ReadWriteTransaction tx)
71 throws InterruptedException, ExecutionException, ReadFailedException {
73 Node existingNode = HwvtepHAUtil.readNode(tx, LogicalDatastoreType.CONFIGURATION, haChildNodeId);
75 PhysicalSwitchAugmentation updated = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(haUpdated);
76 PhysicalSwitchAugmentation orig = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(haOriginal);
77 PhysicalSwitchAugmentation existingData = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(existingNode);
79 psAugmentationMerger.mergeConfigUpdate(existingData, updated, orig, haChildNodeId, tx);
80 psNodeMerger.mergeConfigUpdate(existingNode, haUpdated, haOriginal, haChildNodeId, tx);