*
* @return Logical data store type. Guaranteed to be non-null.
*/
- public @Nonnull LogicalDatastoreType getDatastoreType() {
+ @Nonnull
+ public LogicalDatastoreType getDatastoreType() {
return datastoreType;
}
*
* @return Instance identifier corresponding to the root node.
*/
- public @Nonnull YangInstanceIdentifier getRootIdentifier() {
+ @Nonnull
+ public YangInstanceIdentifier getRootIdentifier() {
return rootIdentifier;
}
public class DOMDataTreeLoopException extends Exception {
private static final long serialVersionUID = 1L;
- public DOMDataTreeLoopException(final @Nonnull String message) {
+ public DOMDataTreeLoopException(@Nonnull final String message) {
super(message);
}
- public DOMDataTreeLoopException(final @Nonnull String message, final @Nonnull Throwable cause) {
+ public DOMDataTreeLoopException(@Nonnull final String message, @Nonnull final Throwable cause) {
super(message, cause);
}
}
public class DOMDataTreeShardingConflictException extends Exception {
private static final long serialVersionUID = 1L;
- public DOMDataTreeShardingConflictException(final @Nonnull String message) {
+ public DOMDataTreeShardingConflictException(@Nonnull final String message) {
super(message);
}
- public DOMDataTreeShardingConflictException(final @Nonnull String message, final @Nonnull Throwable cause) {
+ public DOMDataTreeShardingConflictException(@Nonnull final String message, @Nonnull final Throwable cause) {
super(message, cause);
}
}
*/
public abstract class DOMRpcIdentifier {
private static final class Global extends DOMRpcIdentifier {
- private Global(final @Nonnull SchemaPath type) {
+ private Global(@Nonnull final SchemaPath type) {
super(type);
}
private static final class Local extends DOMRpcIdentifier {
private final YangInstanceIdentifier contextReference;
- private Local(final @Nonnull SchemaPath type, final @Nonnull YangInstanceIdentifier contextReference) {
+ private Local(@Nonnull final SchemaPath type, @Nonnull final YangInstanceIdentifier contextReference) {
super(type);
this.contextReference = Preconditions.checkNotNull(contextReference);
}
* @param type RPC type, SchemaPath of its definition, may not be null
* @return A global RPC identifier, guaranteed to be non-null.
*/
- public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type) {
+ @Nonnull
+ public static DOMRpcIdentifier create(@Nonnull final SchemaPath type) {
return new Global(type);
}
* @param contextReference Context reference, null means a global RPC identifier.
* @return A global RPC identifier, guaranteed to be non-null.
*/
- public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type,
- final @Nullable YangInstanceIdentifier contextReference) {
+ @Nonnull
+ public static DOMRpcIdentifier create(@Nonnull final SchemaPath type,
+ @Nullable final YangInstanceIdentifier contextReference) {
if (contextReference == null || contextReference.isEmpty()) {
return new Global(type);
} else {
*
* @return RPC type.
*/
- public final @Nonnull SchemaPath getType() {
+ @Nonnull
+ public final SchemaPath getType() {
return type;
}
*
* @return RPC context reference.
*/
- public abstract @Nonnull YangInstanceIdentifier getContextReference();
+ @Nonnull
+ public abstract YangInstanceIdentifier getContextReference();
@Override
public final int hashCode() {
*/
package org.opendaylight.mdsal.dom.broker;
-import static com.google.common.base.Preconditions.checkState;
-
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.EnumMap;
public <L extends DOMDataTreeChangeListener> ListenerRegistration<L>
registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) {
DOMStore publisher = getTxFactories().get(treeId.getDatastoreType());
- checkState(publisher != null, "Requested logical data store is not available.");
+ Preconditions.checkState(publisher != null,
+ "Requested logical data store is not available.");
return ((DOMStoreTreeChangePublisher)publisher).registerTreeChangeListener(
treeId.getRootIdentifier(), listener);
*/
final class CommitCoordinationTask implements Callable<Void> {
private enum Phase {
- canCommit,
- preCommit,
- doCommit,
+ CAN_COMMIT,
+ PRE_COMMIT,
+ DO_COMMIT
}
private static final Logger LOG = LoggerFactory.getLogger(CommitCoordinationTask.class);
public Void call() throws TransactionCommitFailedException {
final long startTime = commitStatTracker != null ? System.nanoTime() : 0;
- Phase phase = Phase.canCommit;
+ Phase phase = Phase.CAN_COMMIT;
try {
LOG.debug("Transaction {}: canCommit Started", tx.getIdentifier());
canCommitBlocking();
- phase = Phase.preCommit;
+ phase = Phase.PRE_COMMIT;
LOG.debug("Transaction {}: preCommit Started", tx.getIdentifier());
preCommitBlocking();
- phase = Phase.doCommit;
+ phase = Phase.DO_COMMIT;
LOG.debug("Transaction {}: doCommit Started", tx.getIdentifier());
commitBlocking();
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService {
- private static final Logger LOG = LoggerFactory.getLogger(ShardedDOMDataTree.class);
@GuardedBy("this")
private final DOMDataTreePrefixTable<DOMDataTreeShardRegistration<?>> shards = DOMDataTreePrefixTable.create();
Preconditions.checkNotNull(listener, "listener");
Preconditions.checkArgument(!subtrees.isEmpty(), "Subtrees must not be empty.");
final ShardedDOMDataTreeListenerContext<T> listenerContext =
- ShardedDOMDataTreeListenerContext.create(listener, subtrees, allowRxMerges);
+ ShardedDOMDataTreeListenerContext.create(listener);
try {
// FIXME: Add attachment of producers
for (final DOMDataTreeProducer producer : producers) {
Preconditions.checkArgument(producer instanceof ShardedDOMDataTreeProducer);
- final ShardedDOMDataTreeProducer castedProducer = ((ShardedDOMDataTreeProducer) producer);
+ final ShardedDOMDataTreeProducer castedProducer = (ShardedDOMDataTreeProducer) producer;
simpleLoopCheck(subtrees, castedProducer.getSubtrees());
// FIXME: We should also unbound listeners
castedProducer.bindToListener(listenerContext);
@GuardedBy("this")
private Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> currentData = Collections.emptyMap();
- private ShardedDOMDataTreeListenerContext(T listener, Collection<DOMDataTreeIdentifier> subtrees,
- boolean allowRxMerges) {
+ private ShardedDOMDataTreeListenerContext(T listener) {
for (LogicalDatastoreType type : LogicalDatastoreType.values()) {
storeListeners.put(type, new StoreListener(type));
}
this.listener = Preconditions.checkNotNull(listener, "listener");
}
- static <T extends DOMDataTreeListener> ShardedDOMDataTreeListenerContext<T> create(final T listener,
- final Collection<DOMDataTreeIdentifier> subtrees, final boolean allowRxMerges) {
- return new ShardedDOMDataTreeListenerContext<>(listener, subtrees, allowRxMerges);
+ static <T extends DOMDataTreeListener> ShardedDOMDataTreeListenerContext<T> create(final T listener) {
+ return new ShardedDOMDataTreeListenerContext<>(listener);
}
synchronized void notifyListener() {
public void close() {
// TODO should we also cancel all read futures?
LOG.debug("{}: Closing read transaction", txIdentifier);
- if (finished == true) {
+ if (finished) {
return;
}
}
private void checkRunning() {
- Preconditions.checkState(finished == false, "Transaction is already closed");
+ Preconditions.checkState(!finished, "Transaction is already closed");
}
static class ReadShardedListener implements DOMDataTreeListener {
@Override
public void close() {
- if (finished = true) {
+ if (finished) {
// already closed, do nothing
return;
}
}
private void checkRunning() {
- Preconditions.checkState(finished == false);
+ Preconditions.checkState(!finished);
}
public void transactionFailed(final AsyncTransaction<?, ?> tx, final Throwable cause) {
@Override
public boolean cancel() {
LOG.debug("{}: Cancelling transaction");
- if (finished == true) {
+ if (finished) {
return false;
}
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
checkRunning();
LOG.debug("{}: Submitting transaction", txIdentifier);
- if (initialized == false) {
+ if (!initialized) {
// If underlying producers, transactions and cursors are
// not even initialized just seal this transaction and
// return immediate future
final NormalizedNode<?, ?> data) {
checkRunning();
LOG.debug("{}: Invoking put operation at {}:{} with payload {}", txIdentifier, store, path);
- if (initialized == false) {
+ if (!initialized) {
initializeDataTreeProducerLayer(path.getParent());
}
final NormalizedNode<?, ?> data) {
checkRunning();
LOG.debug("{}: Invoking merge operation at {}:{} with payload {}", txIdentifier, store, path);
- if (initialized == false) {
+ if (!initialized) {
initializeDataTreeProducerLayer(path.getParent());
}
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
checkRunning();
LOG.debug("{}: Invoking delete operation at {}:{}", txIdentifier, store, path);
- if (initialized == false) {
+ if (!initialized) {
initializeDataTreeProducerLayer(path.getParent());
}
}
private void checkRunning() {
- Preconditions.checkState(finished == false, "{}: Transaction already finished");
+ Preconditions.checkState(!finished, "{}: Transaction already finished");
}
private void closeProducers() {
public synchronized SchemaContextListener addingService(final ServiceReference<SchemaContextListener> reference) {
final SchemaContextListener listener = context.getService(reference);
- final SchemaContext _ctxContext = getGlobalContext();
- if (getContext() != null && _ctxContext != null) {
- listener.onGlobalContextUpdated(_ctxContext);
+ final SchemaContext ctxContext = getGlobalContext();
+ if (getContext() != null && ctxContext != null) {
+ listener.onGlobalContextUpdated(ctxContext);
}
return listener;
}
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.broker.util.TestModel;
-import org.opendaylight.mdsal.dom.store.inmemory.WriteableDOMDataTreeShard;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
public class ShardedDOMTransactionChainAdapterTest {
public void basicTest() throws Exception {
String identifier = "TestIdent";
DOMDataTreeService dataTreeService = mock(DOMDataTreeService.class);
- WriteableDOMDataTreeShard shard = mock(WriteableDOMDataTreeShard.class);
DOMDataTreeProducer producer = mock(DOMDataTreeProducer.class);
DOMDataTreeCursorAwareTransaction transaction = mock(DOMDataTreeCursorAwareTransaction.class);
DOMDataTreeWriteCursor cursor = mock(DOMDataTreeWriteCursor.class);
doReturn(producer).when(dataTreeService).createProducer(any());
doReturn(transaction).when(producer).createTransaction(true);
doReturn(cursor).when(transaction).createCursor(any());
+ doNothing().when(producer).close();
TransactionChainListener chainListener = new BlockingTransactionChainListener();
transactionChainAdapter.closeReadTransaction();
transactionChainAdapter.close();
}
-}
\ No newline at end of file
+}
private final int maxDataChangeListenerQueueSize;
private final int maxDataStoreExecutorQueueSize;
+ private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize, int maxDataChangeExecutorQueueSize,
+ int maxDataChangeListenerQueueSize, int maxDataStoreExecutorQueueSize) {
+ this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
+ this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
+ this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
+ this.maxDataStoreExecutorQueueSize = maxDataStoreExecutorQueueSize;
+ }
+
/**
* Constructs an instance with the given property values.
*
return DEFAULT;
}
- private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
- int maxDataStoreExecutorQueueSize) {
- this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
- this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
- this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
- this.maxDataStoreExecutorQueueSize = maxDataStoreExecutorQueueSize;
- }
-
/**
* Returns the maximum queue size for the data change notification executor.
*/
}
- @Override
- public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
- registerTreeChangeListener(final YangInstanceIdentifier path, final L listener) {
- return super.registerTreeChangeListener(path, listener);
- }
-
synchronized void publishChange(@Nonnull final DataTreeCandidate candidate) {
processCandidateTree(candidate);
}
public abstract void markDeleted();
-}
\ No newline at end of file
+}