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


Java DoNothingActor类代码示例

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


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

示例1: setupActorContextWithInitialCreateTransaction

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
protected ActorRef setupActorContextWithInitialCreateTransaction(final ActorSystem actorSystem,
        final TransactionType type, final short transactionVersion, final String prefix,
        final ActorRef shardActorRef) {

    ActorRef txActorRef;
    if (type == TransactionType.WRITE_ONLY
            && dataStoreContextBuilder.build().isWriteOnlyTransactionOptimizationsEnabled()) {
        txActorRef = shardActorRef;
    } else {
        txActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));
        log.info("Created mock shard Tx actor {}", txActorRef);

        doReturn(actorSystem.actorSelection(txActorRef.path()))
            .when(mockActorContext).actorSelection(txActorRef.path().toString());

        doReturn(Futures.successful(createTransactionReply(txActorRef, transactionVersion))).when(mockActorContext)
            .executeOperationAsync(eq(actorSystem.actorSelection(shardActorRef.path())),
                    eqCreateTransaction(prefix, type), any(Timeout.class));
    }

    return txActorRef;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:AbstractTransactionProxyTest.java

示例2: testExceptionOnInitialCreateTransaction

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
private void testExceptionOnInitialCreateTransaction(final Exception exToThrow, final Invoker invoker)
        throws Exception {
    ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));

    if (exToThrow instanceof PrimaryNotFoundException) {
        doReturn(Futures.failed(exToThrow)).when(mockActorContext).findPrimaryShardAsync(anyString());
    } else {
        doReturn(primaryShardInfoReply(getSystem(), actorRef)).when(mockActorContext)
                .findPrimaryShardAsync(anyString());
    }

    doReturn(Futures.failed(exToThrow)).when(mockActorContext).executeOperationAsync(
            any(ActorSelection.class), any(), any(Timeout.class));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY);

    propagateReadFailedExceptionCause(invoker.invoke(transactionProxy));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:TransactionProxyTest.java

示例3: testInvalidCreateTransactionReply

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testInvalidCreateTransactionReply() throws Exception {
    ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));

    doReturn(getSystem().actorSelection(actorRef.path())).when(mockActorContext)
            .actorSelection(actorRef.path().toString());

    doReturn(primaryShardInfoReply(getSystem(), actorRef)).when(mockActorContext)
            .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));

    doReturn(Futures.successful(new Object())).when(mockActorContext).executeOperationAsync(
        eq(getSystem().actorSelection(actorRef.path())), eqCreateTransaction(memberName, READ_ONLY),
        any(Timeout.class));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY);

    propagateReadFailedExceptionCause(transactionProxy.read(TestModel.TEST_PATH));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:TransactionProxyTest.java

示例4: testReadyWithLocalTransaction

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的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());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:TransactionProxyTest.java

示例5: completeOperationLocal

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
private void completeOperationLocal(final TransactionProxyOperation operation, final DataTree dataTree) {
    ActorSystem actorSystem = getSystem();
    ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));

    doReturn(actorSystem.actorSelection(shardActorRef.path())).when(mockActorContext)
            .actorSelection(shardActorRef.path().toString());

    doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef, dataTree))).when(mockActorContext)
            .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);

    long start = System.nanoTime();

    operation.run(transactionProxy);

    long end = System.nanoTime();

    long expected = TimeUnit.MILLISECONDS.toNanos(mockActorContext.getDatastoreContext()
            .getOperationTimeoutInMillis());
    Assert.assertTrue(String.format("Expected elapsed time: %s. Actual: %s", expected, end - start),
            end - start <= expected);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:TransactionProxyTest.java

示例6: setUpReadData

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
private void setUpReadData(final String shardName, final NormalizedNode<?, ?> expectedNode) {
    ActorSystem actorSystem = getSystem();
    ActorRef shardActorRef = getSystem().actorOf(Props.create(DoNothingActor.class));

    doReturn(getSystem().actorSelection(shardActorRef.path())).when(mockActorContext)
            .actorSelection(shardActorRef.path().toString());

    doReturn(primaryShardInfoReply(getSystem(), shardActorRef)).when(mockActorContext)
            .findPrimaryShardAsync(eq(shardName));

    ActorRef txActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));

    doReturn(actorSystem.actorSelection(txActorRef.path())).when(mockActorContext)
            .actorSelection(txActorRef.path().toString());

    doReturn(Futures.successful(createTransactionReply(txActorRef, DataStoreVersions.CURRENT_VERSION)))
            .when(mockActorContext).executeOperationAsync(eq(actorSystem.actorSelection(shardActorRef.path())),
                    eqCreateTransaction(memberName, TransactionType.READ_ONLY), any(Timeout.class));

    doReturn(readDataReply(expectedNode)).when(mockActorContext).executeOperationAsync(
            eq(actorSelection(txActorRef)), eqReadData(YangInstanceIdentifier.EMPTY), any(Timeout.class));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:TransactionProxyTest.java

示例7: setUp

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    actorContext = new ActorContext(getSystem(), actorFactory.createActor(Props.create(DoNothingActor.class)),
            new MockClusterWrapper(), new MockConfiguration(), DatastoreContext.newBuilder().build(),
            new PrimaryShardInfoFutureCache()) {
        @Override
        public Timer getOperationTimer(final String operationName) {
            return commitTimer;
        }

        @Override
        public double getTxCreationLimit() {
            return 10.0;
        }
    };

    doReturn(commitTimerContext).when(commitTimer).time();
    doReturn(commitSnapshot).when(commitTimer).getSnapshot();
    for (int i = 1; i < 11; i++) {
        // Keep on increasing the amount of time it takes to complete transaction for each tenth of a
        // percentile. Essentially this would be 1ms for the 10th percentile, 2ms for 20th percentile and so on.
        doReturn(TimeUnit.MILLISECONDS.toNanos(i) * 1D).when(commitSnapshot).getValue(i * 0.1);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:ThreePhaseCommitCohortProxyTest.java

示例8: setup

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Before
public void setup() {
    TestActorRef<DoNothingActor> actor = actorFactory.createTestActor(
            Props.create(DoNothingActor.class), actorFactory.generateActorId("test"));

    actorContext = actor.underlyingActor().getContext();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:EntityOwnershipListenerSupportTest.java

示例9: setupActorContextWithoutInitialCreateTransaction

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
protected ActorRef setupActorContextWithoutInitialCreateTransaction(final ActorSystem actorSystem,
        final String shardName, final short transactionVersion) {
    ActorRef actorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));
    log.info("Created mock shard actor {}", actorRef);

    doReturn(actorSystem.actorSelection(actorRef.path()))
            .when(mockActorContext).actorSelection(actorRef.path().toString());

    doReturn(primaryShardInfoReply(actorSystem, actorRef, transactionVersion))
            .when(mockActorContext).findPrimaryShardAsync(eq(shardName));

    return actorRef;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:AbstractTransactionProxyTest.java

示例10: testFailedRegistration

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Test
public void testFailedRegistration() {
    new JavaTestKit(getSystem()) {
        {
            ActorSystem mockActorSystem = mock(ActorSystem.class);

            ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), "testFailedRegistration");
            doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
            ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(MoreExecutors.directExecutor());

            ActorContext actorContext = mock(ActorContext.class);
            final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);

            doReturn(executor).when(actorContext).getClientDispatcher();
            doReturn(DatastoreContext.newBuilder().build()).when(actorContext).getDatastoreContext();
            doReturn(mockActorSystem).when(actorContext).getActorSystem();

            String shardName = "shard-1";
            final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
                    actorContext, mockListener, path);

            doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
            doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
            doReturn(Futures.failed(new RuntimeException("mock"))).when(actorContext)
                    .executeOperationAsync(any(ActorRef.class), any(Object.class), any(Timeout.class));
            doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();

            proxy.init("shard-1");

            Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());

            proxy.close();
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:36,代码来源:DataTreeChangeListenerProxyTest.java

示例11: completeOperation

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
private void completeOperation(final TransactionProxyOperation operation, final boolean shardFound) {
    ActorSystem actorSystem = getSystem();
    ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));

    doReturn(actorSystem.actorSelection(shardActorRef.path())).when(mockActorContext)
            .actorSelection(shardActorRef.path().toString());

    if (shardFound) {
        doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef))).when(mockActorContext)
                .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
    } else {
        doReturn(Futures.failed(new PrimaryNotFoundException("test"))).when(mockActorContext)
                .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
    }

    ActorRef txActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));
    String actorPath = txActorRef.path().toString();
    CreateTransactionReply createTransactionReply = new CreateTransactionReply(actorPath, nextTransactionId(),
            DataStoreVersions.CURRENT_VERSION);

    doReturn(actorSystem.actorSelection(actorPath)).when(mockActorContext).actorSelection(actorPath);

    doReturn(Futures.successful(createTransactionReply)).when(mockActorContext).executeOperationAsync(
            eq(actorSystem.actorSelection(shardActorRef.path())), eqCreateTransaction(memberName, READ_WRITE),
            any(Timeout.class));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);

    long start = System.nanoTime();

    operation.run(transactionProxy);

    long end = System.nanoTime();

    long expected = TimeUnit.MILLISECONDS.toNanos(mockActorContext.getDatastoreContext()
            .getOperationTimeoutInMillis());
    Assert.assertTrue(String.format("Expected elapsed time: %s. Actual: %s",
            expected, end - start), end - start <= expected);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:40,代码来源:TransactionProxyTest.java

示例12: testFailedRegistration

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Test
public void testFailedRegistration() {
    new JavaTestKit(getSystem()) {
        {
            ActorSystem mockActorSystem = mock(ActorSystem.class);

            ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class),
                    "testFailedRegistration");
            doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
            ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(
                    MoreExecutors.directExecutor());


            ActorContext actorContext = mock(ActorContext.class);

            doReturn(executor).when(actorContext).getClientDispatcher();

            String shardName = "shard-1";
            final DataChangeListenerRegistrationProxy proxy = new DataChangeListenerRegistrationProxy(
                    shardName, actorContext, mockListener);

            doReturn(mockActorSystem).when(actorContext).getActorSystem();
            doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
            doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
            doReturn(Futures.failed(new RuntimeException("mock")))
                .when(actorContext).executeOperationAsync(any(ActorRef.class),
                    any(Object.class), any(Timeout.class));
            doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();

            proxy.init(YangInstanceIdentifier.of(TestModel.TEST_QNAME),
                    AsyncDataBroker.DataChangeScope.ONE);

            Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());

            proxy.close();
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:39,代码来源:DataChangeListenerRegistrationProxyTest.java

示例13: testOnDataChanged

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
@Test
public void testOnDataChanged() throws Exception {
    final ActorRef actorRef = getSystem().actorOf(MessageCollectorActor.props());

    DataChangeListenerProxy dataChangeListenerProxy = new DataChangeListenerProxy(
            getSystem().actorSelection(actorRef.path()));

    dataChangeListenerProxy.onDataChanged(new MockDataChangedEvent());

    //Check if it was received by the remote actor
    ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(
            Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
    Object messages = testContext
        .executeOperation(actorRef, MessageCollectorActor.GET_ALL_MESSAGES);

    Assert.assertNotNull(messages);

    Assert.assertTrue(messages instanceof List);

    List<?> listMessages = (List<?>) messages;

    Assert.assertEquals(1, listMessages.size());

    Assert.assertTrue(listMessages.get(0).getClass().equals(DataChanged.class));

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:DataChangeListenerProxyTest.java

示例14: throttleOperation

import org.opendaylight.controller.cluster.raft.utils.DoNothingActor; //导入依赖的package包/类
private void throttleOperation(final TransactionProxyOperation operation, final int outstandingOpsLimit,
        final boolean shardFound, final long expectedCompletionTime) {
    ActorSystem actorSystem = getSystem();
    ActorRef shardActorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));

    // Note that we setting batchedModificationCount to one less than what we need because in TransactionProxy
    // we now allow one extra permit to be allowed for ready
    doReturn(dataStoreContextBuilder.operationTimeoutInSeconds(2)
            .shardBatchedModificationCount(outstandingOpsLimit - 1).build()).when(mockActorContext)
                    .getDatastoreContext();

    doReturn(actorSystem.actorSelection(shardActorRef.path())).when(mockActorContext)
            .actorSelection(shardActorRef.path().toString());

    if (shardFound) {
        doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef))).when(mockActorContext)
                .findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
        doReturn(Futures.successful(newPrimaryShardInfo(shardActorRef))).when(mockActorContext)
                .findPrimaryShardAsync(eq("cars"));

    } else {
        doReturn(Futures.failed(new Exception("not found")))
                .when(mockActorContext).findPrimaryShardAsync(eq(DefaultShardStrategy.DEFAULT_SHARD));
    }

    doReturn(incompleteFuture()).when(mockActorContext).executeOperationAsync(
            eq(actorSystem.actorSelection(shardActorRef.path())), eqCreateTransaction(memberName, READ_WRITE),
            any(Timeout.class));

    TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE);

    long start = System.nanoTime();

    operation.run(transactionProxy);

    long end = System.nanoTime();

    Assert.assertTrue(String.format("Expected elapsed time: %s. Actual: %s",
            expectedCompletionTime, end - start),
            end - start > expectedCompletionTime && end - start < expectedCompletionTime * 2);

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:43,代码来源:TransactionProxyTest.java


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