* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Optional;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.netconf.api.ModifyAction;
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;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
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(final RemoteDeviceId id, final NetconfBaseOps netconfOps, final boolean rollbackSupport,
+ final boolean isLockAllowed) {
+ super(id, netconfOps, rollbackSupport, isLockAllowed);
}
@Override
}
private void lock() {
- final FutureCallback<DOMRpcResult> lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
+ if (!isLockAllowed) {
+ LOG.trace("Lock is not allowed.");
+ return;
+ }
+ final var lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
@Override
public void onSuccess(final DOMRpcResult result) {
if (isSuccess(result)) {
LOG.trace("Lock candidate successful");
}
} else {
- LOG.warn("{}: lock candidate invoked unsuccessfully: {}", id, result.getErrors());
+ LOG.warn("{}: lock candidate invoked unsuccessfully: {}", id, result.errors());
}
}
@Override
public void onFailure(final Throwable throwable) {
- LOG.warn("Lock candidate operation failed. {}", throwable);
+ LOG.warn("Lock candidate operation failed", throwable);
discardChanges();
}
};
}
@Override
- protected void editConfig(final YangInstanceIdentifier path,
- final Optional<NormalizedNode<?, ?>> data,
- final DataContainerChild<?, ?> editStructure,
- final Optional<ModifyAction> defaultOperation,
+ protected void editConfig(final YangInstanceIdentifier path, final Optional<NormalizedNode> data,
+ final DataContainerChild editStructure, final Optional<ModifyAction> defaultOperation,
final String operation) {
final NetconfRpcFutureCallback editConfigCallback = new NetconfRpcFutureCallback("Edit candidate", id);
* 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);
+ }
}
-
}