X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=alivenessmonitor%2Falivenessmonitor-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Falivenessmonitor%2Finternal%2FAlivenessMonitorProvider.java;fp=alivenessmonitor%2Falivenessmonitor-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Falivenessmonitor%2Finternal%2FAlivenessMonitorProvider.java;h=d118cc95a0d48d2867d13b1f3570b3a1dac6bb26;hb=16019c0dbaee9203ffa419c3db634fd57286ac37;hp=0000000000000000000000000000000000000000;hpb=3dc16815b89fef0b19107c2155ffb2fd38802c22;p=vpnservice.git diff --git a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessMonitorProvider.java b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessMonitorProvider.java new file mode 100644 index 00000000..d118cc95 --- /dev/null +++ b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessMonitorProvider.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.vpnservice.alivenessmonitor.internal; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.EtherTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.OdlArputilService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AlivenessMonitorProvider implements BindingAwareProvider, + AutoCloseable { + private static final Logger LOG = LoggerFactory.getLogger(AlivenessMonitorProvider.class); + private AlivenessMonitor alivenessMonitor; + private RpcProviderRegistry rpcProviderRegistry; + private OdlInterfaceRpcService interfaceManager; + private RpcRegistration rpcRegistration; + private ListenerRegistration listenerRegistration; + private NotificationService notificationService; + private NotificationPublishService notificationPublishService; + + public AlivenessMonitorProvider(RpcProviderRegistry rpcProviderRegistry) { + this.rpcProviderRegistry = rpcProviderRegistry; + } + + public RpcProviderRegistry getRpcProviderRegistry() { + return rpcProviderRegistry; + } + + public void setNotificationService(NotificationService notificationService) { + this.notificationService = notificationService; + } + + public void setNotificationPublishService(NotificationPublishService notificationPublishService) { + this.notificationPublishService = notificationPublishService; + } + + @Override + public void close() throws Exception { + rpcRegistration.close(); + listenerRegistration.close(); + alivenessMonitor.close(); + } + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("AlivenessMonitorProvider Session Initiated"); + try { + final DataBroker dataBroker = session.getSALService(DataBroker.class); + PacketProcessingService pktProcessingService = session.getRpcService(PacketProcessingService.class); + IdManagerService idManager = rpcProviderRegistry.getRpcService(IdManagerService.class); + OdlInterfaceRpcService interfaceService = rpcProviderRegistry.getRpcService(OdlInterfaceRpcService.class); + alivenessMonitor = new AlivenessMonitor(dataBroker); + alivenessMonitor.setPacketProcessingService(pktProcessingService); + alivenessMonitor.setNotificationPublishService(notificationPublishService); + alivenessMonitor.setIdManager(idManager); + alivenessMonitor.setInterfaceManager(interfaceService); + rpcRegistration = getRpcProviderRegistry().addRpcImplementation(AlivenessMonitorService.class, alivenessMonitor); + listenerRegistration = notificationService.registerNotificationListener(alivenessMonitor); + + //ARP Handler + AlivenessProtocolHandler arpHandler = new AlivenessProtocolHandlerARP(alivenessMonitor); + OdlArputilService arpService = rpcProviderRegistry.getRpcService(OdlArputilService.class); + ((AlivenessProtocolHandlerARP) arpHandler).setArpManagerService(arpService); + alivenessMonitor.registerHandler(EtherTypes.Arp, arpHandler); + + //LLDP Handler + AlivenessProtocolHandler lldpHandler = new AlivenessProtocolHandlerLLDP(alivenessMonitor); + alivenessMonitor.registerHandler(EtherTypes.Lldp, lldpHandler); + + //TODO: Enable Interface Event Listener + //DelegatingInterfaceEventListener listener = new DelegatingInterfaceEventListener(alivenessMonitor); + //interfaceListenerRegistration = notificationService.registerNotificationListener(listener); + } catch (Exception e) { + LOG.error("Error initializing AlivenessMonitor service", e); + } + } + +}