X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2FNetconfDeviceDataBroker.java;h=e73ed3d7e741929e1b183f3bb95f87f62b25c322;hb=1dba5b2651d7fc60af0263cc0640d5ebeda8e454;hp=cb1a7a6441b8569d424b17185690fc6a7d898d72;hpb=9631593590312ae7641077c182c1fb59723b2241;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBroker.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBroker.java index cb1a7a6441..e73ed3d7e7 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBroker.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBroker.java @@ -7,14 +7,14 @@ */ package org.opendaylight.netconf.sal.connect.netconf.sal; -import com.google.common.base.Preconditions; +import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ImmutableClassToInstanceMap; import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension; import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMRpcService; import org.opendaylight.mdsal.dom.api.DOMTransactionChain; import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker; @@ -22,6 +22,8 @@ import org.opendaylight.netconf.dom.api.tx.NetconfDOMDataBrokerFieldsExtension; import org.opendaylight.netconf.dom.api.tx.NetconfDOMFieldsReadTransaction; import org.opendaylight.netconf.dom.api.tx.NetconfDOMFieldsReadWriteTransaction; import org.opendaylight.netconf.dom.api.tx.NetconfDOMFieldsTransactionChain; +import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId; +import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Rpcs; import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences; import org.opendaylight.netconf.sal.connect.netconf.sal.tx.FieldsAwareReadOnlyTx; import org.opendaylight.netconf.sal.connect.netconf.sal.tx.FieldsAwareReadWriteTx; @@ -33,33 +35,30 @@ import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteCandidateRunning import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteCandidateTx; import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteRunningTx; import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps; -import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext; public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBroker { - private final NetconfDOMDataBrokerFieldsExtension fieldsExtension = new NetconfDOMDataBrokerFieldsExtensionImpl(); - private final RemoteDeviceId id; private final NetconfBaseOps netconfOps; private final boolean rollbackSupport; private final boolean candidateSupported; private final boolean runningWritable; + private final boolean lockDatastore; - private boolean isLockAllowed = true; - - public NetconfDeviceDataBroker(final RemoteDeviceId id, final MountPointContext mountContext, - final DOMRpcService rpc, final NetconfSessionPreferences netconfSessionPreferences) { + public NetconfDeviceDataBroker(final RemoteDeviceId id, final MountPointContext mountContext, final Rpcs rpcs, + final NetconfSessionPreferences netconfSessionPreferences, final boolean lockDatastore) { this.id = id; - this.netconfOps = new NetconfBaseOps(rpc, mountContext); + netconfOps = new NetconfBaseOps(rpcs, mountContext); // get specific attributes from netconf preferences and get rid of it // no need to keep the entire preferences object, its quite big with all the capability QNames candidateSupported = netconfSessionPreferences.isCandidateSupported(); runningWritable = netconfSessionPreferences.isRunningWritable(); rollbackSupport = netconfSessionPreferences.isRollbackSupported(); - Preconditions.checkArgument(candidateSupported || runningWritable, - "Device %s has advertised neither :writable-running nor :candidate capability." - + "At least one of these should be advertised. Failed to establish a session.", id.getName()); + checkArgument(candidateSupported || runningWritable, + "Device %s has advertised neither :writable-running nor :candidate capability. At least one of these " + + "should be advertised. Failed to establish a session.", id.name()); + this.lockDatastore = lockDatastore; } @Override @@ -76,12 +75,12 @@ public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBrok public DOMDataTreeWriteTransaction newWriteOnlyTransaction() { if (candidateSupported) { if (runningWritable) { - return new WriteCandidateRunningTx(id, netconfOps, rollbackSupport, isLockAllowed); + return new WriteCandidateRunningTx(id, netconfOps, rollbackSupport, lockDatastore); } else { - return new WriteCandidateTx(id, netconfOps, rollbackSupport, isLockAllowed); + return new WriteCandidateTx(id, netconfOps, rollbackSupport, lockDatastore); } } else { - return new WriteRunningTx(id, netconfOps, rollbackSupport, isLockAllowed); + return new WriteRunningTx(id, netconfOps, rollbackSupport, lockDatastore); } } @@ -95,10 +94,6 @@ public final class NetconfDeviceDataBroker implements PingPongMergingDOMDataBrok return ImmutableClassToInstanceMap.of(NetconfDOMDataBrokerFieldsExtension.class, fieldsExtension); } - void setLockAllowed(final boolean isLockAllowedOrig) { - this.isLockAllowed = isLockAllowedOrig; - } - private final class NetconfDOMDataBrokerFieldsExtensionImpl implements NetconfDOMDataBrokerFieldsExtension { @Override public NetconfDOMFieldsReadTransaction newReadOnlyTransaction() {