Change-Id: Ifc0955a9dcd162879681cb30ef925b05f37a1fd6
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
32 files changed:
package org.opendaylight.controller.md.sal.dom.broker.spi.mount;
package org.opendaylight.controller.md.sal.dom.broker.spi.mount;
+import com.google.common.base.Optional;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMService;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMService;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.base.Optional;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-
-public class SimpleDOMMountPoint implements DOMMountPoint {
+public final class SimpleDOMMountPoint implements DOMMountPoint {
private final YangInstanceIdentifier identifier;
private final ClassToInstanceMap<DOMService> services;
private final SchemaContext schemaContext;
private final YangInstanceIdentifier identifier;
private final ClassToInstanceMap<DOMService> services;
private final SchemaContext schemaContext;
- public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
+ public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
+ final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
return new SimpleDOMMountPoint(identifier, services, ctx);
}
return new SimpleDOMMountPoint(identifier, services, ctx);
}
- private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
+
+ private SimpleDOMMountPoint(final YangInstanceIdentifier identifier,
+ final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
this.identifier = identifier;
this.services = ImmutableClassToInstanceMap.copyOf(services);
this.schemaContext = ctx;
this.identifier = identifier;
this.services = ImmutableClassToInstanceMap.copyOf(services);
this.schemaContext = ctx;
- * Returns leaf QName in which RPC Route is stored
- *
+ * Returns leaf QName in which RPC Route is stored.
*
* @return leaf QName in which RPC Route is stored
* @throws UnsupportedOperationException If RPC is not content routed.
*
* @return leaf QName in which RPC Route is stored
* @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
+ * ({@link #isContextBasedRouted()} returned <code>false</code>)
*/
public abstract QName getLeaf();
/**
*/
public abstract QName getLeaf();
/**
- * Returns identity QName which represents RPC Routing context
+ * Returns identity QName which represents RPC Routing context.
*
* @return identity QName which represents RPC Routing context
* @throws UnsupportedOperationException If RPC is not content routed.
*
* @return identity QName which represents RPC Routing context
* @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
+ * ({@link #isContextBasedRouted()} returned <code>false</code>)
*/
public abstract QName getContext();
*/
public abstract QName getContext();
private static final class GlobalRpcStrategy extends RpcRoutingStrategy {
private static final class GlobalRpcStrategy extends RpcRoutingStrategy {
- public GlobalRpcStrategy(final QName identifier) {
+ GlobalRpcStrategy(final QName identifier) {
*
* @param <T> type of listener
*/
*
* @param <T> type of listener
*/
-public abstract class AbstractDOMDataTreeChangeListenerRegistration<T extends DOMDataTreeChangeListener> extends AbstractListenerRegistration<T> {
+public abstract class AbstractDOMDataTreeChangeListenerRegistration<T extends DOMDataTreeChangeListener>
+ extends AbstractListenerRegistration<T> {
protected AbstractDOMDataTreeChangeListenerRegistration(final T listener) {
super(listener);
}
protected AbstractDOMDataTreeChangeListenerRegistration(final T listener) {
super(listener);
}
/**
* Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
*/
/**
* Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
*/
-public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
+public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation>
+ extends AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
protected AbstractDOMRpcImplementationRegistration(final T instance) {
super(instance);
}
protected AbstractDOMRpcImplementationRegistration(final T instance) {
super(instance);
}
*/
public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
@Override
*/
public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
@Override
- public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ final T implementation, final DOMRpcIdentifier... types) {
return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
}
}
return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
}
}
* @param node Tree node
* @param registration Registration instance
*/
* @param node Tree node
* @param registration Registration instance
*/
- protected final void removeRegistration(@Nonnull final RegistrationTreeNode<T> node, @Nonnull final T registration) {
+ protected final void removeRegistration(@Nonnull final RegistrationTreeNode<T> node,
+ @Nonnull final T registration) {
// Take the write lock
rwLock.writeLock().lock();
try {
// Take the write lock
rwLock.writeLock().lock();
try {
public interface DOMNotificationSubscriptionListener extends EventListener {
/**
public interface DOMNotificationSubscriptionListener extends EventListener {
/**
- * Invoked when notification subscription changed
+ * Invoked when notification subscription changed.
- * @param currentTypes Set of notification types
- * for which listeners are registered.
+ * @param currentTypes Set of notification types for which listeners are registered.
*/
void onSubscriptionChanged(Set<SchemaPath> currentTypes);
*/
void onSubscriptionChanged(Set<SchemaPath> currentTypes);
* Utility {@link DOMDataReadOnlyTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
* Utility {@link DOMDataReadOnlyTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
-public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject implements DOMDataReadOnlyTransaction {
+public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject
+ implements DOMDataReadOnlyTransaction {
@Override
protected abstract @Nonnull DOMDataReadOnlyTransaction delegate();
@Override
@Override
protected abstract @Nonnull DOMDataReadOnlyTransaction delegate();
@Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
return delegate().read(store, path);
}
@Override
return delegate().read(store, path);
}
@Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
return delegate().exists(store, path);
}
return delegate().exists(store, path);
}
* Utility {@link DOMDataReadWriteTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
* Utility {@link DOMDataReadWriteTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
-public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject implements DOMDataReadWriteTransaction {
+public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject
+ implements DOMDataReadWriteTransaction {
@Override
protected abstract @Nonnull DOMDataReadWriteTransaction delegate();
@Override
@Override
protected abstract @Nonnull DOMDataReadWriteTransaction delegate();
@Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
return delegate().read(store, path);
}
@Override
return delegate().read(store, path);
}
@Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
return delegate().exists(store, path);
}
return delegate().exists(store, path);
}
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().put(store, path, data);
}
@Override
delegate().put(store, path, data);
}
@Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().merge(store, path, data);
}
delegate().merge(store, path, data);
}
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().put(store, path, data);
}
@Override
delegate().put(store, path, data);
}
@Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().merge(store, path, data);
}
delegate().merge(store, path, data);
}
* Utility implementations of {@link DOMNotificationPublishService} which forwards
* all requests to a delegate instance.
*/
* Utility implementations of {@link DOMNotificationPublishService} which forwards
* all requests to a delegate instance.
*/
-public abstract class ForwardingDOMNotificationPublishService extends ForwardingObject implements DOMNotificationPublishService {
+public abstract class ForwardingDOMNotificationPublishService extends ForwardingObject
+ implements DOMNotificationPublishService {
@Override
protected abstract DOMNotificationPublishService delegate();
@Override
protected abstract DOMNotificationPublishService delegate();
protected abstract @Nonnull DOMRpcImplementation delegate();
@Override
protected abstract @Nonnull DOMRpcImplementation delegate();
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier type, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier type,
+ final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}
}
return delegate().invokeRpc(type, input);
}
}
protected abstract @Nonnull DOMRpcProviderService delegate();
@Override
protected abstract @Nonnull DOMRpcProviderService delegate();
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ final T implementation, final DOMRpcIdentifier... types) {
return delegate().registerRpcImplementation(implementation, types);
}
@Override
return delegate().registerRpcImplementation(implementation, types);
}
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final Set<DOMRpcIdentifier> types) {
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ final T implementation, final Set<DOMRpcIdentifier> types) {
return delegate().registerRpcImplementation(implementation, types);
}
}
return delegate().registerRpcImplementation(implementation, types);
}
}
protected abstract @Nonnull DOMRpcService delegate();
@Override
protected abstract @Nonnull DOMRpcService delegate();
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
+ final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}
return delegate().invokeRpc(type, input);
}
package org.opendaylight.controller.sal.core.spi;
import java.util.Set;
package org.opendaylight.controller.sal.core.spi;
import java.util.Set;
-
-import org.opendaylight.controller.sal.core.api.BrokerService;
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
+import org.opendaylight.controller.sal.core.api.BrokerService;
import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;
import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;
import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality;
import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality;
/**
* Abstract DOM Store Transaction.
*
/**
* Abstract DOM Store Transaction.
*
* Convenience super implementation of DOM Store transaction which provides
* common implementation of {@link #toString()} and {@link #getIdentifier()}.
*
* Convenience super implementation of DOM Store transaction which provides
* common implementation of {@link #toString()} and {@link #getIdentifier()}.
*
* It can optionally capture the context where it was allocated.
*
* @param <T> identifier type
* It can optionally capture the context where it was allocated.
*
* @param <T> identifier type
/**
* Abstract base class for {@link DOMStoreTreeChangePublisher} implementations.
*/
/**
* Abstract base class for {@link DOMStoreTreeChangePublisher} implementations.
*/
-public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>> implements DOMStoreTreeChangePublisher {
+public abstract class AbstractDOMStoreTreeChangePublisher
+ extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>>
+ implements DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class);
/**
private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class);
/**
- * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is guaranteed
- * to be only called from within {@link #processCandidateTree(DataTreeCandidate)}.
+ * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is
+ * guaranteed to be only called from within {@link #processCandidateTree(DataTreeCandidate)}.
*
* @param registrations Registrations which are affected by the candidate node
* @param path Path of changed candidate node. Guaranteed to match the path specified by the registration
* @param node Candidate node
*/
*
* @param registrations Registrations which are affected by the candidate node
* @param path Path of changed candidate node. Guaranteed to match the path specified by the registration
* @param node Candidate node
*/
- protected abstract void notifyListeners(@Nonnull Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node);
+ protected abstract void notifyListeners(@Nonnull Collection<AbstractDOMDataTreeChangeListenerRegistration<?>>
+ registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node);
/**
* Callback notifying the subclass that the specified registration is being closed and it's user no longer
/**
* Callback notifying the subclass that the specified registration is being closed and it's user no longer
- * wishes to receive notifications. This notification is invoked while the {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()}
+ * wishes to receive notifications. This notification is invoked while the
+ * {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()}
* method is executing. Subclasses can use this callback to properly remove any delayed notifications pending
* towards the registration.
*
* method is executing. Subclasses can use this callback to properly remove any delayed notifications pending
* towards the registration.
*
- try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
+ try (RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate);
}
}
@Override
lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate);
}
}
@Override
- public final <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
+ public final <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
// Take the write lock
takeLock();
try {
// Take the write lock
takeLock();
try {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node = findNodeFor(treeId.getPathArguments());
- final AbstractDOMDataTreeChangeListenerRegistration<L> reg = new AbstractDOMDataTreeChangeListenerRegistration<L>(listener) {
- @Override
- protected void removeRegistration() {
- AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this);
- registrationRemoved(this);
- }
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node =
+ findNodeFor(treeId.getPathArguments());
+ final AbstractDOMDataTreeChangeListenerRegistration<L> reg =
+ new AbstractDOMDataTreeChangeListenerRegistration<L>(listener) {
+ @Override
+ protected void removeRegistration() {
+ AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this);
+ registrationRemoved(this);
+ }
};
addRegistration(node, reg);
};
addRegistration(node, reg);
- private void lookupAndNotify(final List<PathArgument> args, final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node, final DataTreeCandidate candidate) {
+ private void lookupAndNotify(final List<PathArgument> args, final int offset,
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node,
+ final DataTreeCandidate candidate) {
if (args.size() != offset) {
final PathArgument arg = args.get(offset);
if (args.size() != offset) {
final PathArgument arg = args.get(offset);
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild = node.getExactChild(arg);
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild =
+ node.getExactChild(arg);
if (exactChild != null) {
lookupAndNotify(args, offset + 1, exactChild, candidate);
}
if (exactChild != null) {
lookupAndNotify(args, offset + 1, exactChild, candidate);
}
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c : node.getInexactChildren(arg)) {
+ for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c :
+ node.getInexactChildren(arg)) {
lookupAndNotify(args, offset + 1, c, candidate);
}
} else {
lookupAndNotify(args, offset + 1, c, candidate);
}
} else {
- private void notifyNode(final YangInstanceIdentifier path, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode, final DataTreeCandidateNode candNode) {
+ private void notifyNode(final YangInstanceIdentifier path,
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode,
+ final DataTreeCandidateNode candNode) {
if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
LOG.debug("Skipping unmodified candidate {}", path);
return;
if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
LOG.debug("Skipping unmodified candidate {}", path);
return;
for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild = regNode.getExactChild(candChild.getIdentifier());
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild =
+ regNode.getExactChild(candChild.getIdentifier());
if (regChild != null) {
notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
}
if (regChild != null) {
notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
}
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc : regNode.getInexactChildren(candChild.getIdentifier())) {
+ for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc :
+ regNode.getInexactChildren(candChild.getIdentifier())) {
notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
}
}
notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
}
}
import org.slf4j.LoggerFactory;
/**
import org.slf4j.LoggerFactory;
/**
- * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot} supplier
- * and backend commit coordinator.
+ * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot}
+ * supplier and backend commit coordinator.
*
* @param <T> transaction identifier type
*/
@Beta
*
* @param <T> transaction identifier type
*/
@Beta
-public abstract class AbstractSnapshotBackedTransactionChain<T> extends TransactionReadyPrototype<T> implements DOMStoreTransactionChain {
- private static abstract class State {
+public abstract class AbstractSnapshotBackedTransactionChain<T> extends TransactionReadyPrototype<T>
+ implements DOMStoreTransactionChain {
+ private abstract static class State {
/**
* Allocate a new snapshot.
*
/**
* Allocate a new snapshot.
*
@Override
protected DataTreeSnapshot getSnapshot(Object transactionId) {
final DataTreeSnapshot ret = snapshot;
@Override
protected DataTreeSnapshot getSnapshot(Object transactionId) {
final DataTreeSnapshot ret = snapshot;
- Preconditions.checkState(ret != null, "Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
+ Preconditions.checkState(ret != null,
+ "Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
transactionId, transaction.getIdentifier());
return ret;
}
void setSnapshot(final DataTreeSnapshot snapshot) {
final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
transactionId, transaction.getIdentifier());
return ret;
}
void setSnapshot(final DataTreeSnapshot snapshot) {
final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
- Preconditions.checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier());
+ Preconditions.checkState(success, "Transaction %s has already been marked as ready",
+ transaction.getIdentifier());
}
private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) {
}
private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) {
- final State state = new Allocated(transaction);
- return STATE_UPDATER.compareAndSet(this, expected, state);
+ final State localState = new Allocated(transaction);
+ return STATE_UPDATER.compareAndSet(this, expected, localState);
if (allocated.getTransaction().equals(tx)) {
final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState);
if (!success) {
if (allocated.getTransaction().equals(tx)) {
final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState);
if (!success) {
- LOG.warn("Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange",
+ LOG.warn(
+ "Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange",
tx, this, localState, state);
}
}
tx, this, localState, state);
}
}
if (localState instanceof Allocated) {
final Allocated allocated = (Allocated)localState;
final DOMStoreWriteTransaction transaction = allocated.getTransaction();
if (localState instanceof Allocated) {
final Allocated allocated = (Allocated)localState;
final DOMStoreWriteTransaction transaction = allocated.getTransaction();
- Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx, transaction);
+ Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s",
+ tx, transaction);
allocated.setSnapshot(tree);
} else {
LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
allocated.setSnapshot(tree);
} else {
LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
}
if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) {
}
if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) {
- LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", this, localState, state);
+ LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle",
+ this, localState, state);
* @param transaction Transaction which failed.
* @param cause Failure cause
*/
* @param transaction Transaction which failed.
* @param cause Failure cause
*/
- protected final void onTransactionFailed(final SnapshotBackedWriteTransaction<T> transaction, final Throwable cause) {
+ protected final void onTransactionFailed(final SnapshotBackedWriteTransaction<T> transaction,
+ final Throwable cause) {
LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause);
state = FAILED;
}
LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause);
state = FAILED;
}
* @param operationError Any previous error that could be reported through three phase commit
* @return A {@link DOMStoreThreePhaseCommitCohort} cohort.
*/
* @param operationError Any previous error that could be reported through three phase commit
* @return A {@link DOMStoreThreePhaseCommitCohort} cohort.
*/
- protected abstract DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<T> transaction,
- final DataTreeModification modification,
- final Exception operationError);
+ protected abstract DOMStoreThreePhaseCommitCohort createCohort(SnapshotBackedWriteTransaction<T> transaction,
+ DataTreeModification modification,
+ Exception operationError);
* DOM Data Store provides transactional tree-like storage for YANG-modeled
* entities described by YANG schema and represented by {@link NormalizedNode}.
*
* DOM Data Store provides transactional tree-like storage for YANG-modeled
* entities described by YANG schema and represented by {@link NormalizedNode}.
*
* Read and write access to stored data is provided only via transactions
* created using {@link #newReadOnlyTransaction()},
* {@link #newWriteOnlyTransaction()} and {@link #newReadWriteTransaction()}, or
* Read and write access to stored data is provided only via transactions
* created using {@link #newReadOnlyTransaction()},
* {@link #newWriteOnlyTransaction()} and {@link #newReadWriteTransaction()}, or
public interface DOMStore extends DOMStoreTransactionFactory {
/**
public interface DOMStore extends DOMStoreTransactionFactory {
/**
- * Registers {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener} for Data Change callbacks which will
- * be triggered on the change of provided subpath. What constitutes a change
+ * Registers {@link org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener} for Data Change
+ * callbacks which will be triggered on the change of provided subpath. What constitutes a change
* depends on the @scope parameter.
*
* Listener upon registration receives an initial callback
* depends on the @scope parameter.
*
* Listener upon registration receives an initial callback
- * {@link AsyncDataChangeListener#onDataChanged(org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent)}
+ * {@link AsyncDataChangeListener#onDataChanged(org.opendaylight.controller.md.sal.common.api.data
+ * .AsyncDataChangeEvent)}
* which contains stable view of data tree at the time of registration.
*
* Â @param path Path (subtree identifier) on which client listener will be
* which contains stable view of data tree at the time of registration.
*
* Â @param path Path (subtree identifier) on which client listener will be
* registration / interest on receiving data changes.
*
*/
* registration / interest on receiving data changes.
*
*/
- <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(
- YangInstanceIdentifier path, L listener, DataChangeScope scope);
+ <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L>
+ registerChangeListener(YangInstanceIdentifier path, L listener, DataChangeScope scope);
* Creates new transaction chain.
*
* Creates new transaction chain.
*
* Transactions in a chain need to be committed in sequence and each
* transaction should see the effects of previous transactions as if they
* happened.
*
* Transactions in a chain need to be committed in sequence and each
* transaction should see the effects of previous transactions as if they
* happened.
*
- * See {@link DOMStoreTransactionChain} for more information.
- *
+ * @see DOMStoreTransactionChain for more information.
* @return Newly created transaction chain.
*/
DOMStoreTransactionChain createTransactionChain();
* @return Newly created transaction chain.
*/
DOMStoreTransactionChain createTransactionChain();
*/
package org.opendaylight.controller.sal.core.spi.data;
*/
package org.opendaylight.controller.sal.core.spi.data;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-
public interface DOMStoreReadTransaction extends DOMStoreTransaction {
/**
public interface DOMStoreReadTransaction extends DOMStoreTransaction {
/**
- * Reads data from provided logical data store located at provided path
+ * Reads data from provided logical data store located at provided path.
*
* @param path
* Path which uniquely identifies subtree which client want to
*
* @param path
* Path which uniquely identifies subtree which client want to
/**
* Checks if data is available in the logical data store located at provided path.
/**
* Checks if data is available in the logical data store located at provided path.
* Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
* will succeed. It is possible that the data resides in a data store on a remote node and, if that
* node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
* Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
* will succeed. It is possible that the data resides in a data store on a remote node and, if that
* node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
/**
* Initiates a pre-commit phase of associated transaction on datastore.
*
/**
* Initiates a pre-commit phase of associated transaction on datastore.
*
* This message is valid only and only if and only if the participant responded
* on {@link #canCommit()} call with positive response.
*
* This message is valid only and only if and only if the participant responded
* on {@link #canCommit()} call with positive response.
*
import org.opendaylight.yangtools.concepts.Identifiable;
/**
import org.opendaylight.yangtools.concepts.Identifiable;
/**
- * DOM Data Store transaction
- *
- * See {@link DOMStoreReadTransaction}, {@link DOMStoreWriteTransaction} and {@link DOMStoreReadWriteTransaction}
- * for specific transaction types.
+ * DOM Data Store transaction.
+ * @see DOMStoreReadTransaction
+ * @see DOMStoreWriteTransaction
+ * @see DOMStoreReadWriteTransaction
*/
public interface DOMStoreTransaction extends AutoCloseable, Identifiable<Object> {
/**
*/
public interface DOMStoreTransaction extends AutoCloseable, Identifiable<Object> {
/**
- * Unique identifier of the transaction
+ * Unique identifier of the transaction.
*/
@Override
Object getIdentifier();
*/
@Override
Object getIdentifier();
* Create a new read only transaction which will continue the chain. The
* previous write transaction has to be either READY or CANCELLED.
*
* Create a new read only transaction which will continue the chain. The
* previous write transaction has to be either READY or CANCELLED.
*
* If previous write transaction was already commited to data store, new
* read-only transaction is same as obtained via {@link DOMStore#newReadOnlyTransaction()}
* and contains merged result of previous one and current state of data store.
*
* If previous write transaction was already commited to data store, new
* read-only transaction is same as obtained via {@link DOMStore#newReadOnlyTransaction()}
* and contains merged result of previous one and current state of data store.
*
* Otherwise read-only transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
* Otherwise read-only transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
* Create a new read write transaction which will continue the chain. The
* previous read-write transaction has to be either COMMITED or CANCELLED.
*
* Create a new read write transaction which will continue the chain. The
* previous read-write transaction has to be either COMMITED or CANCELLED.
*
* If previous write transaction was already commited to data store, new
* read-write transaction is same as obtained via {@link DOMStore#newReadWriteTransaction()}
* and contains merged result of previous one and current state of data store.
*
* If previous write transaction was already commited to data store, new
* read-write transaction is same as obtained via {@link DOMStore#newReadWriteTransaction()}
* and contains merged result of previous one and current state of data store.
*
* Otherwise read-write transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
* Otherwise read-write transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
/**
* Closes Transaction Chain.
*
/**
* Closes Transaction Chain.
*
* Close method of transaction chain does not guarantee that
* last alocated transaction is ready or was submitted.
*
* Close method of transaction chain does not guarantee that
* last alocated transaction is ready or was submitted.
*
* Underlying {@link DOMStore} or {@link DOMStoreTransactionChain}.
*
* <p>
* Underlying {@link DOMStore} or {@link DOMStoreTransactionChain}.
*
* <p>
- * See {@link DOMStore} or {@link DOMStoreTransactionChain} for concrete
- * variations of this factory.
+ * See DOMStore, DOMStoreTransactionChain for concrete variations of this factory.
*
* <p>
* <b>Note:</b> This interface is used only to define common functionality
*
* <p>
* <b>Note:</b> This interface is used only to define common functionality
public interface DOMStoreTransactionFactory {
/**
public interface DOMStoreTransactionFactory {
/**
- *
- * Creates a read only transaction
+ * Creates a read only transaction.
*
* <p>
* Creates a new read-only transaction, which provides read access to
* snapshot of current state.
*
*
* <p>
* Creates a new read-only transaction, which provides read access to
* snapshot of current state.
*
- * See {@link DOMStoreReadTransaction} for more information.
- *
+ * @see DOMStoreReadTransaction for more information.
* @return new {@link DOMStoreReadTransaction}
* @throws IllegalStateException
* If state of factory prevents allocating new transaction.
* @return new {@link DOMStoreReadTransaction}
* @throws IllegalStateException
* If state of factory prevents allocating new transaction.
DOMStoreReadTransaction newReadOnlyTransaction();
/**
DOMStoreReadTransaction newReadOnlyTransaction();
/**
- * Creates write only transaction
- *
- * <p>
- * See {@link DOMStoreWriteTransaction} for more information.
+ * Creates write only transaction.
+ * @see DOMStoreWriteTransaction for more information.
* @return new {@link DOMStoreWriteTransaction}
* @throws IllegalStateException If state of factory prevents allocating new transaction.
*/
DOMStoreWriteTransaction newWriteOnlyTransaction();
/**
* @return new {@link DOMStoreWriteTransaction}
* @throws IllegalStateException If state of factory prevents allocating new transaction.
*/
DOMStoreWriteTransaction newWriteOnlyTransaction();
/**
- * Creates Read-Write transaction
- *
- * <p>
- * See {@link DOMStoreReadWriteTransaction} for more information.
+ * Creates Read-Write transaction.
+ * @see DOMStoreReadWriteTransaction for more information.
* @return new {@link DOMStoreWriteTransaction}
* @throws IllegalStateException If state of factory prevents allocating new transaction.
*/
* @return new {@link DOMStoreWriteTransaction}
* @throws IllegalStateException If state of factory prevents allocating new transaction.
*/
* Registers a {@link DOMDataTreeChangeListener} to receive
* notifications when data changes under a given path in the conceptual data
* tree.
* Registers a {@link DOMDataTreeChangeListener} to receive
* notifications when data changes under a given path in the conceptual data
* tree.
* <p>
* You are able to register for notifications for any node or subtree
* which can be represented using {@link YangInstanceIdentifier}.
* <p>
* You are able to register for notifications for any node or subtree
* which can be represented using {@link YangInstanceIdentifier}.
* You are able to register for data change notifications for a subtree or leaf
* even if it does not exist. You will receive notification once that node is
* created.
* You are able to register for data change notifications for a subtree or leaf
* even if it does not exist. You will receive notification once that node is
* created.
* <p>
* If there is any pre-existing data in data tree on path for which you are
* registering, you will receive initial data change event, which will
* <p>
* If there is any pre-existing data in data tree on path for which you are
* registering, you will receive initial data change event, which will
* This method returns a {@link ListenerRegistration} object. To
* "unregister" your listener for changes call the {@link ListenerRegistration#close()}
* method on this returned object.
* This method returns a {@link ListenerRegistration} object. To
* "unregister" your listener for changes call the {@link ListenerRegistration#close()}
* method on this returned object.
* <p>
* You MUST explicitly unregister your listener when you no longer want to receive
* notifications. This is especially true in OSGi environments, where failure to
* <p>
* You MUST explicitly unregister your listener when you no longer want to receive
* notifications. This is especially true in OSGi environments, where failure to
* your listener using {@link ListenerRegistration#close()} to stop
* delivery of change events.
*/
* your listener using {@link ListenerRegistration#close()} to stop
* delivery of change events.
*/
- @Nonnull <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(@Nonnull YangInstanceIdentifier treeId, @Nonnull L listener);
+ @Nonnull <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ @Nonnull YangInstanceIdentifier treeId, @Nonnull L listener);
* operation, which is to say that whole subtree will be replaced by
* specified path.
*
* operation, which is to say that whole subtree will be replaced by
* specified path.
*
* If you need add or merge of current object with specified use
* {@link #merge(YangInstanceIdentifier, NormalizedNode)}.
*
* If you need add or merge of current object with specified use
* {@link #merge(YangInstanceIdentifier, NormalizedNode)}.
*
- *
- * @param path
- * @param data
- * Data object to be written
- *
+ * @param path the path to write
+ * @param data data object to be written
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
* operation, which is to say that whole subtree will be replaced by
* specified path.
*
* operation, which is to say that whole subtree will be replaced by
* specified path.
*
- * @param path
- * @param data
- * Data object to be written
- *
+ * @param path the path to write
+ * @param data data object to be written
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
/**
void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
/**
* Deletes data and whole subtree located at provided path.
*
* Deletes data and whole subtree located at provided path.
*
- * @param path
- * Path to delete
+ * @param path path to delete
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
* @throws IllegalStateException
* if the client code already sealed transaction and invoked
* {@link #ready()}
void delete(YangInstanceIdentifier path);
/**
void delete(YangInstanceIdentifier path);
/**
* Seals transaction, and returns three-phase commit cohort associated
* with this transaction and DOM Store to be coordinated by coordinator.
*
* Seals transaction, and returns three-phase commit cohort associated
* with this transaction and DOM Store to be coordinated by coordinator.
*
* which forward most of their functionality to a backend {@link #delegate()}.
*/
@Beta
* which forward most of their functionality to a backend {@link #delegate()}.
*/
@Beta
-public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject implements DOMStoreThreePhaseCommitCohort {
+public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject
+ implements DOMStoreThreePhaseCommitCohort {
@Override
protected abstract DOMStoreThreePhaseCommitCohort delegate();
@Override
protected abstract DOMStoreThreePhaseCommitCohort delegate();
import org.slf4j.LoggerFactory;
/**
import org.slf4j.LoggerFactory;
/**
+ * Implementation of read-only transaction backed by {@link DataTreeSnapshot}.
- * Implementation of read-only transaction backed by {@link DataTreeSnapshot}
- *
* Implementation of read-only transaction backed by {@link DataTreeSnapshot}
* which delegates most of its calls to similar methods provided by underlying snapshot.
*
* @param <T> identifier type
*/
@Beta
* Implementation of read-only transaction backed by {@link DataTreeSnapshot}
* which delegates most of its calls to similar methods provided by underlying snapshot.
*
* @param <T> identifier type
*/
@Beta
-public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTransaction<T> implements DOMStoreReadTransaction {
+public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTransaction<T>
+ implements DOMStoreReadTransaction {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class);
private volatile DataTreeSnapshot stableSnapshot;
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class);
private volatile DataTreeSnapshot stableSnapshot;
+ @SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
try {
return Futures.immediateCheckedFuture(Optional.fromJavaUtil(snapshot.readNode(path)));
try {
return Futures.immediateCheckedFuture(Optional.fromJavaUtil(snapshot.readNode(path)));
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
}
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
}
package org.opendaylight.controller.sal.core.spi.data;
import static com.google.common.base.Preconditions.checkNotNull;
package org.opendaylight.controller.sal.core.spi.data;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
* @param <T> identifier type
*/
@Beta
* @param <T> identifier type
*/
@Beta
-public final class SnapshotBackedReadWriteTransaction<T> extends SnapshotBackedWriteTransaction<T> implements DOMStoreReadWriteTransaction {
+public final class SnapshotBackedReadWriteTransaction<T> extends SnapshotBackedWriteTransaction<T>
+ implements DOMStoreReadWriteTransaction {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class);
SnapshotBackedReadWriteTransaction(final T identifier, final boolean debug,
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class);
SnapshotBackedReadWriteTransaction(final T identifier, final boolean debug,
+ @SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
final Optional<NormalizedNode<?, ?>> result;
try {
result = readSnapshotNode(path);
final Optional<NormalizedNode<?, ?>> result;
try {
result = readSnapshotNode(path);
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e));
}
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e));
}
* @param debug Enable transaction debugging
* @param snapshot Snapshot which will be modified.
*/
* @param debug Enable transaction debugging
* @param snapshot Snapshot which will be modified.
*/
- public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot) {
+ public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug,
+ final DataTreeSnapshot snapshot) {
return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot);
}
return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot);
}
* @param snapshot Snapshot which will be modified.
* @param readyImpl Implementation of ready method.
*/
* @param snapshot Snapshot which will be modified.
* @param readyImpl Implementation of ready method.
*/
- public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
+ public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier,
+ final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl);
}
return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl);
}
* @param <T> Identifier type
*/
@Beta
* @param <T> Identifier type
*/
@Beta
-public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransaction<T> implements DOMStoreWriteTransaction {
+public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransaction<T>
+ implements DOMStoreWriteTransaction {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedWriteTransaction.class);
@SuppressWarnings("rawtypes")
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedWriteTransaction.class);
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, TransactionReadyPrototype> READY_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, TransactionReadyPrototype.class, "readyImpl");
+ private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, TransactionReadyPrototype>
+ READY_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
+ TransactionReadyPrototype.class, "readyImpl");
@SuppressWarnings("rawtypes")
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, DataTreeModification> TREE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, DataTreeModification.class, "mutableTree");
+ private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, DataTreeModification>
+ TREE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
+ DataTreeModification.class, "mutableTree");
// non-null when not ready
private volatile TransactionReadyPrototype<T> readyImpl;
// non-null when not ready
private volatile TransactionReadyPrototype<T> readyImpl;
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
try {
tree.write(path, data);
// FIXME: Add checked exception
try {
tree.write(path, data);
// FIXME: Add checked exception
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
try {
tree.merge(path, data);
// FIXME: Add checked exception
try {
tree.merge(path, data);
// FIXME: Add checked exception
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void delete(final YangInstanceIdentifier path) {
checkNotReady();
public void delete(final YangInstanceIdentifier path) {
checkNotReady();
try {
tree.delete(path);
// FIXME: Add checked exception
try {
tree.delete(path);
// FIXME: Add checked exception
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
return readyImpl == null ? null : Optional.fromJavaUtil(mutableTree.readNode(path));
}
return readyImpl == null ? null : Optional.fromJavaUtil(mutableTree.readNode(path));
}
- private final void checkNotReady() {
+ private void checkNotReady() {
checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.",
getIdentifier());
}
@Override
checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.",
getIdentifier());
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public DOMStoreThreePhaseCommitCohort ready() {
@SuppressWarnings("unchecked")
final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null);
public DOMStoreThreePhaseCommitCohort ready() {
@SuppressWarnings("unchecked")
final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null);
- * This class is intended to be implemented by Transaction factories
- * responsible for allocation of {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction} and
+ * This class is intended to be implemented by Transaction factories responsible for allocation of
+ * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction} and
* providing underlying logic for applying implementation.
*
* @param <T> identifier type
* providing underlying logic for applying implementation.
*
* @param <T> identifier type
*
* @param tx Transaction which got aborted.
*/
*
* @param tx Transaction which got aborted.
*/
- protected abstract void transactionAborted(final SnapshotBackedWriteTransaction<T> tx);
+ protected abstract void transactionAborted(SnapshotBackedWriteTransaction<T> tx);
/**
* Returns a commit coordinator associated with supplied transactions.
*
/**
* Returns a commit coordinator associated with supplied transactions.
*
* This call must not fail.
*
* @param tx
* This call must not fail.
*
* @param tx
package org.opendaylight.controller.sal.core.spi.data.statistics;
import java.util.concurrent.ExecutorService;
package org.opendaylight.controller.sal.core.spi.data.statistics;
import java.util.concurrent.ExecutorService;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
/**
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
/**
*
* @param dclExecutor the executor
*/
*
* @param dclExecutor the executor
*/
- void setDataChangeListenerExecutor( @Nonnull ExecutorService dclExecutor );
+ void setDataChangeListenerExecutor(@Nonnull ExecutorService dclExecutor);
/**
* Sets the executor used internally by the data store.
*
* @param dsExecutor the executor
*/
/**
* Sets the executor used internally by the data store.
*
* @param dsExecutor the executor
*/
- void setDataStoreExecutor( @Nonnull ExecutorService dsExecutor );
+ void setDataStoreExecutor(@Nonnull ExecutorService dsExecutor);
- * Sets the QueuedNotificationManager use for DataChangeListener notifications,
+ * Sets the QueuedNotificationManager use for DataChangeListener notifications.
*
* @param manager the manager
*/
*
* @param manager the manager
*/
- void setNotificationManager( @Nonnull QueuedNotificationManager<?, ?> manager );
+ void setNotificationManager(@Nonnull QueuedNotificationManager<?, ?> manager);