Java 类akka.actor.ActorSystem 实例源码

项目:talk-kafka-messaging-logs    文件:KafkaProducer.java   
public static void main(String[] args) {
    final ActorSystem system = ActorSystem.create("KafkaProducerSystem");

    final Materializer materializer = ActorMaterializer.create(system);

    final ProducerSettings<byte[], String> producerSettings =
            ProducerSettings
                    .create(system, new ByteArraySerializer(), new StringSerializer())
                    .withBootstrapServers("localhost:9092");

    CompletionStage<Done> done =
            Source.range(1, 100)
                    .map(n -> n.toString())
                    .map(elem ->
                            new ProducerRecord<byte[], String>(
                                    "topic1-ts",
                                    0,
                                    Instant.now().getEpochSecond(),
                                    null,
                                    elem))
                    .runWith(Producer.plainSink(producerSettings), materializer);

    done.whenComplete((d, ex) -> System.out.println("sent"));
}
项目:ujug2017    文件:Main.java   
public static void main(String[] args) throws Exception {
    ActorSystem system = ActorSystem.create("ServiceB");
    final Http http = Http.get(system);
    final ActorMaterializer materializer = ActorMaterializer.create(system);
    final Main app = new Main();
    final ActorRef serviceBackendActor = system.actorOf(BackendActor.props(), "backendActor");
    final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow =  app.createRoute(serviceBackendActor).flow(system, materializer);

    final CompletionStage<ServerBinding> binding =
            http.bindAndHandle(
                    routeFlow,
                    ConnectHttp.toHost("localhost", 8081),
                    materializer);

    System.out.println("Server online at http://localhost:8081/\nPress RETURN to stop...");
    System.in.read(); // let it run until user presses return
    binding
            .thenCompose(ServerBinding::unbind) // trigger unbinding from the port
            .thenAccept(unbound -> system.terminate()); // and shutdown when done

}
项目:ujug2017    文件:StreamMain.java   
public static void main(String[] args) throws IOException {
    final ActorSystem system = ActorSystem.create("ServiceA");
    final Http http = Http.get(system);
    final ActorMaterializer materializer = ActorMaterializer.create(system);
    final StreamMain app = new StreamMain();
    final ActorRef streamActor = system.actorOf(StreamActor.props());
    final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = app.createRoute(streamActor).flow(system, materializer);
    final CompletionStage<ServerBinding> binding =
            http.bindAndHandle(
                    routeFlow,
                    ConnectHttp.toHost("localhost", 8080),
                    materializer);

    System.out.println("Server online at http://localhost:8080/\nPress RETURN to stop...");
    System.in.read(); // let it run until user presses return
    System.in.read(); // let it run until user presses return
    binding
            .thenCompose(ServerBinding::unbind) // trigger unbinding from the port
            .thenAccept(unbound -> system.terminate()); // and shutdown when done

}
项目:Concierge    文件:ConciergeApplication.java   
public void run() {
  final Config conf = parseString("akka.remote.netty.tcp.hostname=" + config.hostname())
          .withFallback(parseString("akka.remote.netty.tcp.port=" + config.actorPort()))
          .withFallback(ConfigFactory.load("remote"));

  final ActorSystem system = ActorSystem.create("concierge", conf);
  kv = system.actorOf(LinearizableStorage.props(new Cluster(config.cluster().paths(), "kv")), "kv");

  final ActorMaterializer materializer = ActorMaterializer.create(system);

  final Flow<HttpRequest, HttpResponse, NotUsed> theFlow = createRoute().flow(system, materializer);

  final ConnectHttp host = ConnectHttp.toHost(config.hostname(), config.clientPort());
  Http.get(system).bindAndHandle(theFlow, host, materializer);

  LOG.info("Ama up");
}
项目:hashsdn-controller    文件:ActorContext.java   
public ActorContext(ActorSystem actorSystem, ActorRef shardManager,
        ClusterWrapper clusterWrapper, Configuration configuration,
        DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache) {
    this.actorSystem = actorSystem;
    this.shardManager = shardManager;
    this.clusterWrapper = clusterWrapper;
    this.configuration = configuration;
    this.datastoreContext = datastoreContext;
    this.dispatchers = new Dispatchers(actorSystem.dispatchers());
    this.primaryShardInfoCache = primaryShardInfoCache;

    final LogicalDatastoreType convertedType =
            LogicalDatastoreType.valueOf(datastoreContext.getLogicalStoreType().name());
    this.shardStrategyFactory = new ShardStrategyFactory(configuration, convertedType);

    setCachedProperties();

    Address selfAddress = clusterWrapper.getSelfAddress();
    if (selfAddress != null && !selfAddress.host().isEmpty()) {
        selfAddressHostPort = selfAddress.host().get() + ":" + selfAddress.port().get();
    } else {
        selfAddressHostPort = null;
    }

}
项目:sunbird-lms-mw    文件:Application.java   
/**
 * This method will do the basic setup for actors.
 */
private static void startRemoteActorSystem() {
  ProjectLogger.log("startRemoteCreationSystem method called....");
  Config con = null;
  String host = System.getenv(JsonKey.SUNBIRD_ACTOR_SERVICE_IP);
  String port = System.getenv(JsonKey.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(ACTOR_CONFIG_NAME));
  } else {
    con = ConfigFactory.load().getConfig(ACTOR_CONFIG_NAME);
  }
  system = ActorSystem.create(REMOTE_ACTOR_SYSTEM_NAME, con);
  ActorRef learnerActorSelectorRef = system.actorOf(Props.create(RequestRouterActor.class),
      RequestRouterActor.class.getSimpleName());

  RequestRouterActor.setSystem(system);

  ProjectLogger.log("normal remote ActorSelectorRef " + learnerActorSelectorRef);
  ProjectLogger.log("NORMAL ACTOR REMOTE SYSTEM STARTED " + learnerActorSelectorRef,
      LoggerEnum.INFO.name());
  checkCassandraConnection();
}
项目:sunbird-lms-mw    文件:Application.java   
public static ActorRef startLocalActorSystem() {
  try{
  system = ActorSystem.create(LOCAL_ACTOR_SYSTEM_NAME,
      ConfigFactory.load().getConfig(ACTOR_LOCAL_CONFIG_NAME));
  ActorRef learnerActorSelectorRef = system.actorOf(Props.create(RequestRouterActor.class),
      RequestRouterActor.class.getSimpleName());
  ProjectLogger.log("normal local ActorSelectorRef " + learnerActorSelectorRef);
  ProjectLogger.log("NORNAL ACTOR LOCAL SYSTEM STARTED " + learnerActorSelectorRef,
      LoggerEnum.INFO.name());
  checkCassandraConnection();
  PropertiesCache cache = PropertiesCache.getInstance();
  if ("local".equalsIgnoreCase(cache.getProperty("background_actor_provider"))) {
    ProjectLogger.log("Initializing Local Background Actor System");
    startBackgroundLocalActorSystem();
  }
  return learnerActorSelectorRef;
  }catch(Exception ex){
    ProjectLogger.log("Exception occurred while starting local Actor System in Application.java startLocalActorSystem method "+ex);
  }
  return null;
}
项目:sunbird-utils    文件:ActorUtility.java   
private static void createConnection() {
  try{
  ProjectLogger.log("ActorUtility createConnection method start....");
  ActorSystem system =
      ActorSystem.create("ActorApplication",ConfigFactory.load().getConfig("ActorConfig"));

  String path = PropertiesCache.getInstance().getProperty("remote.actor.path");
  try {
    if (!ProjectUtil.isStringNullOREmpty(System.getenv(JsonKey.SUNBIRD_ACTOR_IP))
        && !ProjectUtil.isStringNullOREmpty(System.getenv(JsonKey.SUNBIRD_ACTOR_PORT))) {
      ProjectLogger.log("value is taking from system env");
      path = MessageFormat.format(
          PropertiesCache.getInstance().getProperty("remote.actor.env.path"),
          System.getenv(JsonKey.SUNBIRD_ACTOR_IP), System.getenv(JsonKey.SUNBIRD_ACTOR_PORT));
    }
    ProjectLogger.log("Actor path is ==" + path, LoggerEnum.INFO.name());
  } catch (Exception e) {
    ProjectLogger.log(e.getMessage(), e);
  }
  selection = system.actorSelection(path);
  ProjectLogger.log("ActorUtility selection reference    : "+selection);
  }catch(Exception ex){
    ProjectLogger.log("Exception Occurred while creating remote connection in ActorUtility createConnection method "+ex);
  }
}
项目:hashsdn-controller    文件:AbstractClientConnectionTest.java   
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    system = ActorSystem.apply();
    backendProbe = new TestProbe(system);
    contextProbe = new TestProbe(system);
    context = new ClientActorContext(contextProbe.ref(), PERSISTENCE_ID, system,
            CLIENT_ID, AccessClientUtil.newMockClientActorConfig());
    replyToProbe = new TestProbe(system);
    connection = createConnection();
}
项目:sunbird-lms-mw    文件:PageManagementActorTest.java   
@BeforeClass
public static void setUp() {
    system = ActorSystem.create("system");
    Util.checkCassandraDbConnections(JsonKey.SUNBIRD);
    pageMgmntDbInfo = Util.dbInfoMap.get(JsonKey.PAGE_MGMT_DB);
    pageSectionDbInfo = Util.dbInfoMap.get(JsonKey.PAGE_SECTION_DB);
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:ujug2017    文件:RSExample1.java   
private void run1() {
    final ActorSystem actorSystem = ActorSystem.create();
    final Materializer materializer = ActorMaterializer.create(actorSystem);
    final Source<Integer, NotUsed> source = Source.range(0, 10);
    final Flow<Integer, String, NotUsed> flow = Flow.fromFunction((Integer i) -> i.toString());
    final Sink<String, CompletionStage<Done>> sink = Sink.foreach(s -> System.out.println("Example1 - Number: " + s));
    final RunnableGraph runnable = source.via(flow).to(sink);
    runnable.run(materializer);
    actorSystem.terminate();
}
项目:hashsdn-controller    文件:SingleClientHistoryTest.java   
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    system = ActorSystem.apply();

    final TestProbe clientContextProbe = new TestProbe(system, "client");
    final TestProbe actorContextProbe = new TestProbe(system, "actor-context");
    clientActorContext = AccessClientUtil.createClientActorContext(
            system, clientContextProbe.ref(), CLIENT_ID, PERSISTENCE_ID);
    final ActorContext actorContextMock = createActorContextMock(system, actorContextProbe.ref());
    behavior = new SimpleDataStoreClientBehavior(clientActorContext, actorContextMock, SHARD_NAME);

    object = new SingleClientHistory(behavior, HISTORY_ID);
}
项目:akka-persistance-ignite    文件:IgniteWriteJournal.java   
/**
 * @param config akka configuration
 * @throws NotSerializableException
 */
public IgniteWriteJournal(Config config) throws NotSerializableException {
    ActorSystem actorSystem = context().system();
    serializer = SerializationExtension.get(actorSystem).serializerFor(PersistentRepr.class);
    storage = new Store<>(actorSystem);
    JournalCaches journalCaches = journalCacheProvider.apply(config, actorSystem);
    sequenceNumberTrack = journalCaches.getSequenceCache();
    cache = journalCaches.getJournalCache();
}
项目:lagomkotlin    文件:StreamIT.java   
@BeforeClass
public static void setup() {
    clientFactory = LagomClientFactory.create("integration-test", StreamIT.class.getClassLoader());
    // One of the clients can use the service locator, the other can use the service gateway, to test them both.
    helloService = clientFactory.createDevClient(HelloService.class, URI.create(SERVICE_LOCATOR_URI));
    streamService = clientFactory.createDevClient(StreamService.class, URI.create(SERVICE_LOCATOR_URI));

    system = ActorSystem.create();
    mat = ActorMaterializer.create(system);
}
项目:sunbird-lms-service    文件:UserControllerTest.java   
@BeforeClass
public static void startApp() {
  app = Helpers.fakeApplication();
  Helpers.start(app);
  headerMap = new HashMap<String, String[]>();
  headerMap.put(HeaderParam.X_Consumer_ID.getName(), new String[]{"Service test consumer"});
  headerMap.put(HeaderParam.X_Device_ID.getName(), new String[]{"Some Device Id"});
  headerMap.put(HeaderParam.X_Authenticated_Userid.getName(), new String[]{"Authenticated user id"});
  headerMap.put(JsonKey.MESSAGE_ID, new String[]{"Unique Message id"});

  system = ActorSystem.create("system");
  ActorRef subject = system.actorOf(props);
  BaseController.setActorRef(subject);
}
项目:sunbird-lms-service    文件:SkillControllerTest.java   
@BeforeClass
public static void startApp() {
  app = Helpers.fakeApplication();
  Helpers.start(app);
  headerMap = new HashMap<String, String[]>();
  headerMap.put(HeaderParam.X_Consumer_ID.getName(), new String[]{"Service test consumer"});
  headerMap.put(HeaderParam.X_Device_ID.getName(), new String[]{"Some Device Id"});
  headerMap.put(HeaderParam.X_Authenticated_Userid.getName(), new String[]{"Authenticated user id"});
  headerMap.put(JsonKey.MESSAGE_ID, new String[]{"Unique Message id"});

  system = ActorSystem.create("system");
  ActorRef subject = system.actorOf(props);
  BaseController.setActorRef(subject);
}
项目:sunbird-lms-service    文件:LearnerControllerTest.java   
@BeforeClass
public static void startApp() {
  app = Helpers.fakeApplication();
  Helpers.start(app);
  headerMap = new HashMap<String, String[]>();
  headerMap.put(HeaderParam.X_Consumer_ID.getName(), new String[]{"Service test consumer"});
  headerMap.put(HeaderParam.X_Device_ID.getName(), new String[]{"Some Device Id"});
  headerMap.put(HeaderParam.X_Authenticated_Userid.getName(), new String[]{"Authenticated user id"});
  headerMap.put(JsonKey.MESSAGE_ID, new String[]{"Unique Message id"});

  system = ActorSystem.create("system");
  ActorRef subject = system.actorOf(props);
  BaseController.setActorRef(subject);
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:hashsdn-controller    文件:ClusterWrapperImpl.java   
public ClusterWrapperImpl(ActorSystem actorSystem) {
    Preconditions.checkNotNull(actorSystem, "actorSystem should not be null");

    cluster = Cluster.get(actorSystem);

    Preconditions.checkState(cluster.getSelfRoles().size() > 0,
        "No akka roles were specified.\n"
        + "One way to specify the member name is to pass a property on the command line like so\n"
        + "   -Dakka.cluster.roles.0=member-3\n"
        + "member-3 here would be the name of the member");

    currentMemberName = MemberName.forName(cluster.getSelfRoles().iterator().next());
    selfAddress = cluster.selfAddress();
}
项目:sunbird-lms-mw    文件:BackgroundServiceActorTest.java   
@BeforeClass
public static void setUp(){

  Util.checkCassandraDbConnections(JsonKey.SUNBIRD);
  system = ActorSystem.create("system");

  Map<String , Object> locnMap = new HashMap<String , Object>();
  locnMap.put(JsonKey.ID , locnId);
  cassandraOperation.insertRecord(geoLocationDbInfo.getKeySpace(), geoLocationDbInfo.getTableName(), locnMap);

}
项目:hashsdn-controller    文件:ShardedDataTreeActor.java   
ConfigShardReadinessTask(final ActorSystem system,
                         final ActorRef replyTo,
                         final ActorContext context,
                         final ClusterWrapper clusterWrapper,
                         final ActorRef shard,
                         final int lookupMaxRetries) {
    super(replyTo, lookupMaxRetries);
    this.system = system;
    this.replyTo = replyTo;
    this.context = context;
    this.clusterWrapper = clusterWrapper;
    this.shard = shard;
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
public CoffeeHouseApp(final ActorSystem system) {
    this.system = system;
    log = Logging.getLogger(system, getClass().getName());
    coffeeHouse = createCoffeeHouse();

    //===========================================================================
    // ANSWER
    //===========================================================================\
    // @todo send "Brew Coffee" to coffeeHouse
    // @todo use ActorRef.noSender() as the sender
    // coffeeHouse.tell("Brew Coffee", ActorRef.noSender());
}
项目:hashsdn-controller    文件:RemoteRpcProviderTest.java   
@BeforeClass
public static void setup() throws InterruptedException {
    moduleConfig = new RemoteRpcProviderConfig.Builder("odl-cluster-rpc")
            .withConfigReader(ConfigFactory::load).build();
    final Config config = moduleConfig.get();
    system = ActorSystem.create("odl-cluster-rpc", config);

}
项目:sunbird-lms-service    文件:PageControllerTest.java   
@BeforeClass
public static void startApp() {
  app = Helpers.fakeApplication();
  Helpers.start(app);
  headerMap = new HashMap<String, String[]>();
  headerMap.put(HeaderParam.X_Consumer_ID.getName(), new String[]{"Service test consumer"});
  headerMap.put(HeaderParam.X_Device_ID.getName(), new String[]{"Some Device Id"});
  headerMap.put(HeaderParam.X_Authenticated_Userid.getName(), new String[]{"Authenticated user id"});
  headerMap.put(JsonKey.MESSAGE_ID, new String[]{"Unique Message id"});

  system = ActorSystem.create("system");
  ActorRef subject = system.actorOf(props);
  BaseController.setActorRef(subject);
}
项目:hashsdn-controller    文件:DataChangeListenerRegistrationProxyTest.java   
@Test
public void testFailedRegistration() {
    new JavaTestKit(getSystem()) {
        {
            ActorSystem mockActorSystem = mock(ActorSystem.class);

            ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class),
                    "testFailedRegistration");
            doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
            ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(
                    MoreExecutors.directExecutor());


            ActorContext actorContext = mock(ActorContext.class);

            doReturn(executor).when(actorContext).getClientDispatcher();

            String shardName = "shard-1";
            final DataChangeListenerRegistrationProxy proxy = new DataChangeListenerRegistrationProxy(
                    shardName, actorContext, mockListener);

            doReturn(mockActorSystem).when(actorContext).getActorSystem();
            doReturn(duration("5 seconds")).when(actorContext).getOperationDuration();
            doReturn(Futures.successful(getRef())).when(actorContext).findLocalShardAsync(eq(shardName));
            doReturn(Futures.failed(new RuntimeException("mock")))
                .when(actorContext).executeOperationAsync(any(ActorRef.class),
                    any(Object.class), any(Timeout.class));
            doReturn(mock(DatastoreContext.class)).when(actorContext).getDatastoreContext();

            proxy.init(YangInstanceIdentifier.of(TestModel.TEST_QNAME),
                    AsyncDataBroker.DataChangeScope.ONE);

            Assert.assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());

            proxy.close();
        }
    };
}
项目:hashsdn-controller    文件:AbstractClientHandleTest.java   
private static ActorContext createActorContextMock(final ActorSystem system, final ActorRef actor) {
    final ActorContext mock = mock(ActorContext.class);
    final Promise<PrimaryShardInfo> promise = new scala.concurrent.impl.Promise.DefaultPromise<>();
    final ActorSelection selection = system.actorSelection(actor.path());
    final PrimaryShardInfo shardInfo = new PrimaryShardInfo(selection, (short) 0);
    promise.success(shardInfo);
    when(mock.findPrimaryShardAsync(any())).thenReturn(promise.future());
    return mock;
}
项目:hashsdn-controller    文件:AbstractTransactionProxyTest.java   
@BeforeClass
public static void setUpClass() throws IOException {

    Config config = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder()
            .put("akka.actor.default-dispatcher.type",
                    "akka.testkit.CallingThreadDispatcherConfigurator").build())
            .withFallback(ConfigFactory.load());
    system = ActorSystem.create("test", config);
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:oreilly-reactive-architecture-old    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:oreilly-reactive-with-akka    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:sunbird-lms-service    文件:ApplicationConfigControllerTest.java   
@BeforeClass
public static void startApp() {
  app = Helpers.fakeApplication();
  Helpers.start(app);
  headerMap = new HashMap<String, String[]>();
  headerMap.put(HeaderParam.X_Consumer_ID.getName(), new String[]{"Service test consumer"});
  headerMap.put(HeaderParam.X_Device_ID.getName(), new String[]{"Some Device Id"});
  headerMap.put(HeaderParam.X_Authenticated_Userid.getName(), new String[]{"Authenticated user id"});
  headerMap.put(JsonKey.MESSAGE_ID, new String[]{"Unique Message id"});

  system = ActorSystem.create("system");
  ActorRef subject = system.actorOf(props);
  BaseController.setActorRef(subject);
}
项目: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   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:oreilly-reactive-architecture-student    文件:CoffeeHouseApp.java   
public static void main(final String[] args) throws Exception {
    final Map<String, String> opts = argsToOpts(Arrays.asList(args));
    applySystemProperties(opts);
    final String name = opts.getOrDefault("name", "coffee-house");

    final ActorSystem system = ActorSystem.create(String.format("%s-system", name));
    final CoffeeHouseApp coffeeHouseApp = new CoffeeHouseApp(system);
    coffeeHouseApp.run();
}
项目:hashsdn-controller    文件:ShardManagerTest.java   
private ActorRef newMockShardActor(final ActorSystem system, final String shardName, final String memberName) {
    String name = ShardIdentifier.create(shardName, MemberName.forName(memberName), "config").toString();
    if (system == getSystem()) {
        return actorFactory.createActor(MessageCollectorActor.props(), name);
    }

    return system.actorOf(MessageCollectorActor.props(), name);
}
项目:hashsdn-controller    文件:AbstractRpcTest.java   
@BeforeClass
public static void setup() throws InterruptedException {
    config1 = new RemoteRpcProviderConfig.Builder("memberA").build();
    config2 = new RemoteRpcProviderConfig.Builder("memberB").build();
    node1 = ActorSystem.create("opendaylight-rpc", config1.get());
    node2 = ActorSystem.create("opendaylight-rpc", config2.get());
}
项目:hashsdn-controller    文件:InitialClientActorContext.java   
ClientActorBehavior<?> createBehavior(final ClientIdentifier clientId) {
    final ActorSystem system = actor.getContext().system();
    final ClientActorContext context = new ClientActorContext(self(), persistenceId(), system,
        clientId, actor.getClientActorConfig());

    return actor.initialBehavior(context);
}
项目:exam    文件:StudentExamController.java   
@Inject
public StudentExamController(EmailComposer emailComposer, ActorSystem actor,
                             AutoEvaluationHandler autoEvaluationHandler, Environment environment) {
    this.emailComposer = emailComposer;
    this.actor = actor;
    this.autoEvaluationHandler = autoEvaluationHandler;
    this.environment = environment;
}