2
votes

Remote Controller System:

Code:

private final ActorRef reaper = getContext().actorOf(Props.create(Reaper.class), "reaper");
private final ActorRef router = getContext().actorOf(Props.create(Worker.class).withRouter(new RemoteRouterConfig(new RoundRobinRouter(10), getNodes())), "router");

getnodes() is List<Address>

application.conf:

akka {
  log-dead-letters-during-shutdown = off
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
    remote {
      enabled-transports = ["akka.remote.netty.tcp"]
      transport-failure-detector {
        acceptable-heartbeat-pause = 100s
      }
      watch-failure-detector {
        acceptable-heartbeat-pause = 100s
      }
      netty.tcp {
        hostname = "127.0.0.1"
        port = 2552
      }
    }
  }
}

Remote Worker System: Code:

 private ActorSystem system;

  public RemoteWorker(String name) {
    Config conf = ConfigFactory.load("remote");
    int port = conf.getInt("akka.remote.netty.tcp.port");
    system = ActorSystem.create(name, conf);
  }

  private void handleShutdown() {
    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override public void run() {
        System.out.println("Shutting down remote actor system...");
        system.shutdown();
      }
    });
  }

  public static void main(String[] args) {
    String systemName = (args.length == 0) ? "remote" : args[0];
    RemoteWorker remsys = new RemoteWorker(systemName);
    remsys.handleShutdown();
  }

remote.conf

akka {
  log-dead-letters-during-shutdown = off
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
      hostname = ""
      port = 2553
    }
  }
}

Error: [WARN] [02/11/2014 14:50:26.728] [remote-akka.actor.default-dispatcher-17] [akka://..../system/remote-watcher] Detected unreachable: [akka.tcp://[email protected]:2553] [INFO] [02/11/2014 14:50:26.728] [remote-akka.actor.default-dispatcher-15] [Remoting] Address [akka.tcp://[email protected]:2553] is now quarantined, all messages to this address will be delivered to dead letters.

1

1 Answers

1
votes

Your master expects the worker to listen at 127.0.0.1, but the worker listens at the computer’s default address.