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


Java MockClusterWrapper类代码示例

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


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

示例1: testAddShardReplicaWithFindPrimaryTimeout

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Test
public void testAddShardReplicaWithFindPrimaryTimeout() throws Exception {
    LOG.info("testAddShardReplicaWithFindPrimaryTimeout starting");
    datastoreContextBuilder.shardInitializationTimeout(100, TimeUnit.MILLISECONDS);
    new JavaTestKit(getSystem()) {
        {
            MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder()
                    .put("astronauts", Arrays.asList("member-2")).build());

            final ActorRef newReplicaShardManager = actorFactory
                    .createActor(newTestShardMgrBuilder(mockConfig).shardActor(mockShardActor).props()
                            .withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);

            newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            MockClusterWrapper.sendMemberUp(newReplicaShardManager, "member-2",
                    AddressFromURIString.parse("akka://[email protected]:5").toString());

            newReplicaShardManager.tell(new AddShardReplica("astronauts"), getRef());
            Status.Failure resp = expectMsgClass(duration("5 seconds"), Status.Failure.class);
            assertEquals("Failure obtained", true, resp.cause() instanceof RuntimeException);
        }
    };

    LOG.info("testAddShardReplicaWithFindPrimaryTimeout ending");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ShardManagerTest.java

示例2: setUp

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Before
public void setUp() {
    DatastoreContext datastoreContext = DatastoreContext.newBuilder().dataStoreName(dataStoreName)
            .shardInitializationTimeout(10, TimeUnit.SECONDS).build();

    Configuration configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()) {
        @Override
        public Collection<MemberName> getUniqueMemberNamesForAllShards() {
            return Sets.newHashSet(MemberName.forName("member-1"));
        }
    };

    DatastoreContextFactory mockContextFactory = mock(DatastoreContextFactory.class);
    Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
    Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());

    dataStore = new DistributedDataStore(getSystem(), new MockClusterWrapper(), configuration,
            mockContextFactory, null);

    dataStore.onGlobalContextUpdated(SchemaContextHelper.entityOwners());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:DistributedEntityOwnershipServiceTest.java

示例3: testRoleChangeNotificationToFollowerWithShardLeaderStateChangedReleaseReady

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Test
public void testRoleChangeNotificationToFollowerWithShardLeaderStateChangedReleaseReady() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            TestShardManager shardManager = newTestShardManager();

            String memberId = "member-1-shard-default-" + shardMrgIDSuffix;
            shardManager.onReceiveCommand(new RoleChangeNotification(memberId, null, RaftState.Follower.name()));

            verify(ready, never()).countDown();

            shardManager
                    .onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString()));

            shardManager.onReceiveCommand(
                    new ShardLeaderStateChanged(memberId, "member-2-shard-default-" + shardMrgIDSuffix,
                            mock(DataTree.class), DataStoreVersions.CURRENT_VERSION));

            verify(ready, times(1)).countDown();
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:ShardManagerTest.java

示例4: testReadyCountDownForMemberUpAfterLeaderStateChanged

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Test
public void testReadyCountDownForMemberUpAfterLeaderStateChanged() throws Exception {
    new JavaTestKit(getSystem()) {
        {
            TestShardManager shardManager = newTestShardManager();

            String memberId = "member-1-shard-default-" + shardMrgIDSuffix;
            shardManager.onReceiveCommand(new RoleChangeNotification(memberId, null, RaftState.Follower.name()));

            verify(ready, never()).countDown();

            shardManager.onReceiveCommand(
                    new ShardLeaderStateChanged(memberId, "member-2-shard-default-" + shardMrgIDSuffix,
                            mock(DataTree.class), DataStoreVersions.CURRENT_VERSION));

            shardManager
                    .onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString()));

            verify(ready, times(1)).countDown();
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:ShardManagerTest.java

示例5: setUp

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的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

示例6: testOnReceiveFindPrimaryForNonLocalLeaderShard

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Test
public void testOnReceiveFindPrimaryForNonLocalLeaderShard() throws Exception {
    LOG.info("testOnReceiveFindPrimaryForNonLocalLeaderShard starting");
    new JavaTestKit(getSystem()) {
        {
            final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());

            shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            shardManager.tell(new ActorInitialized(), mockShardActor);

            String memberId2 = "member-2-shard-default-" + shardMrgIDSuffix;
            MockClusterWrapper.sendMemberUp(shardManager, "member-2", getRef().path().toString());

            String memberId1 = "member-1-shard-default-" + shardMrgIDSuffix;
            shardManager.tell(
                    new RoleChangeNotification(memberId1, RaftState.Candidate.name(), RaftState.Follower.name()),
                    mockShardActor);
            short leaderVersion = DataStoreVersions.CURRENT_VERSION - 1;
            shardManager.tell(new ShardLeaderStateChanged(memberId1, memberId2, leaderVersion), mockShardActor);

            shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), getRef());

            RemotePrimaryShardFound primaryFound = expectMsgClass(duration("5 seconds"),
                    RemotePrimaryShardFound.class);
            assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(),
                    primaryFound.getPrimaryPath().contains("member-2-shard-default"));
            assertEquals("getPrimaryVersion", leaderVersion, primaryFound.getPrimaryVersion());
        }
    };

    LOG.info("testOnReceiveFindPrimaryForNonLocalLeaderShard ending");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:33,代码来源:ShardManagerTest.java

示例7: testServerChangeWhenAlreadyInProgress

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
public void testServerChangeWhenAlreadyInProgress(final String shardName, final Object firstServerChange,
                                                  final Class<?> firstForwardedServerChangeClass,
                                                  final Object secondServerChange) throws Exception {
    new JavaTestKit(getSystem()) {
        {
            JavaTestKit mockShardLeaderKit = new JavaTestKit(getSystem());
            final JavaTestKit secondRequestKit = new JavaTestKit(getSystem());

            MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder()
                    .put(shardName, Arrays.asList("member-2")).build());

            final TestActorRef<TestShardManager> shardManager = TestActorRef.create(getSystem(),
                    newTestShardMgrBuilder().configuration(mockConfig).shardActor(mockShardActor)
                            .cluster(new MockClusterWrapper()).props()
                            .withDispatcher(Dispatchers.DefaultDispatcherId()),
                    shardMgrID);

            shardManager.underlyingActor()
                    .setMessageInterceptor(newFindPrimaryInterceptor(mockShardLeaderKit.getRef()));

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

            shardManager.tell(firstServerChange, getRef());

            mockShardLeaderKit.expectMsgClass(firstForwardedServerChangeClass);

            shardManager.tell(secondServerChange, secondRequestKit.getRef());

            secondRequestKit.expectMsgClass(duration("5 seconds"), Failure.class);
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:33,代码来源:ShardManagerTest.java

示例8: testOnDataChanged

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的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

示例9: testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
@Test
public void testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader() throws Exception {
    LOG.info("testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader starting");
    new JavaTestKit(getSystem()) {
        {
            TestActorRef<TestShardManager> shardManager = actorFactory
                    .createTestActor(newPropsShardMgrWithMockShardActor(), shardMgrID);

            shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
            shardManager.tell(new ActorInitialized(), mockShardActor);

            String leaderId = "leader-member-shard-default-" + shardMrgIDSuffix;
            AddServerReply addServerReply = new AddServerReply(ServerChangeStatus.ALREADY_EXISTS, null);
            ActorRef leaderShardActor = shardManager.underlyingActor().getContext()
                    .actorOf(Props.create(MockRespondActor.class, AddServer.class, addServerReply), leaderId);

            MockClusterWrapper.sendMemberUp(shardManager, "leader-member", leaderShardActor.path().toString());

            String newReplicaId = "member-1-shard-default-" + shardMrgIDSuffix;
            shardManager.tell(
                    new RoleChangeNotification(newReplicaId, RaftState.Candidate.name(), RaftState.Follower.name()),
                    mockShardActor);
            shardManager.tell(
                    new ShardLeaderStateChanged(newReplicaId, leaderId, DataStoreVersions.CURRENT_VERSION),
                    mockShardActor);

            shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), getRef());

            MessageCollectorActor.expectFirstMatching(leaderShardActor, AddServer.class);

            Failure resp = expectMsgClass(duration("5 seconds"), Failure.class);
            assertEquals("Failure cause", AlreadyExistsException.class, resp.cause().getClass());

            shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), getRef());
            expectMsgClass(duration("5 seconds"), LocalShardFound.class);

            // Send message again to verify previous in progress state is
            // cleared

            shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), getRef());
            resp = expectMsgClass(duration("5 seconds"), Failure.class);
            assertEquals("Failure cause", AlreadyExistsException.class, resp.cause().getClass());

            // Send message again with an AddServer timeout to verify the
            // pre-existing shard actor isn't terminated.

            shardManager.tell(
                    newDatastoreContextFactory(
                            datastoreContextBuilder.shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build()),
                    getRef());
            leaderShardActor.tell(MockRespondActor.CLEAR_RESPONSE, ActorRef.noSender());
            shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), getRef());
            expectMsgClass(duration("5 seconds"), Failure.class);

            shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), getRef());
            expectMsgClass(duration("5 seconds"), LocalShardFound.class);
        }
    };

    LOG.info("testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader ending");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:62,代码来源:ShardManagerTest.java

示例10: AbstractGenericCreator

import org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; //导入依赖的package包/类
AbstractGenericCreator(final Class<C> shardManagerClass) {
    this.shardManagerClass = shardManagerClass;
    cluster(new MockClusterWrapper()).configuration(new MockConfiguration()).waitTillReadyCountDownLatch(ready)
            .primaryShardInfoCache(new PrimaryShardInfoFutureCache());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ShardManagerTest.java


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