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 com.google.common.base.Optional;
11 import java.util.concurrent.ExecutionException;
12 import javax.inject.Inject;
13 import javax.inject.Singleton;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
16 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 public class HAEventHandler implements IHAEventHandler {
23 private final NodeConnectedHandler nodeConnectedHandler;
24 private final ConfigNodeUpdatedHandler configNodeUpdatedHandler = new ConfigNodeUpdatedHandler();
25 private final OpNodeUpdatedHandler opNodeUpdatedHandler = new OpNodeUpdatedHandler();
28 public HAEventHandler(DataBroker db) {
29 nodeConnectedHandler = new NodeConnectedHandler(db);
33 public void handleChildNodeConnected(Node connectedNode,
34 InstanceIdentifier<Node> connectedNodePath,
35 InstanceIdentifier<Node> haNodePath,
36 ReadWriteTransaction tx)
37 throws ReadFailedException, ExecutionException, InterruptedException {
38 if (haNodePath == null) {
41 nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
42 Optional.absent(), Optional.absent(), tx);
46 public void handleChildNodeReConnected(Node connectedNode,
47 InstanceIdentifier<Node> connectedNodePath,
48 InstanceIdentifier<Node> haNodePath,
49 Optional<Node> haGlobalCfg,
50 Optional<Node> haPSCfg,
51 ReadWriteTransaction tx)
52 throws ReadFailedException, ExecutionException, InterruptedException {
53 if (haNodePath == null) {
56 nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
57 haGlobalCfg, haPSCfg, tx);
61 public void copyChildGlobalOpUpdateToHAParent(Node updatedSrcNode,
63 InstanceIdentifier<Node> haPath,
64 ReadWriteTransaction tx) throws ReadFailedException {
68 opNodeUpdatedHandler.copyChildGlobalOpUpdateToHAParent(updatedSrcNode, origSrcNode, haPath, tx);
72 public void copyChildPsOpUpdateToHAParent(Node updatedSrcPSNode,
74 InstanceIdentifier<Node> haPath,
75 ReadWriteTransaction tx) throws ReadFailedException {
79 opNodeUpdatedHandler.copyChildPsOpUpdateToHAParent(updatedSrcPSNode, origSrcPSNode, haPath, tx);
83 public void copyHAPSUpdateToChild(Node haUpdated,
85 InstanceIdentifier<Node> haChildNodeId,
86 ReadWriteTransaction tx)
87 throws InterruptedException, ExecutionException, ReadFailedException {
88 if (haChildNodeId == null) {
91 configNodeUpdatedHandler.copyHAPSUpdateToChild(haUpdated, haOriginal, haChildNodeId, tx);
95 public void copyHAGlobalUpdateToChild(Node haUpdated,
97 InstanceIdentifier<Node> haChildNodeId,
98 ReadWriteTransaction tx)
99 throws InterruptedException, ExecutionException, ReadFailedException {
100 if (haChildNodeId == null) {
103 configNodeUpdatedHandler.copyHAGlobalUpdateToChild(haUpdated, haOriginal, haChildNodeId, tx);