package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfRpcFutureCallback;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
private static final Logger LOG = LoggerFactory.getLogger(WriteCandidateTx.class);
- public WriteCandidateTx(final RemoteDeviceId id, final NetconfBaseOps rpc, final boolean rollbackSupport) {
- super(rpc, id, rollbackSupport);
+ public WriteCandidateTx(final RemoteDeviceId id, final NetconfBaseOps netconfOps, final boolean rollbackSupport) {
+ this(id, netconfOps, rollbackSupport, true);
+ }
+
+ public WriteCandidateTx(RemoteDeviceId id, NetconfBaseOps netconfOps, boolean rollbackSupport,
+ boolean isLockAllowed) {
+ super(id, netconfOps, rollbackSupport, isLockAllowed);
}
@Override
}
private void lock() {
+ if (!isLockAllowed) {
+ LOG.trace("Lock is not allowed.");
+ return;
+ }
final FutureCallback<DOMRpcResult> lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
@Override
public void onSuccess(@Nonnull final DOMRpcResult result) {
@Override
public void onFailure(final Throwable throwable) {
- LOG.warn("Lock candidate operation failed. {}", throwable);
+ LOG.warn("Lock candidate operation failed", throwable);
discardChanges();
}
};
* and its netty threadpool that is really sensitive to blocking calls.
*/
private void unlock() {
- netOps.unlockCandidate(new NetconfRpcFutureCallback("Unlock candidate", id));
+ if (isLockAllowed) {
+ netOps.unlockCandidate(new NetconfRpcFutureCallback("Unlock candidate", id));
+ } else {
+ LOG.trace("Unlock is not allowed: {}", id);
+ }
}
}