move vpnservice and cleanup poms
[netvirt.git] / elanmanager / elanmanager-impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / ha / handlers / HAEventHandler.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netvirt.elan.l2gw.ha.handlers;
9
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;
19
20 @Singleton
21 public class HAEventHandler implements IHAEventHandler {
22
23     private final NodeConnectedHandler nodeConnectedHandler;
24     private final ConfigNodeUpdatedHandler configNodeUpdatedHandler = new ConfigNodeUpdatedHandler();
25     private final OpNodeUpdatedHandler opNodeUpdatedHandler = new OpNodeUpdatedHandler();
26
27     @Inject
28     public HAEventHandler(DataBroker db) {
29         nodeConnectedHandler = new NodeConnectedHandler(db);
30     }
31
32     @Override
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) {
39             return;
40         }
41         nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
42                 Optional.absent(), Optional.absent(), tx);
43     }
44
45     @Override
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) {
54             return;
55         }
56         nodeConnectedHandler.handleNodeConnected(connectedNode, connectedNodePath, haNodePath,
57                 haGlobalCfg, haPSCfg, tx);
58     }
59
60     @Override
61     public void copyChildGlobalOpUpdateToHAParent(Node updatedSrcNode,
62                                                   Node origSrcNode,
63                                                   InstanceIdentifier<Node> haPath,
64                                                   ReadWriteTransaction tx) throws ReadFailedException {
65         if (haPath == null) {
66             return;
67         }
68         opNodeUpdatedHandler.copyChildGlobalOpUpdateToHAParent(updatedSrcNode, origSrcNode, haPath, tx);
69     }
70
71     @Override
72     public void copyChildPsOpUpdateToHAParent(Node updatedSrcPSNode,
73                                               Node origSrcPSNode,
74                                               InstanceIdentifier<Node> haPath,
75                                               ReadWriteTransaction tx) throws ReadFailedException {
76         if (haPath == null) {
77             return;
78         }
79         opNodeUpdatedHandler.copyChildPsOpUpdateToHAParent(updatedSrcPSNode, origSrcPSNode, haPath, tx);
80     }
81
82     @Override
83     public void copyHAPSUpdateToChild(Node haUpdated,
84                                       Node haOriginal,
85                                       InstanceIdentifier<Node> haChildNodeId,
86                                       ReadWriteTransaction tx)
87             throws InterruptedException, ExecutionException, ReadFailedException {
88         if (haChildNodeId == null) {
89             return;
90         }
91         configNodeUpdatedHandler.copyHAPSUpdateToChild(haUpdated, haOriginal, haChildNodeId, tx);
92     }
93
94     @Override
95     public void copyHAGlobalUpdateToChild(Node haUpdated,
96                                           Node haOriginal,
97                                           InstanceIdentifier<Node> haChildNodeId,
98                                           ReadWriteTransaction tx)
99             throws InterruptedException, ExecutionException, ReadFailedException {
100         if (haChildNodeId == null) {
101             return;
102         }
103         configNodeUpdatedHandler.copyHAGlobalUpdateToChild(haUpdated, haOriginal, haChildNodeId, tx);
104     }
105
106 }