2 * Copyright (c) 2015 Huawei Technologies 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.groupbasedpolicy.renderer.faas;
11 import java.util.concurrent.Executors;
12 import java.util.concurrent.ScheduledExecutorService;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * Renderer that converts GBP services to FAAS logical networks, which then maps
21 * to the physical networks..
23 public class FaasRenderer implements AutoCloseable {
25 private static final Logger LOG = LoggerFactory.getLogger(FaasRenderer.class);
27 private final ScheduledExecutorService executor;
28 private final FaasEndpointManagerListener endpointListner;
29 private final FaasPolicyManager policyManager;
30 private final FaasEndpointAug faasEndpointAug;
32 public FaasRenderer(final DataBroker dataProvider, EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
33 int numCPU = Runtime.getRuntime().availableProcessors();
34 executor = Executors.newScheduledThreadPool(numCPU * 2);
35 policyManager = new FaasPolicyManager(dataProvider, executor);
36 endpointListner = new FaasEndpointManagerListener(policyManager, dataProvider, executor);
37 faasEndpointAug = new FaasEndpointAug(epRendererAugmentationRegistry);
38 LOG.info("FAAS Renderer has Started");
42 public void close() throws Exception {
43 executor.shutdownNow();
44 endpointListner.close();
45 policyManager.close();
46 faasEndpointAug.close();