Java 类akka.actor.Props 实例源码

项目:hashsdn-controller    文件:ShardTransactionFailureTest.java   
@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));
}
项目:hashsdn-controller    文件:DataChangeListenerTest.java   
@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));
                }
            };
        }
    };
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseTest.java   
@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();
    }};
}
项目:CodeBroker    文件:AreaManagerActor.java   
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);
    }
}
项目:CodeBroker    文件:UserManagerActor.java   
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);

}
项目:DHIS2-fhir-lab-app    文件:DefaultOrchestrator.java   
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());
}
项目:hashsdn-controller    文件:RemoteRpcRegistryMXBeanImplTest.java   
@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);
}
项目:hashsdn-controller    文件:TransactionProxyTest.java   
@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));
}
项目:DHIS2-fhir-lab-app    文件:DefaultOrchestrator.java   
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());
}
项目:hashsdn-controller    文件:RoleChangeListenerActorTest.java   
@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));

}
项目:hashsdn-controller    文件:DistributedShardedDOMDataTree.java   
@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);
    }
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseTest.java   
@Test
public void shouldCreateChildActorCalledBaristaWhenCreated() {
    new JavaTestKit(system) {{
        system.actorOf(Props.create(CoffeeHouse.class), "create-barista");
        expectActor(this, "/user/create-barista/waiter");
    }};
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseApp.java   
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()
            );
        }
    });
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseTest.java   
@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/$*");
    }};
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseApp.java   
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());
        }
    });
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseTest.java   
@Test
public void shouldCreateChildActorCalledWaiterWhenCreated() {
    new JavaTestKit(system) {{
        system.actorOf(Props.create(CoffeeHouse.class), "create-waiter");
        expectActor(this, "/user/create-waiter/waiter");
    }};
}
项目:SO_reputation    文件:Master.java   
public Master( Timestamp start, final int numberOfWorkers, ActorRef listener )
{
    // Save our parameters locally
    this.start = start;
    this.numberOfWorkers = numberOfWorkers;
    this.listener = listener;

    // Create a new router to distribute messages out to the workers
    workerRouter = this.getContext()
            .actorOf( new Props(Worker.class )
                    .withRouter( new RoundRobinRouter( numberOfWorkers )), "workerRouter" );
}
项目:hashsdn-controller    文件:RemoteRpcProviderConfigTest.java   
@Test
public void testConfigCustomizations() {

    AkkaConfigurationReader reader = new TestConfigReader();

    final int expectedCapacity = 100;
    String timeOutVal = "10ms";
    FiniteDuration expectedTimeout = FiniteDuration.create(10, TimeUnit.MILLISECONDS);

    RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("unit-test")
            .metricCaptureEnabled(true)//enable metric capture
            .mailboxCapacity(expectedCapacity)
            .mailboxPushTimeout(timeOutVal)
            .withConfigReader(reader)
            .build();

    Assert.assertTrue(config.isMetricCaptureEnabled());
    Assert.assertEquals(expectedCapacity, config.getMailBoxCapacity().intValue());
    Assert.assertEquals(expectedTimeout.toMillis(), config.getMailBoxPushTimeout().toMillis());

    //Now check this config inside an actor
    ActorSystem system = ActorSystem.create("unit-test", config.get());
    TestActorRef<ConfigTestActor> configTestActorTestActorRef =
            TestActorRef.create(system, Props.create(ConfigTestActor.class));

    ConfigTestActor actor = configTestActorTestActorRef.underlyingActor();
    Config actorConfig = actor.getConfig();

    config = new RemoteRpcProviderConfig(actorConfig);

    Assert.assertTrue(config.isMetricCaptureEnabled());
    Assert.assertEquals(expectedCapacity, config.getMailBoxCapacity().intValue());
    Assert.assertEquals(expectedTimeout.toMillis(), config.getMailBoxPushTimeout().toMillis());
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseApp.java   
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()
            );
        }
    });
}
项目:hashsdn-controller    文件:DataChangeListenerTest.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataChangedWithNoSender() {
    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, "testDataChangedWithNoSender");

            getSystem().eventStream().subscribe(getRef(), DeadLetter.class);

            subject.tell(new DataChanged(mockChangeEvent), ActorRef.noSender());

            // Make sure no DataChangedReply is sent to DeadLetters.
            while (true) {
                DeadLetter deadLetter;
                try {
                    deadLetter = expectMsgClass(duration("1 seconds"), DeadLetter.class);
                } catch (AssertionError e) {
                    // Timed out - got no DeadLetter - this is good
                    break;
                }

                // We may get DeadLetters for other messages we don't care
                // about.
                Assert.assertFalse("Unexpected DataChangedReply", deadLetter.message() instanceof DataChangedReply);
            }
        }
    };
}
项目:hashsdn-controller    文件:GossiperTest.java   
@BeforeClass
public static void setup() throws InterruptedException {
    system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("unit-test"));
    system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");

    gossiper = createGossiper();
}
项目:iotplatform    文件:AppActor.java   
private ActorRef getOrCreateTenantActor(TenantId tenantId) {
  ActorRef tenantActor = tenantActors.get(tenantId);
  if (tenantActor == null) {
    tenantActor = context().actorOf(Props.create(new TenantActor.ActorCreator(systemContext, tenantId))
        .withDispatcher(DefaultActorService.CORE_DISPATCHER_NAME), tenantId.toString());
    tenantActors.put(tenantId, tenantActor);
  }
  return tenantActor;
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseTest.java   
@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/$*");
    }};
}
项目:DHIS2-fhir-lab-app    文件:DefaultOrchestrator.java   
private void triggerSpecimenOrchestrator(List<Specimen> listSpecimenToProcess,
                                        SpecimenOrchestratorActor.ResolveSpecimenRequest specimenRequest)
{
    this.listOfValidSpecimen=listSpecimenToProcess;
    nbrOfSearchRequestToWaitFor=this.listOfValidSpecimen.size();
    List<String> listOfId=new ArrayList<>();
    for(Specimen oSpecimenToIdentify:listOfValidSpecimen)
    {
        listOfId.add(oSpecimenToIdentify.getId().getIdPart());

    }
    listIdsSpecimenUsedForSearch=listOfId;
    /*
    specimenRequest=new SpecimenOrchestratorActor.ResolveSpecimenRequest(
            originalRequest.getRequestHandler(),
            getSelf(),
            listOfId
    );*/
    specimenRequest=new SpecimenOrchestratorActor.ResolveSpecimenRequest(
            originalRequest.getRequestHandler(),
            getSelf(),
            null
    );
    ActorRef specimenRequestOrchestrator=getContext().actorOf(
            Props.create(SpecimenOrchestratorActor.class,config));
    specimenRequestOrchestrator.tell(specimenRequest,getSelf());
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseApp.java   
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", getSelf());
        }
    });
}
项目:CodeBroker    文件:TestNUserManagerActor.java   
@Test
public void testIt() {
    new TestKit(system) {
        {
            UserManager manager = new UserManager();
            final ActorRef actorRef = system.actorOf(Props.create(UserManagerActor.class, manager), CodeBrokerSystem.IDENTIFY);

            try {
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
}
项目:CodeBroker    文件:NettyIoSession.java   
public NettyIoSession(ChannelHandlerContext ctx) {
    super();
    this.ctx = ctx;
    ActorSystem actorSystem = AkkaUtil.getActorSystem();
    this.sessionId = NettyServerMonitor.sessionIds.getAndIncrement();
    actorRef = actorSystem.actorOf(Props.create(SessionActor.class, this), (NAME + "_" + sessionId));
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
private static Props printerProps(ActorRef coffeeHouse) {
    return Props.create(AbstractLoggingActor.class, () -> {
        return new AbstractLoggingActor() {
            @Override
            public Receive createReceive() {
                return receiveBuilder().matchAny(o -> log().info(o.toString())).build();
            }

            {
                coffeeHouse.tell("Brew Coffee", self());
            }
        };
    });
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseTest.java   
@Test
public void shouldCreateChildActorCalledWaiterWhenCreated() {
    new JavaTestKit(system) {{
        system.actorOf(Props.create(CoffeeHouse.class), "create-waiter");
        expectActor(this, "/user/create-waiter/waiter");
    }};
}
项目:Learning-Spring-5.0    文件:TestActor.java   
public static void main(String[] args) {
    ActorSystem actorSystem = ActorSystem.create("PacktSystem");
    ActorRef actorRef = actorSystem.actorOf(new Props(Actor1.class),
            "actor1");
    actorRef.tell(new MyMessage("Hello Welcome to Akka!"));

    try {
        Thread.sleep(3000);
    } catch (Exception e) {
    }

    actorSystem.stop(actorRef);
    actorSystem.shutdown();

}
项目:sunbird-lms-mw    文件:Application.java   
/**
 * This method will do the basic setup for actors.
 */
private static void startBackgroundRemoteActorSystem() {
  try{
  Config con = null;
  String host = System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_IP);
  String port = System.getenv(JsonKey.BKG_SUNBIRD_ACTOR_SERVICE_PORT);

  if (!ProjectUtil.isStringNullOREmpty(host) && !ProjectUtil.isStringNullOREmpty(port)) {
    con = ConfigFactory
        .parseString(
            "akka.remote.netty.tcp.hostname=" + host + ",akka.remote.netty.tcp.port=" + port + "")
        .withFallback(ConfigFactory.load().getConfig(BKG_ACTOR_CONFIG_NAME));
  } else {
    con = ConfigFactory.load().getConfig(BKG_ACTOR_CONFIG_NAME);
  }
  ActorSystem system = ActorSystem.create(BKG_REMOTE_ACTOR_SYSTEM_NAME, con);
  ActorRef learnerActorSelectorRef =
      system.actorOf(Props.create(BackgroundRequestRouterActor.class),
          BackgroundRequestRouterActor.class.getSimpleName());
  ProjectLogger.log("start BkgRemoteCreationSystem method called....");
  ProjectLogger.log("bkgActorSelectorRef " + learnerActorSelectorRef);
  ProjectLogger.log("BACKGROUND ACTORS STARTED " + learnerActorSelectorRef,
      LoggerEnum.INFO.name());
  checkCassandraConnection();
  }catch(Exception ex){
    ProjectLogger.log("Exception occurred while starting BackgroundRemoteActorSystem  in Application.java "+ex);
  }
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseTest.java   
@Test
public void onReceiveOfMessageCoffeeHouseShouldLogMessage() {
    new JavaTestKit(system) {{
        ActorRef coffeeHouse = system.actorOf(Props.create(CoffeeHouse.class));
        interceptInfoLogMessage(this, ".*[Cc]offee.*", 1, () -> coffeeHouse.tell("Brew Coffee", ActorRef.noSender()));
    }};
}
项目:hashsdn-controller    文件:ShardTest.java   
@Test
public void testRecoveryApplicable() {

    final DatastoreContext persistentContext = DatastoreContext.newBuilder()
            .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).persistent(true).build();

    final Props persistentProps = Shard.builder().id(shardID).datastoreContext(persistentContext)
            .schemaContextProvider(() -> SCHEMA_CONTEXT).props();

    final DatastoreContext nonPersistentContext = DatastoreContext.newBuilder()
            .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).persistent(false).build();

    final Props nonPersistentProps = Shard.builder().id(shardID).datastoreContext(nonPersistentContext)
            .schemaContextProvider(() -> SCHEMA_CONTEXT).props();

    new ShardTestKit(getSystem()) {
        {
            final TestActorRef<Shard> shard1 = actorFactory.createTestActor(persistentProps, "testPersistence1");

            assertTrue("Recovery Applicable", shard1.underlyingActor().persistence().isRecoveryApplicable());

            final TestActorRef<Shard> shard2 = actorFactory.createTestActor(nonPersistentProps, "testPersistence2");

            assertFalse("Recovery Not Applicable", shard2.underlyingActor().persistence().isRecoveryApplicable());
        }
    };
}
项目:hashsdn-controller    文件:AbstractTransactionProxyTest.java   
protected ActorRef setupActorContextWithoutInitialCreateTransaction(final ActorSystem actorSystem,
        final String shardName, final short transactionVersion) {
    ActorRef actorRef = actorSystem.actorOf(Props.create(DoNothingActor.class));
    log.info("Created mock shard actor {}", actorRef);

    doReturn(actorSystem.actorSelection(actorRef.path()))
            .when(mockActorContext).actorSelection(actorRef.path().toString());

    doReturn(primaryShardInfoReply(actorSystem, actorRef, transactionVersion))
            .when(mockActorContext).findPrimaryShardAsync(eq(shardName));

    return actorRef;
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseApp.java   
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()
            );
        }
    });
}
项目:CodeBroker    文件:GameServerListener.java   
@Override
public void init(Object obj) {
    this.configProperties = (PropertiesWrapper) obj;
    /**
     * 注册handler
     */
    HandlerRegisterCenter.registerServerEventHandler(this);
    // 初始化DB
    JongoDBService dbService = new JongoDBService();
    dbService.init(obj);

    ActorSystem actorSystem = AppContext.getActorSystem();
    ActorRef actorOf = actorSystem.actorOf(Props.create(ReplicatedCache.class), "ReplicatedCache");
    System.out.println(actorOf.path().toString());
    try {
        IArea createGrid1 = AppContext.getAreaManager().createArea(1);
        createGrid1.createGrid("G1");
        createGrid1.createGrid("G2");
        createGrid1.createGrid("G3");
        IArea createGrid2 = AppContext.getAreaManager().createArea(2);
        createGrid2.createGrid("G1");
        createGrid2.createGrid("G2");
        createGrid2.createGrid("G3");
    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
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());
        }
    });
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseTest.java   
@Test
public void shouldCreateChildActorCalledBaristaWhenCreated() {
    new JavaTestKit(system) {{
        system.actorOf(Props.create(CoffeeHouse.class), "create-barista");
        expectActor(this, "/user/create-barista/waiter");
    }};
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
private static Props printerProps(ActorRef coffeeHouse) {
    return Props.create(AbstractLoggingActor.class, () -> {
        return new AbstractLoggingActor() {
            @Override
            public Receive createReceive() {
                return receiveBuilder().matchAny(o -> log().info(o.toString())).build();
            }

            {
                coffeeHouse.tell("Brew Coffee", self());
            }
        };
    });
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseTest.java   
@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/$*");
    }};
}