Introduction of XSQL
[controller.git] / opendaylight / md-sal / sal-dom-xsql / src / main / java / org / opendaylight / xsql / XSQLProvider.java
1 package org.opendaylight.xsql;
2
3 import java.util.concurrent.ExecutionException;
4
5 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
6 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
7 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQL;
8 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQLBuilder;
9 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13 /**
14  * Created by root on 6/26/14.
15  */
16 public class XSQLProvider implements AutoCloseable {
17
18     public static final InstanceIdentifier<XSQL> ID = InstanceIdentifier.builder(XSQL.class).build();
19     private static final Logger LOG = LoggerFactory.getLogger(XSQLProvider.class);
20
21     public void close() {
22     }
23
24     public XSQL buildXSQL(DataProviderService dps) {
25             XSQLBuilder builder = new XSQLBuilder();
26             builder.setPort("34343");
27             XSQL xsql = builder.build();
28             if (dps != null) {
29                 final DataModificationTransaction t = dps.beginTransaction();
30                 t.removeOperationalData(ID);
31                 t.putOperationalData(ID,xsql);
32
33                 try {
34                     t.commit().get();
35                 } catch (InterruptedException | ExecutionException e) {
36                    LOG.warn("Failed to update toaster status, operational otherwise", e);
37                 }
38             }
39         return xsql;
40     }
41 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.