當前位置: 首頁>>代碼示例>>Java>>正文


Java AbortTransactionReply類代碼示例

本文整理匯總了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();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:34,代碼來源:ShardCommitCoordinator.java

示例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);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:12,代碼來源:ThreePhaseCommitCohortProxy.java

示例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();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:10,代碼來源:ThreePhaseCommitCohortProxyTest.java

示例4: isSerializedReplyType

import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply; //導入依賴的package包/類
@Override
public boolean isSerializedReplyType(final Object reply) {
    return AbortTransactionReply.isSerializedType(reply);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:5,代碼來源:ThreePhaseCommitCohortProxy.java

示例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);
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:45,代碼來源:ShardTest.java

示例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());
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:54,代碼來源:ShardTest.java


注:本文中的org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。