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


Java Props类代码示例

本文整理汇总了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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:ShardTransactionFailureTest.java

示例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));
                }
            };
        }
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:DataChangeListenerTest.java

示例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();
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:18,代码来源:CoffeeHouseTest.java

示例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);
    }
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:18,代码来源:AreaManagerActor.java

示例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);

}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:26,代码来源:UserManagerActor.java

示例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());
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:22,代码来源:DefaultOrchestrator.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:RemoteRpcRegistryMXBeanImplTest.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:TransactionProxyTest.java

示例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());
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:22,代码来源:DefaultOrchestrator.java

示例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));

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

示例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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:DistributedShardedDOMDataTree.java

示例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");
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:8,代码来源:CoffeeHouseTest.java

示例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()
            );
        }
    });
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:12,代码来源:CoffeeHouseApp.java

示例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/$*");
    }};
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-old,代码行数:9,代码来源:CoffeeHouseTest.java

示例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());
        }
    });
}
 
开发者ID:ironfish,项目名称:oreilly-reactive-architecture-student,代码行数:13,代码来源:CoffeeHouseApp.java


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