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


Java Creator类代码示例

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


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

示例1: createActor

import akka.japi.Creator; //导入依赖的package包/类
public <T extends AbstractActor> ActorRef createActor(Class<T> clazz, String name, Creator<T> factory) {
    Props stub = Props.create(clazz, factory);
    return system.actorOf(stub, name);
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:5,代码来源:BaseAkkaTestCase.java

示例2: createStubActor

import akka.japi.Creator; //导入依赖的package包/类
public ActorRef createStubActor(String name, Creator<AbstractActor> factory) {
    return createActor(AbstractActor.class, name, factory);
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-with-akka,代码行数:4,代码来源:BaseAkkaTestCase.java

示例3: testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration

import akka.japi.Creator; //导入依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration() throws Exception {
    final CountDownLatch onFirstElectionTimeout = new CountDownLatch(1);
    final CountDownLatch onChangeListenerRegistered = new CountDownLatch(1);
    final Creator<Shard> creator = new Creator<Shard>() {
        boolean firstElectionTimeout = true;

        @Override
        public Shard create() throws Exception {
            return new Shard(newShardBuilder()) {
                @Override
                public void handleCommand(final Object message) {
                    if (message instanceof ElectionTimeout && firstElectionTimeout) {
                        firstElectionTimeout = false;
                        final ActorRef self = getSelf();
                        new Thread(() -> {
                            Uninterruptibles.awaitUninterruptibly(
                                    onChangeListenerRegistered, 5, TimeUnit.SECONDS);
                            self.tell(message, self);
                        }).start();

                        onFirstElectionTimeout.countDown();
                    } else {
                        super.handleCommand(message);
                    }
                }
            };
        }
    };

    setupInMemorySnapshotStore();

    final YangInstanceIdentifier path = TestModel.TEST_PATH;
    final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1);
    final ActorRef dclActor = actorFactory.createActor(DataTreeChangeListenerActor.props(listener, path),
            "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration-DataChangeListener");

    final TestActorRef<Shard> shard = actorFactory.createTestActor(
            Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
            "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration");

    new ShardTestKit(getSystem()) {
        {
            assertEquals("Got first ElectionTimeout", true, onFirstElectionTimeout.await(5, TimeUnit.SECONDS));

            shard.tell(new RegisterDataTreeChangeListener(path, dclActor, false), getRef());
            final RegisterDataTreeNotificationListenerReply reply = expectMsgClass(duration("5 seconds"),
                    RegisterDataTreeNotificationListenerReply.class);
            assertNotNull("getListenerRegistratioznPath", reply.getListenerRegistrationPath());

            shard.tell(FindLeader.INSTANCE, getRef());
            final FindLeaderReply findLeadeReply = expectMsgClass(duration("5 seconds"), FindLeaderReply.class);
            assertFalse("Expected the shard not to be the leader", findLeadeReply.getLeaderActor().isPresent());

            onChangeListenerRegistered.countDown();

            // TODO: investigate why we do not receive data chage events
            listener.waitForChangeEvents();
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:63,代码来源:ShardTest.java

示例4: DelegatingShardCreator

import akka.japi.Creator; //导入依赖的package包/类
DelegatingShardCreator(final Creator<Shard> delegate) {
    this.delegate = delegate;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:AbstractShardTest.java


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