當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。