本文整理汇总了Java中org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply类的典型用法代码示例。如果您正苦于以下问题:Java AbortTransactionReply类的具体用法?Java AbortTransactionReply怎么用?Java AbortTransactionReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbortTransactionReply类属于org.opendaylight.controller.cluster.datastore.messages包,在下文中一共展示了AbortTransactionReply类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAbort
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
void handleAbort(final Identifier transactionID, final ActorRef sender, final Shard shard) {
CohortEntry cohortEntry = cohortCache.remove(transactionID);
if (cohortEntry == null) {
return;
}
log.debug("{}: Aborting transaction {}", name, transactionID);
final ActorRef self = shard.getSelf();
cohortEntry.abort(new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
shard.getDataStore().purgeTransaction(cohortEntry.getTransactionId(), null);
if (sender != null) {
sender.tell(AbortTransactionReply.instance(cohortEntry.getClientVersion()).toSerializable(), self);
}
}
@Override
public void onFailure(final Throwable failure) {
log.error("{}: An exception happened during abort", name, failure);
shard.getDataStore().purgeTransaction(cohortEntry.getTransactionId(), null);
if (sender != null) {
sender.tell(new Failure(failure), self);
}
}
});
shard.getShardMBean().incrementAbortTransactionsCount();
}
示例2: abort
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@Override
public ListenableFuture<Void> abort() {
// Note - we pass false for propagateException. In the front-end data broker, this method
// is called when one of the 3 phases fails with an exception. We'd rather have that
// original exception propagated to the client. If our abort fails and we propagate the
// exception then that exception will supersede and suppress the original exception. But
// it's the original exception that is the root cause and of more interest to the client.
return voidOperation("abort", ABORT_MESSAGE_SUPPLIER,
AbortTransactionReply.class, false, OperationCallback.NO_OP_CALLBACK);
}
示例3: testAbort
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@Test
public void testAbort() throws Exception {
ThreePhaseCommitCohortProxy proxy = new ThreePhaseCommitCohortProxy(actorContext, Arrays.asList(
newCohortInfo(new CohortActor.Builder(tx).expectAbort(
AbortTransactionReply.instance(CURRENT_VERSION)))), tx);
verifySuccessfulFuture(proxy.abort());
verifyCohortActors();
}
示例4: isSerializedReplyType
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@Override
public boolean isSerializedReplyType(final Object reply) {
return AbortTransactionReply.isSerializedType(reply);
}
示例5: testAbortAfterReady
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@Test
public void testAbortAfterReady() throws Exception {
dataStoreContextBuilder.shardTransactionCommitTimeoutInSeconds(1);
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()), "testAbortAfterReady");
waitUntilLeader(shard);
final FiniteDuration duration = duration("5 seconds");
// Ready a tx.
final TransactionIdentifier transactionID1 = nextTransactionId();
shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
// Send the AbortTransaction message.
shard.tell(new AbortTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, AbortTransactionReply.class);
assertEquals("getPendingTxCommitQueueSize", 0, shard.underlyingActor().getPendingTxCommitQueueSize());
// Now send CanCommitTransaction - should fail.
shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
final Throwable failure = expectMsgClass(duration, akka.actor.Status.Failure.class).cause();
assertTrue("Failure type", failure instanceof IllegalStateException);
// Ready and CanCommit another and verify success.
final TransactionIdentifier transactionID2 = nextTransactionId();
shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
shard.tell(new CanCommitTransaction(transactionID2, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CanCommitTransactionReply.class);
}
};
}
示例6: testAbortQueuedTransaction
import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //导入依赖的package包/类
@Test
public void testAbortQueuedTransaction() throws Exception {
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(
newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()), "testAbortAfterReady");
waitUntilLeader(shard);
final FiniteDuration duration = duration("5 seconds");
// Ready 3 tx's.
final TransactionIdentifier transactionID1 = nextTransactionId();
shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
final TransactionIdentifier transactionID2 = nextTransactionId();
shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
final TransactionIdentifier transactionID3 = nextTransactionId();
shard.tell(
newBatchedModifications(transactionID3, TestModel.OUTER_LIST_PATH,
ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build(), true, false, 1),
getRef());
expectMsgClass(duration, ReadyTransactionReply.class);
// Abort the second tx while it's queued.
shard.tell(new AbortTransaction(transactionID2, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, AbortTransactionReply.class);
// Commit the other 2.
shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CanCommitTransactionReply.class);
shard.tell(new CommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CommitTransactionReply.class);
shard.tell(new CanCommitTransaction(transactionID3, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CanCommitTransactionReply.class);
shard.tell(new CommitTransaction(transactionID3, CURRENT_VERSION).toSerializable(), getRef());
expectMsgClass(duration, CommitTransactionReply.class);
assertEquals("getPendingTxCommitQueueSize", 0, shard.underlyingActor().getPendingTxCommitQueueSize());
}
};
}