X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2Fconnect%2Fdom%2FBindingIndependentDataServiceConnector.java;h=7a72afc88550b3871ea72286f5b791b4a90f568c;hb=9455ea18680bf9476099ed27157b84d569e33486;hp=ccd6079cc997b00b9de8a2a6f5ee935155f01340;hpb=cf4834ff659cecdeb08a247679dfbf6b10f4ea73;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java index ccd6079cc9..7a72afc885 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java @@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory; public class BindingIndependentDataServiceConnector implements // RuntimeDataProvider, // - Provider { + Provider, AutoCloseable { private final Logger LOG = LoggerFactory.getLogger(BindingIndependentDataServiceConnector.class); @@ -59,16 +59,24 @@ public class BindingIndependentDataServiceConnector implements // @Override public DataObject readOperationalData(InstanceIdentifier path) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); - CompositeNode result = biDataService.readOperationalData(biPath); - return mappingService.dataObjectFromDataDom(path, result); + try { + org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); + CompositeNode result = biDataService.readOperationalData(biPath); + return mappingService.dataObjectFromDataDom(path, result); + } catch (DeserializationException e) { + throw new IllegalStateException(e); + } } @Override public DataObject readConfigurationData(InstanceIdentifier path) { - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); - CompositeNode result = biDataService.readConfigurationData(biPath); - return mappingService.dataObjectFromDataDom(path, result); + try { + org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path); + CompositeNode result = biDataService.readConfigurationData(biPath); + return mappingService.dataObjectFromDataDom(path, result); + } catch (DeserializationException e) { + throw new IllegalStateException(e); + } } private DataModificationTransaction createBindingToDomTransaction( @@ -103,23 +111,42 @@ public class BindingIndependentDataServiceConnector implements // .beginTransaction(); for (Entry entry : source .getUpdatedConfigurationData().entrySet()) { - InstanceIdentifier baKey = mappingService.fromDataDom(entry.getKey()); - DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue()); - target.putConfigurationData(baKey, baData); + try { + InstanceIdentifier baKey = mappingService.fromDataDom(entry.getKey()); + DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue()); + target.putConfigurationData(baKey, baData); + } catch (DeserializationException e) { + LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry.getKey(), e); + } } for (Entry entry : source .getUpdatedOperationalData().entrySet()) { - InstanceIdentifier baKey = mappingService.fromDataDom(entry.getKey()); - DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue()); - target.putOperationalData(baKey, baData); + try { + + InstanceIdentifier baKey = mappingService.fromDataDom(entry.getKey()); + DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue()); + target.putOperationalData(baKey, baData); + } catch (DeserializationException e) { + LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry.getKey(), e); + } } for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedConfigurationData()) { - InstanceIdentifier baEntry = mappingService.fromDataDom(entry); - target.removeConfigurationData(baEntry); + try { + + InstanceIdentifier baEntry = mappingService.fromDataDom(entry); + target.removeConfigurationData(baEntry); + } catch (DeserializationException e) { + LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry, e); + } } for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedOperationalData()) { - InstanceIdentifier baEntry = mappingService.fromDataDom(entry); - target.removeOperationalData(baEntry); + try { + + InstanceIdentifier baEntry = mappingService.fromDataDom(entry); + target.removeOperationalData(baEntry); + } catch (DeserializationException e) { + LOG.error("Ommiting from BA transaction: {}. Reason{}.", entry, e); + } } return target; } @@ -162,6 +189,18 @@ public class BindingIndependentDataServiceConnector implements // start(); } + @Override + public void close() throws Exception { + + if (baCommitHandlerRegistration != null) { + baCommitHandlerRegistration.close(); + } + if (biCommitHandlerRegistration != null) { + biCommitHandlerRegistration.close(); + } + + } + private class DomToBindingTransaction implements DataCommitTransaction { @@ -271,10 +310,11 @@ public class BindingIndependentDataServiceConnector implements // @Override public void onRegister(DataCommitHandlerRegistration, DataObject> registration) { - - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration.getPath()); + + org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration + .getPath()); // FIXME: do registration based on only active commit handlers. - + } @Override