Migrate to MD-SAL APIs
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / intenthandler / GroupBasedPolicyNeutronIntentHandlerBean.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc.  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.lispflowmapping.neutron.intenthandler;
9
10 import org.opendaylight.lispflowmapping.neutron.intenthandler.listener.service.VbridgeTopologyListenerService;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.MountPointService;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 /**
17  * Created by Shakib Ahmed on 1/19/17.
18  */
19
20 /*
21  * This is the bean instantiated when lisp neutron service is installed. This bean
22  * registers and maintain listeners for getting updates of Neutron Topology
23  * maintained by groupbasedpolicy and honeycomb vbd.
24  */
25 public class GroupBasedPolicyNeutronIntentHandlerBean implements AutoCloseable {
26     private static final Logger LOG = LoggerFactory.getLogger(GroupBasedPolicyNeutronIntentHandlerBean.class);
27
28     private final DataBroker dataBroker;
29     private final MountPointService mountService;
30
31     private VbridgeTopologyListenerService vbridgeTopologyListenerService;
32
33     private final IntentHandlerAsyncExecutorProvider intentHandlerAsyncExecutorProvider =
34             IntentHandlerAsyncExecutorProvider.getInstace();
35
36     public GroupBasedPolicyNeutronIntentHandlerBean(DataBroker dataBroker, MountPointService mountService) {
37         this.dataBroker = dataBroker;
38         this.mountService = mountService;
39     }
40
41
42     @Override
43     public void close() throws Exception {
44         LOG.info("Clustering provider closed for {}", this.getClass().getSimpleName());
45         intentHandlerAsyncExecutorProvider.close();
46     }
47
48     public void init() {
49         LOG.info("LFM neutron handler service registered", this.getClass().getSimpleName());
50         vbridgeTopologyListenerService = VbridgeTopologyListenerService.initialize(dataBroker, mountService);
51     }
52 }