Package akka.actor

Examples of akka.actor.ActorSystem


public class BetClient {

    public static void main(String[] args) {
        System.out.println("*** STARTING TEST OF BETTING APPLICATION");
        BetClient client = new BetClient();
        ActorSystem system = client.init();

        try {
            if (args.length > 0 && args[0].equals("send")) {
                client.sendMessages(system);
            } else {
                client.retrieveMessages(system);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            system.shutdown();
        }
    }
View Full Code Here


   * }}}
   *
   * @return ActorSystem
   */
  public static ActorSystem system() {
    ActorSystem applicationSystem = AkkaPlugin.applicationSystem;
    if (ValidateUtils.me().isNullOrEmpty(applicationSystem)) {
      throw new RuntimeException("Akka plugin is not registered.");
    }
    return applicationSystem;
  }
View Full Code Here

    final String port = args.length > 0 ? args[0] : "0";
    final Config config = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port).
      withFallback(ConfigFactory.parseString("akka.cluster.roles = [frontend]")).
      withFallback(ConfigFactory.load());

    ActorSystem system = ActorSystem.create("ClusterSystem", config);

    final ActorRef frontend = system.actorOf(
        Props.create(TransformationFrontend.class), "frontend");
    final FiniteDuration interval = Duration.create(2, TimeUnit.SECONDS);
    final Timeout timeout = new Timeout(Duration.create(5, TimeUnit.SECONDS));
    final ExecutionContext ec = system.dispatcher();
    final AtomicInteger counter = new AtomicInteger();
    system.scheduler().schedule(interval, interval, new Runnable() {
      public void run() {
        ask(frontend,
            new TransformationJob("hello-" + counter.incrementAndGet()),
            timeout).onSuccess(new OnSuccess<Object>() {
          public void onSuccess(Object result) {
View Full Code Here

    final String port = args.length > 0 ? args[0] : "0";
    final Config config = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port).
      withFallback(ConfigFactory.parseString("akka.cluster.roles = [backend]")).
      withFallback(ConfigFactory.load());

    ActorSystem system = ActorSystem.create("ClusterSystem", config);

    system.actorOf(Props.create(TransformationBackend.class), "backend");

  }
View Full Code Here

          .parseString("akka.remote.netty.tcp.port=" + port)
          .withFallback(
              ConfigFactory.parseString("akka.cluster.roles = [compute]"))
          .withFallback(ConfigFactory.load("stats2"));

      ActorSystem system = ActorSystem.create("ClusterSystem", config);

      //#create-singleton-manager
      system.actorOf(ClusterSingletonManager.defaultProps(
          Props.create(StatsService.class), "statsService",
          PoisonPill.getInstance(), "compute"), "singleton");
      //#create-singleton-manager

      //#singleton-proxy
      system.actorOf(ClusterSingletonProxy.defaultProps("/user/singleton/statsService",
        "compute"), "statsServiceProxy");
      //#singleton-proxy
    }

  }
View Full Code Here

public class StatsSampleClientMain {

  public static void main(String[] args) {
    // note that client is not a compute node, role not defined
    ActorSystem system = ActorSystem.create("ClusterSystem",
        ConfigFactory.load("stats1"));
    system.actorOf(Props.create(StatsSampleClient.class, "/user/statsService"),
        "client");
  }
View Full Code Here

          .parseString("akka.remote.netty.tcp.port=" + port)
          .withFallback(
              ConfigFactory.parseString("akka.cluster.roles = [compute]"))
          .withFallback(ConfigFactory.load("stats1"));

      ActorSystem system = ActorSystem.create("ClusterSystem", config);

      system.actorOf(Props.create(StatsWorker.class), "statsWorker");
      system.actorOf(Props.create(StatsService.class), "statsService");
    }

  }
View Full Code Here

public class StatsSampleOneMasterClientMain {

  public static void main(String[] args) {
    // note that client is not a compute node, role not defined
    ActorSystem system = ActorSystem.create("ClusterSystem",
        ConfigFactory.load("stats2"));
    system.actorOf(Props.create(StatsSampleClient.class, "/user/statsServiceProxy"),
        "client");

  }
View Full Code Here

      Config config = ConfigFactory.parseString(
          "akka.remote.netty.tcp.port=" + port).withFallback(
          ConfigFactory.load());

      // Create an Akka system
      ActorSystem system = ActorSystem.create("ClusterSystem", config);

      // Create an actor that handles cluster domain events
      system.actorOf(Props.create(SimpleClusterListener.class),
          "clusterListener");

    }
  }
View Full Code Here

public class EchoServer {

  public static void main(String[] args) throws InterruptedException {
    final Config config = ConfigFactory.parseString("akka.loglevel=DEBUG");
    final ActorSystem system = ActorSystem.create("EchoServer", config);
    try {
      final CountDownLatch latch = new CountDownLatch(1);
      final ActorRef watcher = system.actorOf(Props.create(Watcher.class, latch), "watcher");
      final ActorRef nackServer = system.actorOf(Props.create(EchoManager.class, EchoHandler.class), "nack");
      final ActorRef ackServer = system.actorOf(Props.create(EchoManager.class, SimpleEchoHandler.class), "ack");
      watcher.tell(nackServer, ActorRef.noSender());
      watcher.tell(ackServer, ActorRef.noSender());
      latch.await(10, TimeUnit.MINUTES);
    } finally {
      system.terminate();
    }
  }
View Full Code Here

TOP

Related Classes of akka.actor.ActorSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.