<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
<scm>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-abstract class AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher implements DOMStoreTreeChangePublisher {
+abstract class AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher
+ implements DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMShardTreeChangePublisher.class);
}
@Override
- public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) {
+ public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) {
takeLock();
try {
return setupListenerContext(path, listener);
}
}
- private <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> setupListenerContext(final YangInstanceIdentifier listenerPath, final L listener) {
+ private <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ setupListenerContext(final YangInstanceIdentifier listenerPath, final L listener) {
// we need to register the listener registration path based on the shards root
// we have to strip the shard path from the listener path and then register
YangInstanceIdentifier strippedIdentifier = listenerPath;
strippedIdentifier = YangInstanceIdentifier.create(stripShardPath(listenerPath));
}
- final DOMDataTreeListenerWithSubshards subshardListener = new DOMDataTreeListenerWithSubshards(dataTree, strippedIdentifier, listener);
- final AbstractDOMDataTreeChangeListenerRegistration<L> reg = setupContextWithoutSubshards(strippedIdentifier, subshardListener);
+ final DOMDataTreeListenerWithSubshards subshardListener =
+ new DOMDataTreeListenerWithSubshards(dataTree, strippedIdentifier, listener);
+ final AbstractDOMDataTreeChangeListenerRegistration<L> reg =
+ setupContextWithoutSubshards(strippedIdentifier, subshardListener);
for (final ChildShardContext maybeAffected : childShards.values()) {
if (listenerPath.contains(maybeAffected.getPrefix().getRootIdentifier())) {
subshardListener.addSubshard(maybeAffected);
} else if (maybeAffected.getPrefix().getRootIdentifier().contains(listenerPath)) {
// bind path is inside subshard
- // TODO can this happen? seems like in ShardedDOMDataTree we are already registering to the lowest shard possible
- throw new UnsupportedOperationException("Listener should be registered directly into initialDataChangeEvent subshard");
+ // TODO can this happen? seems like in ShardedDOMDataTree we are
+ // already registering to the lowest shard possible
+ throw new UnsupportedOperationException("Listener should be registered directly "
+ + "into initialDataChangeEvent subshard");
}
}
return reg;
}
- private <L extends DOMDataTreeChangeListener> void initialDataChangeEvent(final YangInstanceIdentifier listenerPath, final L listener) {
+ private <L extends DOMDataTreeChangeListener> void initialDataChangeEvent(
+ final YangInstanceIdentifier listenerPath, final L listener) {
// FIXME Add support for wildcard listeners
final Optional<NormalizedNode<?, ?>> preExistingData = dataTree.takeSnapshot()
.readNode(YangInstanceIdentifier.create(stripShardPath(listenerPath)));
return nodeBuilder.build();
}
- private <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> setupContextWithoutSubshards(final YangInstanceIdentifier listenerPath, final DOMDataTreeListenerWithSubshards listener) {
+ private <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ setupContextWithoutSubshards(final YangInstanceIdentifier listenerPath,
+ final DOMDataTreeListenerWithSubshards listener) {
LOG.debug("Registering root listener at {}", listenerPath);
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node = findNodeFor(listenerPath.getPathArguments());
- final AbstractDOMDataTreeChangeListenerRegistration<L> registration = new AbstractDOMDataTreeChangeListenerRegistration<L>((L) listener) {
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node =
+ findNodeFor(listenerPath.getPathArguments());
+ final AbstractDOMDataTreeChangeListenerRegistration<L> registration =
+ new AbstractDOMDataTreeChangeListenerRegistration<L>((L) listener) {
@Override
protected void removeRegistration() {
listener.close();
final DOMStoreTreeChangePublisher listenableShard = (DOMStoreTreeChangePublisher) context.getShard();
// since this is going into subshard we want to listen for ALL changes in the subshard
registrations.put(context.getPrefix().getRootIdentifier(),
- listenableShard.registerTreeChangeListener(context.getPrefix().getRootIdentifier(),
- changes -> onDataTreeChanged(context.getPrefix().getRootIdentifier(), changes)));
+ listenableShard.registerTreeChangeListener(
+ context.getPrefix().getRootIdentifier(), changes -> onDataTreeChanged(
+ context.getPrefix().getRootIdentifier(), changes)));
}
void close() {
*/
package org.opendaylight.mdsal.dom.store.inmemory;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
-
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
final class ChainedTransactionCommitImpl extends InMemoryDOMStoreThreePhaseCommitCohort {
private final DOMStoreTransactionChainImpl txChain;
- ChainedTransactionCommitImpl(final InMemoryDOMDataStore store, final SnapshotBackedWriteTransaction<String> transaction,
- final DataTreeModification modification, final DOMStoreTransactionChainImpl txChain) {
+ ChainedTransactionCommitImpl(final InMemoryDOMDataStore store,
+ final SnapshotBackedWriteTransaction<String> transaction,final DataTreeModification modification,
+ final DOMStoreTransactionChainImpl txChain) {
super(store, transaction, modification);
this.txChain = Preconditions.checkNotNull(txChain);
}
/**
* Finish this transaction and submit it for processing.
*
+ *<p>
* FIXME: this method should accept a callback which will report success/failure. Let's not use a CheckedFuture
* due to overhead associated with attaching listeners to them.
* @throws IllegalStateException if this transaction has an unclosed cursor.
*/
package org.opendaylight.mdsal.dom.store.inmemory;
+import com.google.common.base.Preconditions;
import org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
-
-import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
}
@Override
- protected DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<String> tx, final DataTreeModification modification) {
+ protected DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<String> tx,
+ final DataTreeModification modification) {
return new ChainedTransactionCommitImpl(store, tx, modification, this);
}
return new DataTreeModificationCursorAdaptor(dataTreeCursor);
}
- protected final DataTreeModificationCursor delegate() {
+ @Override
+ protected DataTreeModificationCursor delegate() {
return delegate;
}
delegate.enter(child);
}
+ @Override
+ public void enter(final Iterable<PathArgument> path) {
+ delegate.enter(path);
+ }
+
+ @Override
+ public void enter(final PathArgument... path) {
+ delegate.enter(path);
+ }
+
@Override
public void merge(final PathArgument child, final NormalizedNode<?, ?> data) {
delegate.merge(child, data);
delegate.write(child, data);
}
- @Override
- public void enter(final Iterable<PathArgument> path) {
- delegate.enter(path);
- }
-
@Override
public void exit() {
delegate.exit();
delegate.close();
}
- @Override
- public void enter(final PathArgument... path) {
- delegate.enter(path);
- }
}
* Operation performed to exit current logical level, default implementation calls
* {@link DOMDataTreeWriteCursor#exit()} on underlaying cursor.
*
+ *<p>
* Subclasses may override this to customize exit strategy.
*
*/
private final DOMDataTreeIdentifier prefix;
private final ForeignShardModificationContext shard;
- public ForeignShardThreePhaseCommitCohort(final DOMDataTreeIdentifier prefix, final ForeignShardModificationContext shard) {
+ public ForeignShardThreePhaseCommitCohort(final DOMDataTreeIdentifier prefix,
+ final ForeignShardModificationContext shard) {
this.prefix = prefix;
this.shard = shard;
}
*/
package org.opendaylight.mdsal.dom.store.inmemory;
+import com.google.common.base.Preconditions;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import com.google.common.base.Preconditions;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.ExecutorServiceUtil;
import org.slf4j.LoggerFactory;
/**
- * In-memory DOM Data Store
+ * In-memory DOM Data Store.
*
+ *<p>
* Implementation of {@link DOMStore} which uses {@link DataTree} and other
* classes such as {@link SnapshotBackedWriteTransaction}.
* {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} to implement {@link DOMStore}
* contract.
*
*/
-public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> implements DOMStore, Identifiable<String>, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
+public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> implements DOMStore,
+ Identifiable<String>, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
private volatile AutoCloseable closeable;
public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor) {
- this(name, dataChangeListenerExecutor, InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false);
+ this(name, dataChangeListenerExecutor,
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false);
}
public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor,
this.name = Preconditions.checkNotNull(name);
this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor);
this.debugTransactions = debugTransactions;
- changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor, maxDataChangeListenerQueueSize);
+ changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor,
+ maxDataChangeListenerQueueSize);
}
public void setCloseable(final AutoCloseable closeable) {
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return SnapshotBackedTransactions.newReadTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot());
+ return SnapshotBackedTransactions.newReadTransaction(
+ nextIdentifier(),debugTransactions, dataTree.takeSnapshot());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return SnapshotBackedTransactions.newReadWriteTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot(), this);
+ return SnapshotBackedTransactions.newReadWriteTransaction(nextIdentifier(),
+ debugTransactions, dataTree.takeSnapshot(), this);
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return SnapshotBackedTransactions.newWriteTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot(), this);
+ return SnapshotBackedTransactions.newWriteTransaction(nextIdentifier(),
+ debugTransactions, dataTree.takeSnapshot(), this);
}
@Override
dataTree.setSchemaContext(ctx);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void close() {
ExecutorServiceUtil.tryGracefulShutdown(dataChangeListenerExecutor, 30, TimeUnit.SECONDS);
- if(closeable != null) {
+ if (closeable != null) {
try {
closeable.close();
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.debug("Error closing instance", e);
}
}
}
@Override
- public synchronized <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
+ public synchronized <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ final YangInstanceIdentifier treeId, final L listener) {
/*
* Make sure commit is not occurring right now. Listener has to be
* registered and its state capture enqueued at a consistent point.
}
@Override
- protected DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction<String> tx, final DataTreeModification modification) {
+ protected DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction<String> tx,
+ final DataTreeModification modification) {
LOG.debug("Tx: {} is submitted. Modifications: {}", tx.getIdentifier(), modification);
return new InMemoryDOMStoreThreePhaseCommitCohort(this, tx, modification);
}
/**
* Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the
- * {@link InMemoryDOMDataStoreFactory}
+ * {@link InMemoryDOMDataStoreFactory}.
*
* @author Thomas Pantelis
* @see InMemoryDOMDataStoreFactory
*/
package org.opendaylight.mdsal.dom.store.inmemory;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-
import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
/**
private static final class SubshardProducerSpecification {
private final Collection<DOMDataTreeIdentifier> prefixes = new ArrayList<>(1);
private final ChildShardContext shard;
+
SubshardProducerSpecification(final ChildShardContext subshard) {
this.shard = Preconditions.checkNotNull(subshard);
}
final TreeType treeType = treeTypeFor(prefix.getDatastoreType());
this.dataTree = InMemoryDataTreeFactory.getInstance().create(treeType, prefix.getRootIdentifier());
- this.shardChangePublisher = new InMemoryDOMDataTreeShardChangePublisher(dataTreeChangeExecutor, maxDataChangeListenerQueueSize, dataTree, prefix.getRootIdentifier(), childShards);
+ this.shardChangePublisher = new InMemoryDOMDataTreeShardChangePublisher(dataTreeChangeExecutor,
+ maxDataChangeListenerQueueSize, dataTree, prefix.getRootIdentifier(), childShards);
this.executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
- public static InMemoryDOMDataTreeShard create(final DOMDataTreeIdentifier id, final ExecutorService dataTreeChangeExecutor,
- final int maxDataChangeListenerQueueSize) {
+ public static InMemoryDOMDataTreeShard create(final DOMDataTreeIdentifier id,
+ final ExecutorService dataTreeChangeExecutor, final int maxDataChangeListenerQueueSize) {
return new InMemoryDOMDataTreeShard(id, dataTreeChangeExecutor, maxDataChangeListenerQueueSize);
}
@Nonnull
@Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(@Nonnull final YangInstanceIdentifier treeId, @Nonnull final L listener) {
+ public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ @Nonnull final YangInstanceIdentifier treeId, @Nonnull final L listener) {
return shardChangePublisher.registerTreeChangeListener(treeId, listener);
}
}
private void reparentChildShards(final DOMDataTreeIdentifier newChildPrefix, final DOMDataTreeShard newChild) {
- final Iterator<Entry<DOMDataTreeIdentifier, ChildShardContext>> actualChildren = childShards.entrySet().iterator();
+ final Iterator<Entry<DOMDataTreeIdentifier, ChildShardContext>> actualChildren =
+ childShards.entrySet().iterator();
final Map<DOMDataTreeIdentifier, ChildShardContext> reparented = new HashMap<>();
while (actualChildren.hasNext()) {
final Entry<DOMDataTreeIdentifier, ChildShardContext> actualChild = actualChildren.next();
throw new UnsupportedOperationException();
}
- private static ChildShardContext createContextFor(final DOMDataTreeIdentifier prefix, final DOMDataTreeShard child) {
+ private static ChildShardContext createContextFor(final DOMDataTreeIdentifier prefix,
+ final DOMDataTreeShard child) {
Preconditions.checkArgument(child instanceof WriteableDOMDataTreeShard,
"Child %s is not a writable shared", child);
return new ChildShardContext(prefix, (WriteableDOMDataTreeShard) child);
return ret;
}
- InmemoryDOMDataTreeShardWriteTransaction createTransaction(final InmemoryDOMDataTreeShardWriteTransaction previousTx) {
+ InmemoryDOMDataTreeShardWriteTransaction createTransaction(
+ final InmemoryDOMDataTreeShardWriteTransaction previousTx) {
// FIXME: implement this
throw new UnsupportedOperationException();
}
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShardChangePublisher.class);
- private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
- (listener, notification) -> {
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(ImmutableList.of(notification));
- }
- };
+ private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
+ MANAGER_INVOKER = (listener, notification) -> {
+ final DOMDataTreeChangeListener inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataTreeChanged(ImmutableList.of(notification));
+ }
+ };
- private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> notificationManager;
+ private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>,
+ DataTreeCandidate> notificationManager;
InMemoryDOMDataTreeShardChangePublisher(final ExecutorService executorService,
final int maxQueueSize,
final YangInstanceIdentifier rootPath,
final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
super(dataTree, rootPath, childShards);
- notificationManager = new QueuedNotificationManager<>(executorService, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr");
+ notificationManager = new QueuedNotificationManager<>(
+ executorService, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr");
}
@Override
- protected void notifyListeners(@Nonnull final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
+ protected void notifyListeners(
+ @Nonnull final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
@Nonnull final YangInstanceIdentifier path,
@Nonnull final DataTreeCandidateNode node) {
final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node);
}
- public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(YangInstanceIdentifier path, L listener) {
+ public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ registerTreeChangeListener(YangInstanceIdentifier path, L listener) {
return super.registerTreeChangeListener(path, listener);
}
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collections;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
this.changePublisher = Preconditions.checkNotNull(changePublisher);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public ListenableFuture<Boolean> canCommit() {
try {
LOG.warn("Data validation failed for {}", modification);
LOG.trace("dataTree : {}", dataTree);
- return Futures.immediateFailedFuture(new TransactionCommitFailedException("Data did not pass validation.", e));
+ return Futures.immediateFailedFuture(new TransactionCommitFailedException(
+ "Data did not pass validation.", e));
} catch (Exception e) {
LOG.warn("Unexpected failure in validation phase", e);
return Futures.immediateFailedFuture(e);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public ListenableFuture<Void> preCommit() {
try {
import static com.google.common.base.Preconditions.checkState;
-import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
-
-import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
private final InMemoryDOMDataStore store;
private DataTreeCandidate candidate;
- public InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store, final SnapshotBackedWriteTransaction<String> writeTransaction, final DataTreeModification modification) {
+ InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store,
+ final SnapshotBackedWriteTransaction<String> writeTransaction, final DataTreeModification modification) {
this.transaction = Preconditions.checkNotNull(writeTransaction);
this.modification = Preconditions.checkNotNull(modification);
this.store = Preconditions.checkNotNull(store);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public final ListenableFuture<Boolean> canCommit() {
try {
// For debugging purposes, allow dumping of the modification. Coupled with the above
// precondition log, it should allow us to understand what went on.
- LOG.trace("Store Tx: {} modifications: {} tree: {}", getTransaction().getIdentifier(), modification, store);
+ LOG.trace("Store Tx: {} modifications: {} tree: {}", getTransaction().getIdentifier(),
+ modification, store);
- return Futures.immediateFailedFuture(new TransactionCommitFailedException("Data did not pass validation.", e));
+ return Futures.immediateFailedFuture(
+ new TransactionCommitFailedException("Data did not pass validation.", e));
} catch (Exception e) {
LOG.warn("Unexpected failure in validation phase", e);
return Futures.immediateFailedFuture(e);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public final ListenableFuture<Void> preCommit() {
try {
*/
package org.opendaylight.mdsal.dom.store.inmemory;
-import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
-
-import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import com.google.common.base.Optional;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
+import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.Invoker;
final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
new Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>() {
- @Override
- public void invokeListener(final AbstractDOMDataTreeChangeListenerRegistration<?> listener, final DataTreeCandidate notification) {
- // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(Collections.singletonList(notification));
- }
- }
- };
+ @Override
+ public void invokeListener(final AbstractDOMDataTreeChangeListenerRegistration<?> listener,
+ final DataTreeCandidate notification) {
+ // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
+ final DOMDataTreeChangeListener inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataTreeChanged(Collections.singletonList(notification));
+ }
+ }
+ };
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
- private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> notificationManager;
+
+ private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
+ notificationManager;
InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
- notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr");
+ notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize,
+ "DataTreeChangeListenerQueueMgr");
}
@Override
- protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations, final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
+ protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
+ final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node);
for (AbstractDOMDataTreeChangeListenerRegistration<?> reg : registrations) {
}
@Override
- protected synchronized void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
+ protected synchronized void registrationRemoved(
+ final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
LOG.debug("Closing registration {}", registration);
// FIXME: remove the queue for this registration and make sure we clear it
}
- <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
+ <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
final AbstractDOMDataTreeChangeListenerRegistration<L> reg = registerTreeChangeListener(treeId, listener);
final Optional<NormalizedNode<?, ?>> node = snapshot.readNode(treeId);
InmemoryDOMDataTreeShardWriteTransaction(final ShardDataModification root,
final DataTree rootShardDataTree,
- final InMemoryDOMDataTreeShardChangePublisher changePublisher, final ListeningExecutorService executor) {
+ final InMemoryDOMDataTreeShardChangePublisher changePublisher,
+ final ListeningExecutorService executor) {
this.modification = Preconditions.checkNotNull(root);
this.rootShardDataTree = Preconditions.checkNotNull(rootShardDataTree);
this.changePublisher = Preconditions.checkNotNull(changePublisher);
LOG.debug("Readying open transaction on shard {}", modification.getPrefix());
rootModification = modification.seal();
- cohorts.add(new InMemoryDOMDataTreeShardThreePhaseCommitCohort(rootShardDataTree, rootModification, changePublisher));
- for (final Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry : modification.getChildShards().entrySet()) {
+ cohorts.add(new InMemoryDOMDataTreeShardThreePhaseCommitCohort(
+ rootShardDataTree, rootModification, changePublisher));
+ for (final Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry :
+ modification.getChildShards().entrySet()) {
cohorts.add(new ForeignShardThreePhaseCommitCohort(entry.getKey(), entry.getValue()));
}
finished = true;
Preconditions.checkNotNull(cohorts);
Preconditions.checkState(!cohorts.isEmpty(), "Transaction was not readied yet.");
- final ListenableFuture<Void> submit = executor.submit(new ShardSubmitCoordinationTask(modification.getPrefix(), cohorts));
+ final ListenableFuture<Void> submit = executor.submit(new ShardSubmitCoordinationTask(
+ modification.getPrefix(), cohorts));
return submit;
}
public ListenableFuture<Boolean> validate() {
LOG.debug("CanCommit on open transaction on shard {}", modification.getPrefix());
- final ListenableFuture<Boolean> submit = executor.submit(new ShardCanCommitCoordinationTask(modification.getPrefix(), cohorts));
+ final ListenableFuture<Boolean> submit = executor.submit(new ShardCanCommitCoordinationTask(
+ modification.getPrefix(), cohorts));
return submit;
}
public ListenableFuture<Void> prepare() {
LOG.debug("PreCommit on open transaction on shard {}", modification.getPrefix());
- final ListenableFuture<Void> submit = executor.submit(new ShardPreCommitCoordinationTask(modification.getPrefix(), cohorts));
+ final ListenableFuture<Void> submit = executor.submit(new ShardPreCommitCoordinationTask(
+ modification.getPrefix(), cohorts));
return submit;
}
public ListenableFuture<Void> commit() {
LOG.debug("Commit open transaction on shard {}", modification.getPrefix());
- final ListenableFuture<Void> submit = executor.submit(new ShardCommitCoordinationTask(modification.getPrefix(), cohorts));
+ final ListenableFuture<Void> submit = executor.submit(new ShardCommitCoordinationTask(
+ modification.getPrefix(), cohorts));
return submit;
}
interface ReadableCursorOperation extends CursorStrategy {
- abstract Optional<NormalizedNode<?, ?>> readNode(PathArgument arg);
+ Optional<NormalizedNode<?, ?>> readNode(PathArgument arg);
}
\ No newline at end of file
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
/**
- * Marker interface for readable/writeable DOMDataTreeShard
+ * Marker interface for readable/writeable DOMDataTreeShard.
*/
@Beta
public interface ReadableWriteableDOMDataTreeShard extends DOMStoreTreeChangePublisher, WriteableDOMDataTreeShard {
import org.slf4j.LoggerFactory;
/**
- * Task that coordinates the CanCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ * Task that coordinates the CanCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s.
*/
@Beta
public class ShardCanCommitCoordinationTask implements Callable<Boolean> {
private ListenableFuture<?>[] canCommitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.canCommit();
+ ops[index++] = cohort.canCommit();
}
return ops;
}
import org.slf4j.LoggerFactory;
/**
- * Task that coordinates the Commit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ * Task that coordinates the Commit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s.
*/
@Beta
public class ShardCommitCoordinationTask implements Callable<Void> {
private ListenableFuture<?>[] commitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.commit();
+ ops[index++] = cohort.commit();
}
return ops;
}
private final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards =
new HashMap<>();
- public ShardDataModificationBuilder(final ShardRootModificationContext root) {
+ ShardDataModificationBuilder(final ShardRootModificationContext root) {
this.root = root;
}
private final Deque<WriteCursorStrategy> stack = new ArrayDeque<>();
private final InmemoryDOMDataTreeShardWriteTransaction parent;
- ShardDataModificationCursor(final ShardDataModification root, final InmemoryDOMDataTreeShardWriteTransaction parent) {
+ ShardDataModificationCursor(final ShardDataModification root,
+ final InmemoryDOMDataTreeShardWriteTransaction parent) {
stack.push(root.createOperation(null));
this.parent = Preconditions.checkNotNull(parent);
}
+ private WriteCursorStrategy getCurrent() {
+ return stack.peek();
+ }
+
@Override
public void enter(final PathArgument child) {
WriteCursorStrategy nextOp = getCurrent().enter(child);
stack.push(nextOp);
}
- private WriteCursorStrategy getCurrent() {
- return stack.peek();
- }
-
@Override
public void enter(final PathArgument... path) {
for (PathArgument pathArgument : path) {
import org.slf4j.LoggerFactory;
/**
- * Task that coordinates the PreCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ * Task that coordinates the PreCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s.
*/
@Beta
-public class ShardPreCommitCoordinationTask implements Callable<Void>{
+public class ShardPreCommitCoordinationTask implements Callable<Void> {
private static final Logger LOG = LoggerFactory.getLogger(ShardPreCommitCoordinationTask.class);
private ListenableFuture<?>[] preCommitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int i = 0;
+ int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[i++] = cohort.preCommit();
+ ops[index++] = cohort.preCommit();
}
return ops;
}
private final PathArgument identifier;
- public WritableInteriorNode(PathArgument identifier, Map<PathArgument, WriteableModificationNode> children) {
+ WritableInteriorNode(PathArgument identifier, Map<PathArgument, WriteableModificationNode> children) {
super(children);
this.identifier = Preconditions.checkNotNull(identifier);
}
interface WriteCursorStrategy extends CursorStrategy {
@Override
- abstract WriteCursorStrategy enter(PathArgument arg);
+ WriteCursorStrategy enter(PathArgument arg);
- abstract void delete(PathArgument arg);
+ void delete(PathArgument arg);
- abstract void merge(PathArgument arg, NormalizedNode<?, ?> data);
+ void merge(PathArgument arg, NormalizedNode<?, ?> data);
- abstract void write(PathArgument arg, NormalizedNode<?, ?> data);
+ void write(PathArgument arg, NormalizedNode<?, ?> data);
- abstract void mergeToCurrent(NormalizedNodeContainer<?, ?, ?> data);
+ void mergeToCurrent(NormalizedNodeContainer<?, ?, ?> data);
- abstract void writeToCurrent(NormalizedNodeContainer<?, ?, ?> data);
+ void writeToCurrent(NormalizedNodeContainer<?, ?, ?> data);
}
\ No newline at end of file
abstract class WriteableModificationNode implements Identifiable<PathArgument> {
/**
- *
* Gets child which is on path towards subshard.
*
* @return null if requested child is not subshard or enclosing node of any subshard.
abstract Map<PathArgument, WriteableModificationNode> getChildrenWithSubshards();
/**
- * Creates operation used to modify this node and its children
+ * Creates operation used to modify this node and its children.
*
* @param parentCursor Cursor associated with parent shard
* @return WriteableOperation for this node.
private final Map<PathArgument, WriteableModificationNode> children;
- public WriteableNodeWithSubshard(Map<PathArgument, WriteableModificationNode> children) {
+ WriteableNodeWithSubshard(Map<PathArgument, WriteableModificationNode> children) {
this.children = ImmutableMap.copyOf(children);
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
-
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
assertNotNull(writeTx);
/**
- * Writes /test in writeTx
+ * Writes /test in writeTx.
*/
NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
writeTx.write(TestModel.TEST_PATH, testNode);
assertNotNull(writeTx);
/**
- * Writes /test in writeTx
+ * Writes /test in writeTx.
*/
NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
writeTx.write(TestModel.TEST_PATH, testNode);
assertThreePhaseCommit( writeTx.ready() );
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
+ Optional<NormalizedNode<?, ?>> afterCommitRead =
+ domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH ).get();
assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() );
// Delete /test and verify
assertThreePhaseCommit( writeTx.ready() );
- afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
+ afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH ).get();
assertEquals( "After commit read: isPresent", false, afterCommitRead.isPresent() );
}
assertThreePhaseCommit( writeTx.ready() );
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
+ Optional<NormalizedNode<?, ?>> afterCommitRead =
+ domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH ).get();
assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() );
assertEquals( "After commit read: data", containerNode, afterCommitRead.get() );
assertEquals(false, exists.checkedGet());
}
- @Test(expected=ReadFailedException.class)
+ @Test(expected = ReadFailedException.class)
public void testExistsThrowsReadFailedException() throws Exception {
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
}
-
- @Test(expected=ReadFailedException.class)
+ @SuppressWarnings("checkstyle:IllegalThrows")
+ @Test(expected = ReadFailedException.class)
public void testReadWithReadOnlyTransactionClosed() throws Throwable {
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
doReadAndThrowEx( readTx );
}
- @Test(expected=ReadFailedException.class)
+ @SuppressWarnings("checkstyle:IllegalThrows")
+ @Test(expected = ReadFailedException.class)
public void testReadWithReadOnlyTransactionFailure() throws Throwable {
DataTreeSnapshot mockSnapshot = Mockito.mock( DataTreeSnapshot.class );
doReadAndThrowEx( readTx );
}
- @Test(expected=ReadFailedException.class)
+ @SuppressWarnings("checkstyle:IllegalThrows")
+ @Test(expected = ReadFailedException.class)
public void testReadWithReadWriteTransactionClosed() throws Throwable {
DOMStoreReadTransaction readTx = domStore.newReadWriteTransaction();
doReadAndThrowEx( readTx );
}
- @Test(expected=ReadFailedException.class)
+ @SuppressWarnings("checkstyle:IllegalThrows")
+ @Test(expected = ReadFailedException.class)
public void testReadWithReadWriteTransactionFailure() throws Throwable {
DataTreeSnapshot mockSnapshot = Mockito.mock( DataTreeSnapshot.class );
Mockito.doReturn( mockModification ).when( mockSnapshot ).newModification();
@SuppressWarnings("unchecked")
TransactionReadyPrototype<String> mockReady = Mockito.mock( TransactionReadyPrototype.class );
- DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot, mockReady);
+ DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction(
+ "1", false, mockSnapshot, mockReady);
doReadAndThrowEx( readTx );
}
+ @SuppressWarnings("checkstyle:IllegalThrows")
private static void doReadAndThrowEx( final DOMStoreReadTransaction readTx ) throws Throwable {
try {
readTx.read(TestModel.TEST_PATH).get();
- } catch( ExecutionException e ) {
+ } catch ( ExecutionException e ) {
throw e.getCause();
}
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testWriteWithTransactionReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
writeTx.write( TestModel.TEST_PATH, ImmutableNodes.containerNode( TestModel.TEST_QNAME ) );
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testReadyWithTransactionAlreadyReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(txChain);
/**
- * We alocate new read-write transaction and write /test
- *
- *
+ * We alocate new read-write transaction and write /test.
*/
DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
assertTestContainerWrite(firstTx);
/**
* First transaction is marked as ready, we are able to allocate chained
- * transactions
+ * transactions.
*/
- DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
+ final DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
/**
* We alocate chained transaction - read transaction, note first one is
DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
/**
- *
* We test if we are able to read data from tx, read should not fail
* since we are using chained transaction.
- *
- *
*/
assertTestContainerExists(secondReadTx);
/**
- *
* We alocate next transaction, which is still based on first one, but
* is read-write.
- *
*/
DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
- *
- *
*/
assertTestContainerExists(thirdDeleteTx);
/**
- * We delete node in third transaction
+ * We delete node in third transaction.
*/
thirdDeleteTx.delete(TestModel.TEST_PATH);
DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
/**
- * We commit first transaction
+ * We commit first transaction.
*
*/
assertThreePhaseCommit(firstWriteTxCohort);
import static org.junit.Assert.assertNotNull;
-import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
-
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
* then triggering update of global schema context
* and then performing write (according to new module).
*
+ *<p>
* If transaction between allocation and schema context was
* unmodified, it is safe to change its schema context
* to new one (e.g. it will be same as if allocated after
* schema context update.)
*
- * @throws InterruptedException
- * @throws ExecutionException
+ *<p>
+ * @throws InterruptedException when this condition met
+ * @throws ExecutionException when execution fails
*/
@Ignore
@Test
import java.util.concurrent.ExecutorService;
/**
- * A forwarding Executor used by unit tests for DataChangeListener notifications
+ * A forwarding Executor used by unit tests for DataChangeListener notifications.
*
* @author Thomas Pantelis
*/
super(DATA_TREE, YANG_INSTANCE_IDENTIFIER, CHILD_SHARDS);
}
- private AbstractDOMShardTreeChangePublisherTest(final Map<DOMDataTreeIdentifier, ChildShardContext> childShardContextMap) {
+ private AbstractDOMShardTreeChangePublisherTest(
+ final Map<DOMDataTreeIdentifier, ChildShardContext> childShardContextMap) {
super(DATA_TREE, YANG_INSTANCE_IDENTIFIER, childShardContextMap);
}
@Override
- protected void notifyListeners(@Nonnull final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
- @Nonnull final YangInstanceIdentifier path, @Nonnull final DataTreeCandidateNode node) {
+ protected void notifyListeners(
+ @Nonnull final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
+ @Nonnull final YangInstanceIdentifier path, @Nonnull final DataTreeCandidateNode node) {
// NOOP
}
verify(IN_MEMORY_DOM_DATA_STORE).validate(any());
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = OptimisticLockFailedException.class)
public void canCommitTestWithOptimisticLockFailedException() throws Throwable {
doThrow(new ConflictingModificationAppliedException(YangInstanceIdentifier.EMPTY, "testException"))
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = TransactionCommitFailedException.class)
public void canCommitTestWithTransactionCommitFailedException() throws Throwable {
doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "testException"))
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = UnsupportedOperationException.class)
public void canCommitTestWithUnknownException() throws Throwable {
doThrow(new UnsupportedOperationException("testException"))
verify(IN_MEMORY_DOM_DATA_STORE).prepare(any());
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = UnsupportedOperationException.class)
public void preCommitTestWithUnknownException() throws Throwable {
doThrow(new UnsupportedOperationException("testException"))
inmemoryDOMDataTreeShardWriteTransaction =
new InmemoryDOMDataTreeShardWriteTransaction(shardDataModification, DATA_TREE,
- inMemoryDOMDataTreeShardChangePublisher, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
+ inMemoryDOMDataTreeShardChangePublisher,
+ MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
}
@Test
@Test
public void basicTest() throws Exception {
- ShardSubmitCoordinationTask shardSubmitCoordinationTask =
+ final ShardSubmitCoordinationTask shardSubmitCoordinationTask =
new ShardSubmitCoordinationTask(DOM_DATA_TREE_IDENTIFIER, Collections.EMPTY_SET);
final ShardCanCommitCoordinationTask canCommitCoordinationTask = mock(ShardCanCommitCoordinationTask.class);
resetMocks();
}
- public WriteableNodeOperationTest(){
+ public WriteableNodeOperationTest() {
super(WRITEABLE_MODIFICATION_NODE, DOM_DATA_TREE_WRITE_CURSOR);
}