Package akka.remote

Examples of akka.remote.RemoteScope


    else {
      for (Address m : nodeList) {
        agentCommandManager = system.actorOf(
          Props.create(LocalManager.class).withDeploy(
              new Deploy(
                   new RemoteScope(
                      m
                      )
                  )),
          "AgentCommandManager-" + UUID.randomUUID().toString()
        );
       
        jobQ.offer(managerList.size());
        managerList.add(agentCommandManager);
        ClusterState.memberLoad.get(m).addAndGet(maxConcNum);
      }
    }
   
    /**
     * Dispatch Jobs
     * @author chunyang
     */
    if (!localMode) {
      List<Map<String, NodeData>> jobGroupList = partDataStore(nodeDataMapValidSafe, nodeList.size()==0?
          totJobNum:Math.min(totJobNum/nodeList.size()+1, 1000));
      List<ActorRef> dispatcherList = new ArrayList<ActorRef>();
      int requestChunckSize = jobGroupList.size()/managerList.size() + 1; // Last one do less
     
      for (int i=0; i<Math.min(3, managerList.size()) ; i++) {
        dispatcherList.add(
            system.actorOf(
                Props.create(JobDispatcher.class, managerList, jobGroupList, jobQ, requestChunckSize,
                    nodeGroupType, agentCommandType, directorJobUuid, maxConcNum)
                )
            );
      }
     
      for (ActorRef dispatcher : dispatcherList) {
        dispatcher.tell("start dispatching", null);
      }
    } else {
      Map<String, NodeGroupDataMap> totDataStore = new HashMap<String, NodeGroupDataMap>();
      totDataStore.put(nodeGroupType, new NodeGroupDataMap(nodeGroupType));
      totDataStore.get(nodeGroupType).setNodeDataMapValid(nodeDataMapValidSafe);
      Future<Object> ackFuture = Patterns.ask(managerList.get(0), new InitialRequestToManager(nodeGroupType,
          agentCommandType, directorJobUuid, totDataStore, true, false, maxConcNum), new Timeout(Duration.create(
              15, TimeUnit.SECONDS)));
      try {
        Await.result(ackFuture,  Duration.create(
            15, TimeUnit.SECONDS));
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      managerList.get(0).tell(new endOfRequest(), null);
    }
   
    ActorRef monitor = system.actorOf(Props.create(Monitor.class, managerList, directorJobUuid, jobStatus), "ProgressMonitor" + directorJobUuid);
   
    ActorRef collector = system.actorOf(Props.create(ResponseCollector.class, jobInfo), "ResultCollector" + directorJobUuid);
   
    final FiniteDuration gatherResponseDuration = Duration.create(
        3600, TimeUnit.SECONDS);
   
    /**
     * Gather Result.
     */
    Future<Object> totResponse = Patterns.ask(collector, new gatherResponse(monitor, totJobNum), new Timeout(gatherResponseDuration));
   
    BatchResponseFromManager responseFromCollecter = null;
    try {
      responseFromCollecter = (BatchResponseFromManager) Await.result(totResponse, gatherResponseDuration);
      System.out.println("Gather Result Back! : " + responseFromCollecter.responseMap.size());
      /**
       * Slave Fail Over
       */
      int failCount = 3;
      while (responseFromCollecter.responseMap.size() < totJobNum && failCount >= 0) {
        System.out.println("Response less than request, fail over @@");
        failCount -- ;
        Map<String, NodeData> failOverMap = gatherFailOverData(nodeDataMapValidSafe, responseFromCollecter);
       
        List<Address> failOverNodeList = new ArrayList<Address>();
       
        int failOverTot = failOverMap.size();
       
        for (Address m : nodeList) {
          if (ClusterState.memberLoad.containsKey(m)) {
            failOverNodeList.add(m);
            failOverTot -= 2000;
            if (failOverTot < 0)
              break;
          }
        } 
       
       
        List<ActorRef> failOverManagerList = new ArrayList<ActorRef>();
        Queue<Integer> failOverJobQ = new ConcurrentLinkedQueue<Integer>();
       
        if (localMode || failOverNodeList.size()==0) {
          agentCommandManager =  system.actorOf(
              Props.create(LocalManager.class),"AgentCommandManager-" + UUID.randomUUID().toString()
            );
          failOverJobQ.offer(failOverManagerList.size());
          failOverManagerList.add(agentCommandManager);
          managerList.add(agentCommandManager);
          localMode = true;
        }
        else {
          for (Address m : failOverNodeList) {
            agentCommandManager = system.actorOf(
              Props.create(LocalManager.class).withDeploy(
                  new Deploy(
                       new RemoteScope(
                          m
                          )
                      )),
              "AgentCommandManager-" + UUID.randomUUID().toString()
            );
View Full Code Here


    // create the address object that points to the remote server
    Address addr = new Address("akka", "ServerSys", "127.0.0.1", 2552);

    // creating the ServerActor on the specified remote server
    final ActorRef serverActor = system.actorOf(new Props(ServerActor.class)
        .withDeploy(new Deploy(new RemoteScope(addr))));

    // create a local actor and pass the reference of the remote actor
    actor = system.actorOf(new Props(new UntypedActorFactory() {
      public UntypedActor create() {
        return new ClientActor(serverActor);
View Full Code Here

    Address addr = AddressFromURIString
        .parse("akka://ServerSys@127.0.0.1:2552");

    // creating the ServerActor on the specified remote server
    final ActorRef serverActor = system.actorOf(new Props(ServerActor.class)
        .withDeploy(new Deploy(new RemoteScope(addr))));

    // create a local actor and pass the reference of the remote actor
    actor = system.actorOf(new Props(new UntypedActorFactory() {
      public UntypedActor create() {
        return new ClientActor(serverActor);
View Full Code Here

    Address addr = new Address("akka.tcp", "sys", "host", 1234);
    addr = AddressFromURIString.parse("akka.tcp://sys@host:1234"); // the same
    //#make-address
    //#deploy
    ActorRef ref = system.actorOf(Props.create(SampleActor.class).withDeploy(
      new Deploy(new RemoteScope(addr))));
    //#deploy
    assert ref.path().address().equals(addr);
  }
View Full Code Here

TOP

Related Classes of akka.remote.RemoteScope

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.