Package akka.actor

Examples of akka.actor.ActorRef


   * @param context the context
   * @param eventDefinitionParameter the event definition parameter
   * @return the ActorRef of the EventDefinition
   */
  public static ActorRef createEventDefinitionActor(String uniqueFlowNodeId, UntypedActorContext context, final EventDefinitionParameter eventDefinitionParameter) {
    ActorRef eventDefinitionActor = context.actorOf(new Props(new UntypedActorFactory() {
      private static final long serialVersionUID = 1L;

      public UntypedActor create() {
          return new EventDefinitionFactory().getEventDefinition(eventDefinitionParameter);
        }
View Full Code Here


  }
 
  @SuppressWarnings({ "unchecked" })
  public List<Object> run(final List<Object> data, List<Object> parameters, Function<?, ?> functionToApply, final int numberOfWorkers, int numberOfSecondsTimeout) {
    final ImmutableList iData = ImmutableList.builder().addAll(data).build();
    ActorRef actorLevel1 = system.actorOf(new Props(new UntypedActorFactory() {
      private static final long serialVersionUID = 1L;
      public UntypedActor create() {
        return new ActorLevel1(iData, numberOfWorkers);
      }
    }), "ActorLevel1-" + System.currentTimeMillis());
View Full Code Here

      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();
View Full Code Here

      StatsJob job = (StatsJob) message;
      if (job.getText().equals("")) {
        unhandled(message);
      } else {
        final String[] words = job.getText().split(" ");
        final ActorRef replyTo = getSender();

        // create actor that collects replies from workers
        ActorRef aggregator = getContext().actorOf(
            Props.create(StatsAggregator.class, words.length, replyTo));

        // send each word to a worker
        for (String word : words) {
          workerRouter.tell(new ConsistentHashableEnvelope(word, word),
View Full Code Here

            return null;
          }
        }
      };

      ActorRef cache = system.actorOf(
          new ConsistentHashingPool(10).withHashMapper(hashMapper).props(
              Props.create(Cache.class)),
        "cache");

      cache.tell(new ConsistentHashableEnvelope(
        new Entry("hello", "HELLO"), "hello"), getRef());
      cache.tell(new ConsistentHashableEnvelope(
        new Entry("hi", "HI"), "hi"), getRef());

      cache.tell(new Get("hello"), getRef());
      expectMsgEquals("HELLO");

      cache.tell(new Get("hi"), getRef());
      expectMsgEquals("HI");

      cache.tell(new Evict("hi"), getRef());
      cache.tell(new Get("hi"), getRef());
      expectMsgEquals(NOT_FOUND);

      //#consistent-hashing-router
    }};
  }
View Full Code Here

  }

  @Override
  public void preStart() throws Exception {
    //#manager
    final ActorRef tcpManager = Tcp.get(getContext().system()).manager();
    //#manager
    tcpManager.tell(
        TcpMessage.bind(getSelf(), new InetSocketAddress("localhost", 0), 100),
        getSelf());
  }
View Full Code Here

      }
    } else
    if (msg instanceof Connected) {
      final Connected conn = (Connected) msg;
      log.info("received connection from [{}]", conn.remoteAddress());
      final ActorRef connection = getSender();
      final ActorRef handler = getContext().actorOf(
          Props.create(handlerClass, connection, conn.remoteAddress()));
      //#echo-manager
      connection.tell(TcpMessage.register(handler,
          true, // <-- keepOpenOnPeerClosed flag
          true), getSelf());
View Full Code Here

  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

              }).build()
            );
          }
        }

        final ActorRef myListener = context().actorOf(Props.create(MyListener.class));
        context().actorOf(Channel.props(
          ChannelSettings.create().withRedeliverFailureListener(null)));
        //#channel-custom-listener

        receive(ReceiveBuilder.
View Full Code Here

    Props props =
      // “head” router actor will run on "router-dispatcher" dispatcher
      // Worker routees will run on "pool-dispatcher" dispatcher 
      new RandomPool(5).withDispatcher("router-dispatcher").props(
        Props.create(Worker.class));
    ActorRef router = system.actorOf(props, "poolWithDispatcher");
    //#dispatchers
  }
View Full Code Here

TOP

Related Classes of akka.actor.ActorRef

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.