本文整理汇总了Java中akka.actor.Props类的典型用法代码示例。如果您正苦于以下问题:Java Props类的具体用法?Java Props怎么用?Java Props使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Props类属于akka.actor包,在下文中一共展示了Props类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNegativeReadWithReadOnlyTransactionClosed
import akka.actor.Props; //导入依赖的package包/类
@Test(expected = ReadFailedException.class)
public void testNegativeReadWithReadOnlyTransactionClosed() throws Exception {
final ActorRef shard = createShard();
final Props props = ShardTransaction.props(RO, STORE.newReadOnlyTransaction(nextTransactionId()), shard,
datastoreContext, shardStats);
final TestActorRef<ShardTransaction> subject = TestActorRef.create(getSystem(), props,
"testNegativeReadWithReadOnlyTransactionClosed");
Future<Object> future = akka.pattern.Patterns.ask(subject,
new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000);
Await.result(future, Duration.create(3, TimeUnit.SECONDS));
subject.underlyingActor().getDOMStoreTransaction().abortFromTransactionActor();
future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY,
DataStoreVersions.CURRENT_VERSION), 3000);
Await.result(future, Duration.create(3, TimeUnit.SECONDS));
}
示例2: testDataChangedWhenNotificationsAreDisabled
import akka.actor.Props; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangedWhenNotificationsAreDisabled() {
new JavaTestKit(getSystem()) {
{
final AsyncDataChangeEvent mockChangeEvent = Mockito.mock(AsyncDataChangeEvent.class);
final AsyncDataChangeListener mockListener = Mockito.mock(AsyncDataChangeListener.class);
final Props props = DataChangeListener.props(mockListener, TEST_PATH);
final ActorRef subject = getSystem().actorOf(props, "testDataChangedNotificationsDisabled");
subject.tell(new DataChanged(mockChangeEvent), getRef());
new Within(duration("1 seconds")) {
@Override
protected void run() {
expectNoMsg();
Mockito.verify(mockListener, Mockito.never())
.onDataChanged(Mockito.any(AsyncDataChangeEvent.class));
}
};
}
};
}
示例3: onReceiveOfMessageCoffeeHouseShouldLogMessage
import akka.actor.Props; //导入依赖的package包/类
@Test
public void onReceiveOfMessageCoffeeHouseShouldLogMessage() {
new JavaTestKit(system) {{
ActorRef coffeeHouse = system.actorOf(Props.create(CoffeeHouse.class));
coffeeHouse.tell("Brew Coffee", getRef());
new ExpectMsg<String>("Some [Cc]offee response") {
@Override
protected String match(Object msg) {
if (msg.toString().matches(".*[Cc]offee.*")) {
return "match";
} else {
throw noMatch();
}
}
}.get();
}};
}
示例4: createArea
import akka.actor.Props; //导入依赖的package包/类
private void createArea(int loaclGridId) {
CacheManager cacheManager = ContextResolver.getComponent(CacheManager.class);
if (cacheManager.containsAreaKey(loaclGridId)) {
return;
} else {
String areaId = CacheManager.getAreaId(loaclGridId);
ActorRef actorOf = getContext().actorOf(Props.create(AreaActor.class, areaId), areaId);
AreaInfoCache info=new AreaInfoCache();
info.setAreaId(areaId);
info.setAreaRef(actorOf);
cacheManager.putAreaInfoCache(areaId,info);
getContext().watch(actorOf);
String identifier = Serialization.serializedActorPath(actorOf);
cacheManager.putAreaManagerPath(areaId, identifier);
}
}
示例5: createWorldUser
import akka.actor.Props; //导入依赖的package包/类
private void createWorldUser(String reBindKey, String name, String parms, ActorRef iosessionRef) {
int id = USER_ID.incrementAndGet();
User user = new User();
ActorRef actorOf = null;
ActorContext context = getContext();
String userid = PrefixConstant.USER_PRFIX + id;
user.setUserId(userid);
user.setLoginName(name);
user.setLoginParms(parms);
UserConnect2Server connect2Server = new UserConnect2Server();
try {
actorOf = context.actorOf(Props.create(UserActor.class, user, iosessionRef, getSelf()), userid);
user.setActorRef(actorOf);
userRefMap.put(userid, actorOf);
connect2Server.success = true;
connect2Server.bindingkey = reBindKey;
} catch (Exception e) {
connect2Server.success = false;
connect2Server.bindingkey = "";
}
byte[] actorMessageWithSubClass = thriftSerializerFactory.getActorMessageByteArray(Operation.SESSION_USER_CONNECT_TO_SERVER, connect2Server);
iosessionRef.tell(actorMessageWithSubClass, actorOf);
}
示例6: triggerPractitionerOrchestrator
import akka.actor.Props; //导入依赖的package包/类
private void triggerPractitionerOrchestrator(List<Practitioner> listPractitionerToProcess,
PractitionerOrchestratorActor.ResolvePractitionerRequest practitionerRequest)
{
this.listOfValidPractitioner=listPractitionerToProcess;
nbrOfSearchRequestToWaitFor=this.listOfValidPractitioner.size();
List<String> listOfId=new ArrayList<>();
for(Practitioner oPractitionerToIdentify:listOfValidPractitioner)
{
listOfId.add(oPractitionerToIdentify.getId().getIdPart());
}
listIdsPractitionerUsedForSearch=listOfId;
practitionerRequest=new PractitionerOrchestratorActor.ResolvePractitionerRequest(
originalRequest.getRequestHandler(),
getSelf(),
listOfId
);
ActorRef practitionerRequestOrchestrator=getContext().actorOf(
Props.create(PractitionerOrchestratorActor.class,config));
practitionerRequestOrchestrator.tell(practitionerRequest,getSelf());
}
示例7: setUp
import akka.actor.Props; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
system = ActorSystem.create("test");
final DOMRpcIdentifier emptyRpcIdentifier = DOMRpcIdentifier.create(
EMPTY_SCHEMA_PATH, YangInstanceIdentifier.EMPTY);
final DOMRpcIdentifier localRpcIdentifier = DOMRpcIdentifier.create(
LOCAL_SCHEMA_PATH, YangInstanceIdentifier.of(LOCAL_QNAME));
buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier);
final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build();
final JavaTestKit invoker = new JavaTestKit(system);
final JavaTestKit registrar = new JavaTestKit(system);
final JavaTestKit supervisor = new JavaTestKit(system);
final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef());
testActor = new TestActorRef<>(system, props, supervisor.getRef(), "testActor");
final RpcRegistry rpcRegistry = testActor.underlyingActor();
mxBean = new RemoteRpcRegistryMXBeanImpl(rpcRegistry);
Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
}
示例8: testInvalidCreateTransactionReply
import akka.actor.Props; //导入依赖的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));
}
示例9: triggerBasicOrchestrator
import akka.actor.Props; //导入依赖的package包/类
private void triggerBasicOrchestrator(List<Basic> listBasicToProcess,
BasicOrchestratorActor.ResolveBasicRequest basicRequest)
{
this.listOfValidBasic=listBasicToProcess;
nbrOfSearchRequestToWaitFor=this.listOfValidBasic.size();
List<String> listOfId=new ArrayList<>();
for(Basic oBasic:listOfValidBasic)
{
listOfId.add(oBasic.getId().getIdPart());
}
listIdsBasicUsedForSearch=listOfId;
basicRequest=new BasicOrchestratorActor.ResolveBasicRequest(
originalRequest.getRequestHandler(),
getSelf(),
listOfId
);
ActorRef basicRequestOrchestrator=getContext().actorOf(
Props.create(BasicOrchestratorActor.class,config));
basicRequestOrchestrator.tell(basicRequest,getSelf());
}
示例10: testOnDataTreeChanged
import akka.actor.Props; //导入依赖的package包/类
@Test
public void testOnDataTreeChanged() {
final LeaderLocationListener listener = mock(LeaderLocationListener.class);
doNothing().when(listener).onLeaderLocationChanged(any());
final Props props = RoleChangeListenerActor.props(getSystem().deadLetters(), listener);
final ActorRef subject = getSystem().actorOf(props, "testDataTreeChangedChanged");
subject.tell(new LeaderStateChanged("member-1", null, (short) 0), noSender());
verify(listener, timeout(5000)).onLeaderLocationChanged(eq(LeaderLocation.UNKNOWN));
subject.tell(new LeaderStateChanged("member-1", "member-1", (short) 0), noSender());
verify(listener, timeout(5000)).onLeaderLocationChanged(eq(LeaderLocation.LOCAL));
subject.tell(new LeaderStateChanged("member-1", "member-2", (short) 0), noSender());
verify(listener, timeout(5000)).onLeaderLocationChanged(eq(LeaderLocation.REMOTE));
}
示例11: createDatastoreClient
import akka.actor.Props; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
private Entry<DataStoreClient, ActorRef> createDatastoreClient(
final String shardName, final ActorContext actorContext)
throws DOMDataTreeShardCreationFailedException {
LOG.debug("{}: Creating distributed datastore client for shard {}", memberName, shardName);
final Props distributedDataStoreClientProps =
SimpleDataStoreClientActor.props(memberName, "Shard-" + shardName, actorContext, shardName);
final ActorRef clientActor = actorSystem.actorOf(distributedDataStoreClientProps);
try {
return new SimpleEntry<>(SimpleDataStoreClientActor
.getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS), clientActor);
} catch (final Exception e) {
LOG.error("{}: Failed to get actor for {}", distributedDataStoreClientProps, memberName, e);
clientActor.tell(PoisonPill.getInstance(), noSender());
throw new DOMDataTreeShardCreationFailedException(
"Unable to create datastore client for shard{" + shardName + "}", e);
}
}
示例12: shouldCreateChildActorCalledBaristaWhenCreated
import akka.actor.Props; //导入依赖的package包/类
@Test
public void shouldCreateChildActorCalledBaristaWhenCreated() {
new JavaTestKit(system) {{
system.actorOf(Props.create(CoffeeHouse.class), "create-barista");
expectActor(this, "/user/create-barista/waiter");
}};
}
示例13: printerProps
import akka.actor.Props; //导入依赖的package包/类
private static Props printerProps(ActorRef coffeeHouse) {
return Props.create(AbstractLoggingActor.class, () -> new AbstractLoggingActor() {
{
coffeeHouse.tell("Brew Coffee", self());
receive(ReceiveBuilder.
matchAny(o -> log().info(o.toString())).build()
);
}
});
}
示例14: shouldCreateGuestActorsWhenCreateGuestMessageSent
import akka.actor.Props; //导入依赖的package包/类
@Test
public void shouldCreateGuestActorsWhenCreateGuestMessageSent() {
new JavaTestKit(system) {{
ActorRef coffeeHouse = system.actorOf(Props.create(CoffeeHouse.class), "create-guest");
coffeeHouse.tell(new CoffeeHouse.CreateGuest(new Coffee.Akkaccino()), ActorRef.noSender());
expectActor(this, "/user/create-guest/$*");
}};
}
示例15: printerProps
import akka.actor.Props; //导入依赖的package包/类
private static Props printerProps(ActorRef coffeeHouse) {
return Props.create(AbstractLoggingActor.class, () -> new AbstractLoggingActor() {
@Override
public Receive createReceive() {
return receiveBuilder().matchAny(o -> log().info(o.toString())).build();
}
{
coffeeHouse.tell("Brew Coffee", self());
}
});
}