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
9 package org.opendaylight.vpnservice.elan.l2gw.internal;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.elanmanager.utils.ElanL2GwCacheUtils;
15 import org.opendaylight.vpnservice.elan.internal.ElanInstanceManager;
16 import org.opendaylight.vpnservice.elan.internal.ElanInterfaceManager;
17 import org.opendaylight.vpnservice.elan.internal.ElanServiceProvider;
18 import org.opendaylight.vpnservice.elan.l2gw.listeners.HwvtepLocalUcastMacListener;
19 import org.opendaylight.vpnservice.elan.l2gw.listeners.HwvtepNodeListener;
20 import org.opendaylight.vpnservice.elan.l2gw.listeners.L2GatewayConnectionListener;
21 import org.opendaylight.vpnservice.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
22 import org.opendaylight.vpnservice.elan.l2gw.utils.ElanL2GatewayUtils;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService;
24 import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
29 * Elan L2 Gateway provider class.
31 public class ElanL2GatewayProvider implements AutoCloseable {
33 private static final Logger LOG = LoggerFactory.getLogger(ElanL2GatewayProvider.class);
35 private DataBroker broker;
36 private EntityOwnershipService entityOwnershipService;
37 private BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer;
38 private ItmRpcService itmRpcService;
39 private ElanInstanceManager elanInstanceManager;
40 private ElanInterfaceManager elanInterfaceManager;
42 private L2GatewayConnectionListener l2GwConnListener;
43 private HwvtepNodeListener hwvtepNodeListener;
44 private HwvtepLocalUcastMacListener torMacsListener;
47 * Instantiates a new elan l2 gateway provider.
49 * @param elanServiceProvider
50 * the elan service provider
52 public ElanL2GatewayProvider(ElanServiceProvider elanServiceProvider) {
53 this.broker = elanServiceProvider.getBroker();
54 this.entityOwnershipService = elanServiceProvider.getEntityOwnershipService();
55 this.bindingNormalizedNodeSerializer = elanServiceProvider.getBindingNormalizedNodeSerializer();
56 this.itmRpcService = elanServiceProvider.getItmRpcService();
57 this.elanInstanceManager = elanServiceProvider.getElanInstanceManager();
58 this.elanInterfaceManager = elanServiceProvider.getElanInterfaceManager();
62 LOG.info("ElanL2GatewayProvider Initialized");
66 * Initialize Elan L2 Gateway.
69 ElanL2GwCacheUtils.createElanL2GwDeviceCache();
70 ElanL2GatewayUtils.setDataBroker(broker);
71 ElanL2GatewayUtils.setItmRpcService(itmRpcService);
73 ElanL2GatewayMulticastUtils.setBroker(broker);
74 ElanL2GatewayMulticastUtils.setElanInstanceManager(elanInstanceManager);
75 ElanL2GatewayMulticastUtils.setElanInterfaceManager(elanInterfaceManager);
77 this.torMacsListener = new HwvtepLocalUcastMacListener(broker, entityOwnershipService,
78 bindingNormalizedNodeSerializer);
79 this.l2GwConnListener = new L2GatewayConnectionListener(broker, entityOwnershipService,
80 bindingNormalizedNodeSerializer, elanInstanceManager);
81 this.hwvtepNodeListener = new HwvtepNodeListener(broker, entityOwnershipService,
82 bindingNormalizedNodeSerializer, elanInstanceManager, itmRpcService);
83 this.hwvtepNodeListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
89 * @see java.lang.AutoCloseable#close()
92 public void close() throws Exception {
93 this.torMacsListener.close();
94 this.l2GwConnListener.close();
95 this.hwvtepNodeListener.close();
96 LOG.info("ElanL2GatewayProvider Closed");