当前位置: 首页>>代码示例>>Java>>正文


Java CreateTransaction类代码示例

本文整理汇总了Java中org.opendaylight.controller.cluster.datastore.messages.CreateTransaction的典型用法代码示例。如果您正苦于以下问题:Java CreateTransaction类的具体用法?Java CreateTransaction怎么用?Java CreateTransaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CreateTransaction类属于org.opendaylight.controller.cluster.datastore.messages包,在下文中一共展示了CreateTransaction类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tryCreateTransaction

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
/**
  Performs a CreateTransaction try async.
 */
private void tryCreateTransaction() {
    LOG.debug("Tx {} Primary shard {} found - trying create transaction", getIdentifier(),
            primaryShardInfo.getPrimaryShardActor());

    Object serializedCreateMessage = new CreateTransaction(getIdentifier(), getTransactionType().ordinal(),
                primaryShardInfo.getPrimaryShardVersion()).toSerializable();

    Future<Object> createTxFuture = getActorContext().executeOperationAsync(
            primaryShardInfo.getPrimaryShardActor(), serializedCreateMessage, createTxMessageTimeout);

    createTxFuture.onComplete(new OnComplete<Object>() {
        @Override
        public void onComplete(Throwable failure, Object response) {
            onCreateTransactionComplete(failure, response);
        }
    }, getActorContext().getClientDispatcher());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:RemoteTransactionContextSupport.java

示例2: eqCreateTransaction

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
protected CreateTransaction eqCreateTransaction(final String expMemberName,
        final TransactionType type) {
    ArgumentMatcher<CreateTransaction> matcher = new ArgumentMatcher<CreateTransaction>() {
        @Override
        public boolean matches(final Object argument) {
            if (CreateTransaction.class.equals(argument.getClass())) {
                CreateTransaction obj = CreateTransaction.fromSerializable(argument);
                return obj.getTransactionId().getHistoryId().getClientId().getFrontendId().getMemberName()
                        .getName().equals(expMemberName) && obj.getTransactionType() == type.ordinal();
            }

            return false;
        }
    };

    return argThat(matcher);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:AbstractTransactionProxyTest.java

示例3: testCreateTransaction

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
@Test
public void testCreateTransaction() {
    new ShardTestKit(getSystem()) {
        {
            final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransaction");

            waitUntilLeader(shard);

            shard.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());

            shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
                    DataStoreVersions.CURRENT_VERSION).toSerializable(), getRef());

            final CreateTransactionReply reply = expectMsgClass(duration("3 seconds"),
                    CreateTransactionReply.class);

            final String path = reply.getTransactionPath().toString();
            assertTrue("Unexpected transaction path " + path, path.startsWith(String.format(
                    "akka://test/user/testCreateTransaction/shard-%s-%s:[email protected]:",
                        shardID.getShardName(), shardID.getMemberName().getName())));
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:ShardTest.java

示例4: testCreateTransactionOnChain

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
@Test
public void testCreateTransactionOnChain() {
    new ShardTestKit(getSystem()) {
        {
            final ActorRef shard = actorFactory.createActor(newShardProps(), "testCreateTransactionOnChain");

            waitUntilLeader(shard);

            shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
                    DataStoreVersions.CURRENT_VERSION).toSerializable(), getRef());

            final CreateTransactionReply reply = expectMsgClass(duration("3 seconds"),
                    CreateTransactionReply.class);

            final String path = reply.getTransactionPath().toString();
            assertTrue("Unexpected transaction path " + path, path.startsWith(String.format(
                    "akka://test/user/testCreateTransactionOnChain/shard-%s-%s:[email protected]:",
                    shardID.getShardName(), shardID.getMemberName().getName())));
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:ShardTest.java

示例5: handleCreateTransaction

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
private void handleCreateTransaction(final Object message) {
    if (isLeader()) {
        createTransaction(CreateTransaction.fromSerializable(message));
    } else if (getLeader() != null) {
        getLeader().forward(message, getContext());
    } else {
        getSender().tell(new Failure(new NoShardLeaderException(
                "Could not create a shard transaction", persistenceId())), getSelf());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:Shard.java

示例6: handleNonRaftCommand

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
@Override
protected void handleNonRaftCommand(final Object message) {
    try (MessageTracker.Context context = appendEntriesReplyTracker.received(message)) {
        final Optional<Error> maybeError = context.error();
        if (maybeError.isPresent()) {
            LOG.trace("{} : AppendEntriesReply failed to arrive at the expected interval {}", persistenceId(),
                maybeError.get());
        }

        store.resetTransactionBatch();

        if (message instanceof RequestEnvelope) {
            handleRequestEnvelope((RequestEnvelope)message);
        } else if (MessageAssembler.isHandledMessage(message)) {
            handleRequestAssemblerMessage(message);
        } else if (message instanceof ConnectClientRequest) {
            handleConnectClient((ConnectClientRequest)message);
        } else if (CreateTransaction.isSerializedType(message)) {
            handleCreateTransaction(message);
        } else if (message instanceof BatchedModifications) {
            handleBatchedModifications((BatchedModifications)message);
        } else if (message instanceof ForwardedReadyTransaction) {
            handleForwardedReadyTransaction((ForwardedReadyTransaction) message);
        } else if (message instanceof ReadyLocalTransaction) {
            handleReadyLocalTransaction((ReadyLocalTransaction)message);
        } else if (CanCommitTransaction.isSerializedType(message)) {
            handleCanCommitTransaction(CanCommitTransaction.fromSerializable(message));
        } else if (CommitTransaction.isSerializedType(message)) {
            handleCommitTransaction(CommitTransaction.fromSerializable(message));
        } else if (AbortTransaction.isSerializedType(message)) {
            handleAbortTransaction(AbortTransaction.fromSerializable(message));
        } else if (CloseTransactionChain.isSerializedType(message)) {
            closeTransactionChain(CloseTransactionChain.fromSerializable(message));
        } else if (message instanceof RegisterChangeListener) {
            changeSupport.onMessage((RegisterChangeListener) message, isLeader(), hasLeader());
        } else if (message instanceof RegisterDataTreeChangeListener) {
            treeChangeSupport.onMessage((RegisterDataTreeChangeListener) message, isLeader(), hasLeader());
        } else if (message instanceof UpdateSchemaContext) {
            updateSchemaContext((UpdateSchemaContext) message);
        } else if (message instanceof PeerAddressResolved) {
            PeerAddressResolved resolved = (PeerAddressResolved) message;
            setPeerAddress(resolved.getPeerId(), resolved.getPeerAddress());
        } else if (TX_COMMIT_TIMEOUT_CHECK_MESSAGE.equals(message)) {
            commitTimeoutCheck();
        } else if (message instanceof DatastoreContext) {
            onDatastoreContext((DatastoreContext)message);
        } else if (message instanceof RegisterRoleChangeListener) {
            roleChangeNotifier.get().forward(message, context());
        } else if (message instanceof FollowerInitialSyncUpStatus) {
            shardMBean.setFollowerInitialSyncStatus(((FollowerInitialSyncUpStatus) message).isInitialSyncDone());
            context().parent().tell(message, self());
        } else if (GET_SHARD_MBEAN_MESSAGE.equals(message)) {
            sender().tell(getShardMBean(), self());
        } else if (message instanceof GetShardDataTree) {
            sender().tell(store.getDataTree(), self());
        } else if (message instanceof ServerRemoved) {
            context().parent().forward(message, context());
        } else if (ShardTransactionMessageRetrySupport.TIMER_MESSAGE_CLASS.isInstance(message)) {
            messageRetrySupport.onTimerMessage(message);
        } else if (message instanceof DataTreeCohortActorRegistry.CohortRegistryCommand) {
            store.processCohortRegistryCommand(getSender(),
                    (DataTreeCohortActorRegistry.CohortRegistryCommand) message);
        } else if (message instanceof PersistAbortTransactionPayload) {
            final TransactionIdentifier txId = ((PersistAbortTransactionPayload) message).getTransactionId();
            persistPayload(txId, AbortTransactionPayload.create(txId), true);
        } else if (message instanceof MakeLeaderLocal) {
            onMakeLeaderLocal();
        } else if (RESUME_NEXT_PENDING_TRANSACTION.equals(message)) {
            store.resumeNextPendingTransaction();
        } else if (!responseMessageSlicer.handleMessage(message)) {
            super.handleNonRaftCommand(message);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:75,代码来源:Shard.java

示例7: testBatchedModificationsOnTransactionChain

import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; //导入依赖的package包/类
@Test
public void testBatchedModificationsOnTransactionChain() throws Exception {
    new ShardTestKit(getSystem()) {
        {
            final TestActorRef<Shard> shard = actorFactory.createTestActor(
                    newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
                    "testBatchedModificationsOnTransactionChain");

            waitUntilLeader(shard);

            final LocalHistoryIdentifier historyId = nextHistoryId();
            final TransactionIdentifier transactionID1 = new TransactionIdentifier(historyId, 0);
            final TransactionIdentifier transactionID2 = new TransactionIdentifier(historyId, 1);

            final FiniteDuration duration = duration("5 seconds");

            // Send a BatchedModifications to start a chained write
            // transaction and ready it.

            final ContainerNode containerNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
            final YangInstanceIdentifier path = TestModel.TEST_PATH;
            shard.tell(newBatchedModifications(transactionID1, path, containerNode, true, false, 1), getRef());
            expectMsgClass(duration, ReadyTransactionReply.class);

            // Create a read Tx on the same chain.

            shard.tell(new CreateTransaction(transactionID2, TransactionType.READ_ONLY.ordinal(),
                    DataStoreVersions.CURRENT_VERSION).toSerializable(), getRef());

            final CreateTransactionReply createReply = expectMsgClass(duration("3 seconds"),
                    CreateTransactionReply.class);

            getSystem().actorSelection(createReply.getTransactionPath())
                    .tell(new ReadData(path, DataStoreVersions.CURRENT_VERSION), getRef());
            final ReadDataReply readReply = expectMsgClass(duration("3 seconds"), ReadDataReply.class);
            assertEquals("Read node", containerNode, readReply.getNormalizedNode());

            // Commit the write transaction.

            shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
            final CanCommitTransactionReply canCommitReply = CanCommitTransactionReply
                    .fromSerializable(expectMsgClass(duration, CanCommitTransactionReply.class));
            assertEquals("Can commit", true, canCommitReply.getCanCommit());

            shard.tell(new CommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), getRef());
            expectMsgClass(duration, CommitTransactionReply.class);

            // Verify data in the data store.

            final NormalizedNode<?, ?> actualNode = readStore(shard, path);
            assertEquals("Stored node", containerNode, actualNode);
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:55,代码来源:ShardTest.java


注:本文中的org.opendaylight.controller.cluster.datastore.messages.CreateTransaction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。