Rework IOVisor model and validate IovisorModuleInstance on Endpoint created events
[groupbasedpolicy.git] / renderers / iovisor / src / main / java / org / opendaylight / groupbasedpolicy / renderer / iovisor / endpoint / EndpointManager.java
1 /*
2  * Copyright (c) 2015 Inocybe Technologies 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
9 package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
10
11 import java.util.Map.Entry;
12
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
15 import org.opendaylight.groupbasedpolicy.endpoint.EndpointRpcRegistry;
16 import org.opendaylight.groupbasedpolicy.endpoint.EpRendererAugmentation;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
22 import org.opendaylight.yangtools.yang.binding.Augmentation;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import com.google.common.base.Preconditions;
27
28 public class EndpointManager implements EpRendererAugmentation, AutoCloseable {
29
30     private static final Logger LOG = LoggerFactory.getLogger(EndpointManager.class);
31
32     private EndpointRpcRegistry endpointRpcRegistry;
33     private EndpointListener endpointListener;
34
35     public EndpointManager(DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) {
36         LOG.debug("Initialized IOVisor EndpointManager");
37         Preconditions.checkNotNull(dataBroker, "DataBroker instance must not be null");
38         Preconditions.checkNotNull(rpcProviderRegistry, "RpcProviderRegistry instance must not be null");
39
40         this.endpointRpcRegistry = new EndpointRpcRegistry(dataBroker, rpcProviderRegistry);
41         this.endpointListener = new EndpointListener(dataBroker);
42
43         EndpointRpcRegistry.register(this);
44     }
45
46     @Override
47     public void close() throws Exception {
48         if (endpointListener != null) {
49             endpointListener.close();
50         }
51         if (endpointRpcRegistry != null) {
52             endpointRpcRegistry.close();
53         }
54         EndpointRpcRegistry.unregister(this);
55     }
56
57     @Override
58     public Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> buildEndpointAugmentation(
59             RegisterEndpointInput input) {
60         // TODO Auto-generated method stub
61         return null;
62     }
63
64     @Override
65     public Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> buildEndpointL3Augmentation(
66             RegisterEndpointInput input) {
67         // TODO Auto-generated method stub
68         return null;
69     }
70
71     @Override
72     public Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> buildL3PrefixEndpointAugmentation(
73             RegisterL3PrefixEndpointInput input) {
74         // TODO Auto-generated method stub
75         return null;
76     }
77 }