Adding nemo engine.
[nemo.git] / nemo-renderers / openflow-renderer / src / main / java / org / opendaylight / nemo / renderer / openflow / OpenflowRenderer.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. 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.nemo.renderer.openflow;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 import com.google.common.util.concurrent.FutureCallback;
19 import com.google.common.util.concurrent.Futures;
20
21 public class OpenflowRenderer implements AutoCloseable {
22         
23         private static final Logger LOG = LoggerFactory.getLogger(OpenflowRenderer.class);
24         
25         private DataBroker dataBroker;
26         private final ResourceManager resourceManager;
27         private final FlowTableManager flowTableMng;
28         
29         public OpenflowRenderer(DataBroker dataBroker) {
30                 super();
31         this.dataBroker = dataBroker;
32                 System.out.println();
33                 System.out.println("Waiting for loading config file about 30s...");
34
35                 LOG.info("New ResourceManager.");
36                 resourceManager = new ResourceManager(dataBroker);
37
38                 LOG.info("New FlowTableManager.");
39                 flowTableMng = new FlowTableManager(dataBroker, resourceManager);
40
41                 LOG.info("Initialized openflow renderer.");
42     }
43         
44         // *************
45     // AutoCloseable
46     // *************
47
48     @Override
49     public void close() throws Exception {
50                 if (flowTableMng != null) flowTableMng.close();
51                 if (resourceManager != null) resourceManager.close();
52     }
53 }
54