本文整理汇总了Java中org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply类的典型用法代码示例。如果您正苦于以下问题:Java CommitTransactionReply类的具体用法?Java CommitTransactionReply怎么用?Java CommitTransactionReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommitTransactionReply类属于org.opendaylight.controller.cluster.datastore.messages包,在下文中一共展示了CommitTransactionReply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initiateDirectCommit
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
Future<Object> initiateDirectCommit() {
final Future<Object> messageFuture = initiateCommit(true);
messageFuture.onComplete(new OnComplete<Object>() {
@Override
public void onComplete(final Throwable failure, final Object message) throws Throwable {
if (failure != null) {
LOG.error("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure);
transactionAborted(transaction);
} else if (CommitTransactionReply.isSerializedType(message)) {
LOG.debug("Transaction {} committed successfully", transaction.getIdentifier());
transactionCommitted(transaction);
} else {
LOG.error("Transaction {} resulted in unhandled message type {}, aborting", message.getClass());
transactionAborted(transaction);
}
}
}, actorContext.getClientDispatcher());
return messageFuture;
}
示例2: handleMessage
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
boolean handleMessage(Object message, EntityOwnershipShard shard) {
boolean handled = true;
if (CommitTransactionReply.isSerializedType(message)) {
// Successful reply from a local commit.
inflightCommitSucceeded(shard);
} else if (message instanceof akka.actor.Status.Failure) {
// Failure reply from a local commit.
inflightCommitFailure(((Failure) message).cause(), shard);
} else if (COMMIT_RETRY_MESSAGE.equals(message)) {
retryInflightCommit(shard);
} else {
handled = false;
}
return handled;
}
示例3: testReadyWithLocalTransaction
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testReadyWithLocalTransaction() throws Exception {
ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
doReturn(getSystem().actorSelection(shardActorRef.path())).when(mockActorContext)
.actorSelection(shardActorRef.path().toString());
doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, createDataTree()))).when(mockActorContext)
.findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY);
expectReadyLocalTransaction(shardActorRef, true);
NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
DOMStoreThreePhaseCommitCohort ready = transactionProxy.ready();
assertTrue(ready instanceof SingleCommitCohortProxy);
verifyCohortFutures((SingleCommitCohortProxy)ready, new CommitTransactionReply().toSerializable());
}
示例4: testAllThreePhasesSuccessful
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testAllThreePhasesSuccessful() throws Exception {
List<CohortInfo> cohorts = Arrays.asList(
newCohortInfo(
new CohortActor.Builder(tx).expectCanCommit(CanCommitTransactionReply.yes(CURRENT_VERSION))
.expectCommit(CommitTransactionReply.instance(CURRENT_VERSION))),
newCohortInfo(
new CohortActor.Builder(tx).expectCanCommit(CanCommitTransactionReply.yes(CURRENT_VERSION))
.expectCommit(CommitTransactionReply.instance(CURRENT_VERSION))));
ThreePhaseCommitCohortProxy proxy = new ThreePhaseCommitCohortProxy(actorContext, cohorts, tx);
verifyCanCommit(proxy.canCommit(), true);
verifySuccessfulFuture(proxy.preCommit());
verifySuccessfulFuture(proxy.commit());
verifyCohortActors();
}
示例5: testReadyWithImmediateCommit
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
private void testReadyWithImmediateCommit(final boolean readWrite) throws Exception {
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
"testReadyWithImmediateCommit-" + readWrite);
waitUntilLeader(shard);
final TransactionIdentifier transactionID = nextTransactionId();
final NormalizedNode<?, ?> containerNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
if (readWrite) {
shard.tell(prepareForwardedReadyTransaction(shard, transactionID, TestModel.TEST_PATH,
containerNode, true), getRef());
} else {
shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH, containerNode, true),
getRef());
}
expectMsgClass(duration("5 seconds"), CommitTransactionReply.class);
final NormalizedNode<?, ?> actualNode = readStore(shard, TestModel.TEST_PATH);
assertEquals(TestModel.TEST_QNAME.getLocalName(), containerNode, actualNode);
}
};
}
示例6: commit
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Override
public ListenableFuture<Void> commit() {
OperationCallback operationCallback = commitOperationCallback != null ? commitOperationCallback :
OperationCallback.NO_OP_CALLBACK;
return voidOperation("commit", COMMIT_MESSAGE_SUPPLIER,
CommitTransactionReply.class, true, operationCallback);
}
示例7: testOnReceiveBatchedModificationsReadyWithImmediateCommit
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() throws Exception {
new JavaTestKit(getSystem()) {
{
final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(),
"testOnReceiveBatchedModificationsReadyWithImmediateCommit");
JavaTestKit watcher = new JavaTestKit(getSystem());
watcher.watch(transaction);
YangInstanceIdentifier writePath = TestModel.TEST_PATH;
NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
.withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
BatchedModifications batched = new BatchedModifications(nextTransactionId(),
DataStoreVersions.CURRENT_VERSION);
batched.addModification(new WriteModification(writePath, writeData));
batched.setReady(true);
batched.setDoCommitOnReady(true);
batched.setTotalMessagesSent(1);
transaction.tell(batched, getRef());
expectMsgClass(duration("5 seconds"), CommitTransactionReply.class);
watcher.expectMsgClass(duration("5 seconds"), Terminated.class);
}
};
}
示例8: testCommitWithExceptionFailure
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test(expected = TestException.class)
public void testCommitWithExceptionFailure() throws Exception {
List<CohortInfo> cohorts = Arrays.asList(
newCohortInfo(
new CohortActor.Builder(tx).expectCanCommit(CanCommitTransactionReply.yes(CURRENT_VERSION))
.expectCommit(CommitTransactionReply.instance(CURRENT_VERSION))),
newCohortInfo(
new CohortActor.Builder(tx).expectCanCommit(CanCommitTransactionReply.yes(CURRENT_VERSION))
.expectCommit(new TestException())));
ThreePhaseCommitCohortProxy proxy = new ThreePhaseCommitCohortProxy(actorContext, cohorts, tx);
verifyCanCommit(proxy.canCommit(), true);
verifySuccessfulFuture(proxy.preCommit());
propagateExecutionExceptionCause(proxy.commit());
}
示例9: testBatchedModificationsWithCommitOnReady
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testBatchedModificationsWithCommitOnReady() throws Exception {
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
"testBatchedModificationsWithCommitOnReady");
waitUntilLeader(shard);
final TransactionIdentifier transactionID = nextTransactionId();
final FiniteDuration duration = duration("5 seconds");
// Send a BatchedModifications to start a transaction.
shard.tell(newBatchedModifications(transactionID, TestModel.TEST_PATH,
ImmutableNodes.containerNode(TestModel.TEST_QNAME), false, false, 1), getRef());
expectMsgClass(duration, BatchedModificationsReply.class);
// Send a couple more BatchedModifications.
shard.tell(newBatchedModifications(transactionID, TestModel.OUTER_LIST_PATH,
ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build(), false, false, 2),
getRef());
expectMsgClass(duration, BatchedModificationsReply.class);
shard.tell(newBatchedModifications(transactionID,
YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
.nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1).build(),
ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1), true, true, 3),
getRef());
expectMsgClass(duration, CommitTransactionReply.class);
// Verify data in the data store.
verifyOuterListEntry(shard, 1);
}
};
}
示例10: testReadyLocalTransactionWithImmediateCommit
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testReadyLocalTransactionWithImmediateCommit() throws Exception {
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
"testReadyLocalTransactionWithImmediateCommit");
waitUntilLeader(shard);
final ShardDataTree dataStore = shard.underlyingActor().getDataStore();
final DataTreeModification modification = dataStore.newModification();
final ContainerNode writeData = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
new WriteModification(TestModel.TEST_PATH, writeData).apply(modification);
final MapNode mergeData = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build();
new MergeModification(TestModel.OUTER_LIST_PATH, mergeData).apply(modification);
final TransactionIdentifier txId = nextTransactionId();
modification.ready();
final ReadyLocalTransaction readyMessage = new ReadyLocalTransaction(txId, modification, true);
shard.tell(readyMessage, getRef());
expectMsgClass(CommitTransactionReply.class);
final NormalizedNode<?, ?> actualNode = readStore(shard, TestModel.OUTER_LIST_PATH);
assertEquals(TestModel.OUTER_LIST_QNAME.getLocalName(), mergeData, actualNode);
}
};
}
示例11: testReadWriteCommitWithPersistenceDisabled
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Test
public void testReadWriteCommitWithPersistenceDisabled() throws Exception {
dataStoreContextBuilder.persistent(false);
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
"testCommitWithPersistenceDisabled");
waitUntilLeader(shard);
// Setup a simulated transactions with a mock cohort.
final FiniteDuration duration = duration("5 seconds");
final TransactionIdentifier transactionID = nextTransactionId();
final NormalizedNode<?, ?> containerNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH, containerNode, false),
getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
// Send the CanCommitTransaction message.
shard.tell(new CanCommitTransaction(transactionID, CURRENT_VERSION).toSerializable(), getRef());
final CanCommitTransactionReply canCommitReply = CanCommitTransactionReply
.fromSerializable(expectMsgClass(duration, CanCommitTransactionReply.class));
assertEquals("Can commit", true, canCommitReply.getCanCommit());
// Send the CanCommitTransaction message.
shard.tell(new CommitTransaction(transactionID, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CommitTransactionReply.class);
final NormalizedNode<?, ?> actualNode = readStore(shard, TestModel.TEST_PATH);
assertEquals(TestModel.TEST_QNAME.getLocalName(), containerNode, actualNode);
}
};
}
示例12: isSerializedReplyType
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@Override
public boolean isSerializedReplyType(final Object reply) {
return CommitTransactionReply.isSerializedType(reply);
}
示例13: expectBatchedModificationsReady
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
protected void expectBatchedModificationsReady(final ActorRef actorRef, final boolean doCommitOnReady) {
doReturn(doCommitOnReady ? Futures.successful(new CommitTransactionReply().toSerializable()) :
readyTxReply(actorRef.path().toString())).when(mockActorContext).executeOperationAsync(
eq(actorSelection(actorRef)), isA(BatchedModifications.class), any(Timeout.class));
}
示例14: expectReadyLocalTransaction
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
protected void expectReadyLocalTransaction(final ActorRef actorRef, final boolean doCommitOnReady) {
doReturn(doCommitOnReady ? Futures.successful(new CommitTransactionReply().toSerializable()) :
readyTxReply(actorRef.path().toString())).when(mockActorContext).executeOperationAsync(
eq(actorSelection(actorRef)), isA(ReadyLocalTransaction.class), any(Timeout.class));
}
示例15: verifyCohortFutures
import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
protected void verifyCohortFutures(final AbstractThreePhaseCommitCohort<?> proxy,
final Object... expReplies) {
assertEquals("getReadyOperationFutures size", expReplies.length,
proxy.getCohortFutures().size());
List<Object> futureResults = new ArrayList<>();
for (Future<?> future : proxy.getCohortFutures()) {
assertNotNull("Ready operation Future is null", future);
try {
futureResults.add(Await.result(future, Duration.create(5, TimeUnit.SECONDS)));
} catch (Exception e) {
futureResults.add(e);
}
}
for (Object expReply : expReplies) {
boolean found = false;
Iterator<?> iter = futureResults.iterator();
while (iter.hasNext()) {
Object actual = iter.next();
if (CommitTransactionReply.isSerializedType(expReply)
&& CommitTransactionReply.isSerializedType(actual)) {
found = true;
} else if (expReply instanceof ActorSelection && Objects.equals(expReply, actual)) {
found = true;
} else if (expReply instanceof Class && ((Class<?>) expReply).isInstance(actual)) {
found = true;
}
if (found) {
iter.remove();
break;
}
}
if (!found) {
fail(String.format("No cohort Future response found for %s. Actual: %s", expReply, futureResults));
}
}
}