2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
10 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
11 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
12 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfRpcFutureCallback;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
17 * Tx implementation for netconf devices that support only candidate datastore and writable running.
18 * The sequence goes exactly as with only candidate supported, with one addition:
20 * <li>Running datastore is locked as the first thing and this lock has to succeed</li>
23 public class WriteCandidateRunningTx extends WriteCandidateTx {
24 private static final Logger LOG = LoggerFactory.getLogger(WriteCandidateRunningTx.class);
26 public WriteCandidateRunningTx(final RemoteDeviceId id, final NetconfBaseOps netOps,
27 final boolean rollbackSupport) {
28 this(id, netOps, rollbackSupport, true);
31 public WriteCandidateRunningTx(final RemoteDeviceId id, final NetconfBaseOps netconfOps,
32 final boolean rollbackSupport, final boolean isLockAllowed) {
33 super(id, netconfOps, rollbackSupport, isLockAllowed);
37 protected synchronized void init() {
43 protected void cleanupOnSuccess() {
44 super.cleanupOnSuccess();
48 private void lockRunning() {
50 resultsFutures.add(netOps.lockRunning(new NetconfRpcFutureCallback("Lock running", id)));
52 LOG.trace("Lock is not allowed: {}", id);
57 * This has to be non blocking since it is called from a callback on commit
58 * and its netty threadpool that is really sensitive to blocking calls.
60 private void unlockRunning() {
62 netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id));
64 LOG.trace("Unlock is not allowed: {}", id);