*/
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.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 boolean isLockAllowed = true;
+ private final boolean lockDatastore;
public NetconfDeviceDataBroker(final RemoteDeviceId id, final MountPointContext mountContext, final Rpcs rpcs,
- final NetconfSessionPreferences netconfSessionPreferences) {
+ final NetconfSessionPreferences netconfSessionPreferences, final boolean lockDatastore) {
this.id = id;
netconfOps = new NetconfBaseOps(rpcs, mountContext);
// get specific attributes from netconf preferences and get rid of it
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.getName());
+ this.lockDatastore = lockDatastore;
}
@Override
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);
}
}
return ImmutableClassToInstanceMap.of(NetconfDOMDataBrokerFieldsExtension.class, fieldsExtension);
}
- void setLockAllowed(final boolean isLockAllowedOrig) {
- isLockAllowed = isLockAllowedOrig;
- }
-
private final class NetconfDOMDataBrokerFieldsExtensionImpl implements NetconfDOMDataBrokerFieldsExtension {
@Override
public NetconfDOMFieldsReadTransaction newReadOnlyTransaction() {