import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload;
-import org.opendaylight.controller.cluster.datastore.persisted.PreBoronShardDataTreeSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
import org.opendaylight.controller.cluster.raft.TestActorFactory;
private static final AtomicInteger NEXT_SHARD_NUM = new AtomicInteger();
+ protected static final int HEARTBEAT_MILLIS = 100;
+
protected final ShardIdentifier shardID = ShardIdentifier.create("inventory", MemberName.forName("member-1"),
"config" + NEXT_SHARD_NUM.getAndIncrement());
protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder()
- .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).shardHeartbeatIntervalInMillis(100);
+ .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000)
+ .shardHeartbeatIntervalInMillis(HEARTBEAT_MILLIS);
protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
}
public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
- final NormalizedNode<?,?> node) throws Exception {
+ final NormalizedNode<?,?> node) throws DataValidationFailedException {
BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
- store.notifyListeners(store.commit(modification));
+ store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
public static void writeToStore(final DataTree store, final YangInstanceIdentifier id,
}
public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id,
- final NormalizedNode<?,?> node) throws Exception {
+ final NormalizedNode<?,?> node) throws DataValidationFailedException {
final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION);
batched.addModification(new MergeModification(id, node));
batched.setReady(true);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
- store.notifyListeners(store.commit(modification));
+ store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
DataTree setupInMemorySnapshotStore() throws DataValidationFailedException {
final NormalizedNode<?, ?> root = readStore(testStore, YangInstanceIdentifier.EMPTY);
InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create(
- new ShardSnapshotState(new PreBoronShardDataTreeSnapshot(root)),
+ new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
Collections.<ReplicatedLogEntry>emptyList(), 0, 1, -1, -1, 1, null, null));
return testStore;
}
return mockCandidate;
}
- static void commitTransaction(final DataTree store, final DataTreeModification modification)
+ static DataTreeCandidate commitTransaction(final DataTree store, final DataTreeModification modification)
throws DataValidationFailedException {
modification.ready();
store.validate(modification);
- store.commit(store.prepare(modification));
+ final DataTreeCandidate candidate = store.prepare(modification);
+ store.commit(candidate);
+ return candidate;
}
@SuppressWarnings("serial")