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%2Ftx%2FWriteRunningTx.java;fp=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2Ftx%2FWriteRunningTx.java;h=0000000000000000000000000000000000000000;hb=22cb88b09661d3a13bfb8ed6d31cc4ad4c6c5a4a;hp=ee60c2ad98f86baf2faacea4ba1e086b4cb27d6e;hpb=0009fbaa0f1c512295711e7b65f0adad9e43554e;p=netconf.git
diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java
deleted file mode 100644
index ee60c2ad98..0000000000
--- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.ListenableFuture;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-import org.opendaylight.netconf.api.EffectiveOperation;
-import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
-import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
-import org.opendaylight.netconf.sal.connect.netconf.util.NetconfRpcFutureCallback;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Tx implementation for netconf devices that support only writable-running with no candidate.
- * The sequence goes as:
- *
- * - Lock running datastore on tx construction
- *
- * - Lock has to succeed, if it does not, transaction is failed
- *
- *
- * - Edit-config in running N times
- *
- * - If any issue occurs during edit, datastore is unlocked and an exception is thrown
- *
- *
- * - Unlock running datastore on tx commit
- *
- */
-public class WriteRunningTx extends AbstractWriteTx {
-
- private static final Logger LOG = LoggerFactory.getLogger(WriteRunningTx.class);
- private final List changes = new ArrayList<>();
-
- public WriteRunningTx(final RemoteDeviceId id, final NetconfBaseOps netOps,
- final boolean rollbackSupport) {
- this(id, netOps, rollbackSupport, true);
- }
-
- public WriteRunningTx(final RemoteDeviceId id, final NetconfBaseOps netconfOps, final boolean rollbackSupport,
- final boolean isLockAllowed) {
- super(id, netconfOps, rollbackSupport, isLockAllowed);
- }
-
- @Override
- protected synchronized void init() {
- lock();
- }
-
- private void lock() {
- if (isLockAllowed) {
- resultsFutures.add(netOps.lockRunning(new NetconfRpcFutureCallback("Lock running", id)));
- } else {
- LOG.trace("Lock is not allowed: {}", id);
- }
- }
-
- @Override
- protected void cleanup() {
- unlock();
- }
-
- @Override
- public synchronized ListenableFuture> performCommit() {
- for (final Change change : changes) {
- resultsFutures.add(change.execute(id, netOps, rollbackSupport));
- }
- unlock();
- return resultsToTxStatus();
- }
-
- @Override
- protected void editConfig(final YangInstanceIdentifier path, final Optional data,
- final DataContainerChild editStructure,
- final Optional defaultOperation,
- final String operation) {
- changes.add(new Change(editStructure, defaultOperation));
- }
-
- private void unlock() {
- if (isLockAllowed) {
- netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id));
- } else {
- LOG.trace("Unlock is not allowed: {}", id);
- }
- }
-
- private static final class Change {
-
- private final DataContainerChild editStructure;
- private final Optional defaultOperation;
-
- Change(final DataContainerChild editStructure, final Optional defaultOperation) {
- this.editStructure = editStructure;
- this.defaultOperation = defaultOperation;
- }
-
- ListenableFuture extends DOMRpcResult> execute(final RemoteDeviceId id, final NetconfBaseOps netOps,
- final boolean rollbackSupport) {
- final NetconfRpcFutureCallback editConfigCallback = new NetconfRpcFutureCallback("Edit running", id);
- if (defaultOperation.isPresent()) {
- return netOps.editConfigRunning(editConfigCallback, editStructure, defaultOperation.get(),
- rollbackSupport);
- } else {
- return netOps.editConfigRunning(editConfigCallback, editStructure, rollbackSupport);
- }
- }
- }
-}