本文整理汇总了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);
}
示例2: createStubActor
import akka.japi.Creator; //导入依赖的package包/类
public ActorRef createStubActor(String name, Creator<AbstractActor> factory) {
return createActor(AbstractActor.class, name, factory);
}
示例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();
}
};
}
示例4: DelegatingShardCreator
import akka.japi.Creator; //导入依赖的package包/类
DelegatingShardCreator(final Creator<Shard> delegate) {
this.delegate = delegate;
}