X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FForwardedBackwardsCompatibleDataBroker.java;h=12f26b09bb2cf1645d645438302e705c3c0489ce;hp=bf18454f4d1c3122ad7e8c5cd651e02d24f50437;hb=3d81e6fb622fb7d5b239a8697d51bcb6d96658db;hpb=ebd9aba9e844229de613a2b60b5d21119fcee968 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java index bf18454f4d..12f26b09bb 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java @@ -18,7 +18,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.binding.api.BindingDataChangeListener; import org.opendaylight.controller.md.sal.common.api.RegistrationListener; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -29,12 +28,12 @@ import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.Data import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration; import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.controller.sal.binding.api.data.DataProviderService; -import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.Delegator; @@ -43,8 +42,8 @@ import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.concepts.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -113,11 +112,11 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat final InstanceIdentifier path, final DataChangeListener listener) { - BindingDataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener); - BindingDataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener); + org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener); + org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener); - ListenerRegistration cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE); - ListenerRegistration operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE); + ListenerRegistration cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE); + ListenerRegistration operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE); return new LegacyListenerRegistration(listener,cfgReg,operReg); } @@ -162,9 +161,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat @Override public ListenableFuture> apply(final Boolean requestCommitSuccess) throws Exception { if(requestCommitSuccess) { - return tx.getDelegate().commit(); + return AbstractDataTransaction.convertToLegacyCommitFuture(tx.getDelegate().submit()); } - return Futures.immediateFuture(Rpcs.getRpcResult(false, TransactionStatus.FAILED, Collections.emptySet())); + return Futures.immediateFuture(RpcResultBuilder.failed().withResult(TransactionStatus.FAILED).build()); } }); @@ -187,7 +186,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } private class ForwardedBackwardsCompatibleTransacion extends - AbstractForwardedTransaction implements DataModificationTransaction { + AbstractReadWriteTransaction implements DataModificationTransaction { private final ListenerRegistry listeners = ListenerRegistry.create(); private final Map, DataObject> updated = new HashMap<>(); @@ -215,9 +214,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat public void putOperationalData(final InstanceIdentifier path, final DataObject data) { boolean previouslyRemoved = posponedRemovedOperational.remove(path); if(previouslyRemoved) { - doPutWithEnsureParents(getDelegate(), LogicalDatastoreType.OPERATIONAL, path, data); + doPutWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data); } else { - doMergeWithEnsureParents(getDelegate(), LogicalDatastoreType.OPERATIONAL, path, data); + doMergeWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data); } } @@ -233,9 +232,9 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } updated.put(path, data); if(previouslyRemoved) { - doPutWithEnsureParents(getDelegate(), LogicalDatastoreType.CONFIGURATION, path, data); + doPutWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data); } else { - doMergeWithEnsureParents(getDelegate(), LogicalDatastoreType.CONFIGURATION, path, data); + doMergeWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data); } } @@ -309,11 +308,6 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } } - @Override - public Object getIdentifier() { - return getDelegate().getIdentifier(); - } - private void changeStatus(final TransactionStatus status) { LOG.trace("Transaction {} changed status to {}", getIdentifier(), status); this.status = status; @@ -331,11 +325,11 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat public ListenableFuture> commit() { for(InstanceIdentifier path : posponedRemovedConfiguration) { - doDelete(getDelegate(), LogicalDatastoreType.CONFIGURATION, path); + doDelete(LogicalDatastoreType.CONFIGURATION, path); } for(InstanceIdentifier path : posponedRemovedOperational) { - doDelete(getDelegate(), LogicalDatastoreType.OPERATIONAL, path); + doDelete(LogicalDatastoreType.OPERATIONAL, path); } changeStatus(TransactionStatus.SUBMITED); @@ -387,12 +381,12 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat private static final class LegacyListenerRegistration implements ListenerRegistration { private final DataChangeListener instance; - private final ListenerRegistration cfgReg; - private final ListenerRegistration operReg; + private final ListenerRegistration cfgReg; + private final ListenerRegistration operReg; public LegacyListenerRegistration(final DataChangeListener listener, - final ListenerRegistration cfgReg, - final ListenerRegistration operReg) { + final ListenerRegistration cfgReg, + final ListenerRegistration operReg) { this.instance = listener; this.cfgReg = cfgReg; this.operReg = operReg; @@ -411,7 +405,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } - private static class BackwardsCompatibleOperationalDataChangeInvoker implements BindingDataChangeListener, Delegator { + private static class BackwardsCompatibleOperationalDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator { private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener delegate; @@ -436,7 +430,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } - private static class BackwardsCompatibleConfigurationDataChangeInvoker implements BindingDataChangeListener, Delegator { + private static class BackwardsCompatibleConfigurationDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator { private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener delegate; public BackwardsCompatibleConfigurationDataChangeInvoker(final DataChangeListener listener) {