New features
[groupbasedpolicy.git] / renderers / iovisor / src / main / java / org / opendaylight / groupbasedpolicy / renderer / iovisor / IovisorRenderer.java
1 /*
2  * Copyright (c) 2015 Cisco Systems. 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;
10
11 import java.util.concurrent.Executors;
12 import java.util.concurrent.ScheduledExecutorService;
13
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
16 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * Renderer that converts GBP services to IOVisor Agents
22  */
23 public class IovisorRenderer implements AutoCloseable {
24
25     private static final Logger LOG = LoggerFactory.getLogger(IovisorRenderer.class);
26
27     private final DataBroker dataBroker;
28     private final ScheduledExecutorService executor;
29
30
31     public IovisorRenderer(final DataBroker dataProvider, RpcProviderRegistry rpcRegistry,
32             NotificationService notificationService) {
33         super();
34         this.dataBroker = dataProvider;
35
36         int numCPU = Runtime.getRuntime().availableProcessors();
37         executor = Executors.newScheduledThreadPool(numCPU * 2);
38
39         LOG.info("IOVisor Renderer has Started");
40     }
41
42     @Override
43     public void close() throws Exception {
44         executor.shutdownNow();
45     }
46
47 }