Java 类akka.actor.UntypedActor 实例源码

项目:peak-forecast    文件:ControllerSoftwareImpl.java   
/** implementation du service Install */   
@SuppressWarnings("serial")
public void install(String nomLogiciel, String listImages) {

    if (nomLogiciel.equals("frascati")) this.logiciel= this.logicielFrascati;
    if (nomLogiciel.equals("nodejs")) this.logiciel= this.logicielNodejs;

    this.imageVirtuels.clear();

    String tab[]= listImages.split(" ");
    for (int i = 0; i < tab.length; i++) {
        this.imageVirtuels.add(new VirtuelImage(tab[i],tab[i],tab[i]));
    }

    // creation de l'actor ControllerSoftwareSupervisor
    controllerSoftwareSupervisor = systemSoftware.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
         return new ControllerSoftwareSupervisor(imageVirtuels,logiciel,sh,new Props(WorkerInstall.class),listener);
        }
    }), "ControllerVMSupervisor");      

    // demarrer le déploiement
    controllerSoftwareSupervisor.tell(new MessageExecuteService()); 

}
项目:peak-forecast    文件:ControllerVMImpl.java   
/** implementation du service Create container */   
@SuppressWarnings("serial")
public void createContainer(String listImages) {

        System.out.println("nom des container à créer "+listImages);

this.imageVirtuels.clear();
            String tab[]= listImages.split(" ");
            for (int i = 0; i < tab.length; i++) {
                this.imageVirtuels.add(new VirtuelImage(tab[i],tab[i],tab[i])); 
            }

    // creation de l'actor ControllerVMSupervisor
    controllerVmSupervisor = systemVm.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
         return new ControllerVMSupervisor(imageVirtuels,pathFabFile,sh,new Props(WorkerCreateContainer.class),listener);
        }
    }), "ControllerVMSupervisor");      

    // démarrer l'exécution
    controllerVmSupervisor.tell(new MessageExecuteService());   

}
项目:peak-forecast    文件:ControllerVMImpl.java   
/** implementation du service Create container */   
@SuppressWarnings("serial")
public void startContainer(String listImages) {
this.imageVirtuels.clear();
        String tab[]= listImages.split(" ");
        for (int i = 0; i < tab.length; i++) {
            this.imageVirtuels.add(new VirtuelImage(tab[i],tab[i],tab[i])); 
        }

    // creation de l'actor ControllerVMSupervisor
    controllerVmSupervisor = systemVm.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
         return new ControllerVMSupervisor(imageVirtuels,pathFabFile,sh,new Props(WorkerStartContainer.class),listener);
        }
    }), "ControllerVMSupervisor");      

    // démarrer l'exécution
    controllerVmSupervisor.tell(new MessageExecuteService());   

}
项目:peak-forecast    文件:ControllerVMImpl.java   
/** implementation du service Create container */   
    @SuppressWarnings("serial")
    public void stopContainer(String listImages) {

this.imageVirtuels.clear();
        String tab[]= listImages.split(" ");
        for (int i = 0; i < tab.length; i++) {
            this.imageVirtuels.add(new VirtuelImage(tab[i],tab[i],tab[i])); 
        }
        // creation de l'actor ControllerVMSupervisor
        controllerVmSupervisor = systemVm.actorOf(new Props(new UntypedActorFactory() {
            public UntypedActor create() {
             return new ControllerVMSupervisor(imageVirtuels,pathFabFile,sh,new Props(WorkerStopContainer.class),listener);
            }
        }), "ControllerVMSupervisor");      

        // démarrer l'exécution
        controllerVmSupervisor.tell(new MessageExecuteService());   

    }
项目:wicket-akka    文件:Akka.java   
/**
 * Attempts to register the subscriber to the specified channel.
 *
 * @return the temporary actor that delegates the event to given handler
 */
public <T> ActorRef subscribeEvent(final Handler<T> handler, final Class<T> channel) {
    ActorRef ref = system.actorOf(new Props().withCreator(new Creator<Actor>() {
        @Override
        public Actor create() throws Exception {
            return new UntypedActor() {
                @Override
                public void onReceive(Object message) throws Exception {
                    if (message != null && message.getClass().equals(channel)) {
                        handler.handle(channel.cast(message));
                    } else {
                        unhandled(message);
                    }
                }
            };
        }
    }));

    eventStream().subscribe(ref, channel);
    return ref;
}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void detach() throws Exception {
    ActorModel<Integer> model = new ActorModel<Integer>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            unhandled(message);
                        }
                    };
                }
            }));
        }
    };

    model.detach();
    Thread.sleep(100);

    assertThat(model.getObject(), is(nullValue()));
    assertThat(model.getActorRef().isTerminated(), is(true));
}
项目:AkkaGuice    文件:AkkaGuiceModule.java   
private static void RegisterActors(Binder binder) {
    Logger.debug("Actor Scanner Started...");
    final Map<String, ActorHolder> map = new HashMap<>();       
    final ConfigurationBuilder configBuilder = build();
    final Reflections reflections = new Reflections(configBuilder.setScanners(new SubTypesScanner()));
    final Set<Class<? extends UntypedActor>> actors = reflections.getSubTypesOf(UntypedActor.class);
       final Set<Class<? extends AbstractActor>> abstractActors = reflections.getSubTypesOf(AbstractActor.class);
       loopOnActors(map, actors);
       loopOnAbstractActors(map, abstractActors);
       if(!map.isEmpty()) Logger.debug("Registering actors: ");
    for(final String key : map.keySet()) {
        final ActorHolder actorHolder = map.get(key);
        final Class<? extends Actor> actor = actorHolder.getActor();
        if(actorHolder.isSingleton()) {
            Logger.debug("Binding class " + actor.getSimpleName() + " to name: " + key + " Singleton Scoped.");
            binder.bind(ActorRef.class).annotatedWith(Names.named(key)).toProvider(new ActorRefProvider(actor, key, true)).in(Singleton.class);
        } else {
            Logger.debug("Binding class " + actor.getSimpleName() + " to name: " + key + " Request Scoped.");
            binder.bind(ActorRef.class).annotatedWith(Names.named(key)).toProvider(new ActorRefProvider(actor, key, false));
            PropsContext.put(key, actorHolder);
        }
    }
}
项目:AkkaGuice    文件:AkkaGuiceModule.java   
private static void loopOnActors(Map<String, ActorHolder> map, Set<Class<? extends UntypedActor>> actors) {
    for(final Class<? extends Actor> actor : actors) {
        if(ignore.contains(actor.getSimpleName())) continue;
        final String named = getNamed(actor);
        final boolean isSingleton = isSingleton(actor);
        final ActorHolder actorHolder = new ActorHolder(actor, isSingleton);
        if(named != null) {
            map.put(named, actorHolder);
        } else {
            if(map.containsKey(actor.getSimpleName())){
                map.put(actor.getName(), actorHolder);
                final ActorHolder tempHolder = map.remove(actor.getSimpleName());
                map.put(tempHolder.getActor().getName(), tempHolder);
            }
            else map.put(actor.getSimpleName(), actorHolder);
        }
    }
}
项目:trial    文件:ClientActorSystem.java   
@SuppressWarnings("serial")
public void remoteActorCreationDemo1() {
    log.info("Creating a actor using remote deployment mechanism");

    // 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);
        }
    }));
    // send a message to the local client actor
    actor.tell("Start-RemoteActorCreationDemo1");
}
项目:trial    文件:ClientActorSystem.java   
@SuppressWarnings("serial")
public void remoteActorCreationDemo3() {
    log.info("Creating a actor with remote deployment");

    // creating the ServerActor on the specified remote server
    final ActorRef serverActor = system.actorOf(new Props(ServerActor.class),"remoteServerActor");

    // 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);
        }
    }));
    // send a message to the local client actor
    actor.tell("Start-RemoteActorCreationDemo3");
}
项目:trial    文件:ExampleUnitTest.java   
@Test
public void testFilteringActor() {
    ActorRef filteringActorRef = _system.actorOf(new Props(
            new UntypedActorFactory() {
                public UntypedActor create() {
                    return new FilteringActor(testActor());
                }
            }));
    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    // first test
    filteringActorRef.tell("test message", super.testActor());
    expectMsg("test message");
    // second test
    filteringActorRef.tell(1, super.testActor());
    expectNoMsg();
}
项目:trial    文件:ApplicationManagerSystem.java   
public ApplicationManagerSystem() {

        final int no_of_workers = 10;

        system = ActorSystem.create("LoadGeneratorApp");

        final ActorRef appManager = system.actorOf(
                new Props(new UntypedActorFactory() {
                    public UntypedActor create() {
                        return new JobControllerActor(no_of_msgs);
                    }
                }), "jobController");

        router = system.actorOf(new Props(new UntypedActorFactory() {
            public UntypedActor create() {
                return new WorkerActor(appManager);
            }
        }).withRouter(new RoundRobinRouter(no_of_workers)));
    }
项目:hashsdn-controller    文件:RaftActorServerConfigurationSupportTest.java   
private static RaftActorContextImpl newFollowerContext(String id, TestActorRef<? extends UntypedActor> actor) {
    DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
    configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
    configParams.setElectionTimeoutFactor(100000);
    NonPersistentDataProvider noPersistence = new NonPersistentDataProvider(Runnable::run);
    ElectionTermImpl termInfo = new ElectionTermImpl(noPersistence, id, LOG);
    termInfo.update(1, LEADER_ID);
    return new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
            id, termInfo, -1, -1, ImmutableMap.of(LEADER_ID, ""), configParams,
            noPersistence, applyState -> actor.tell(applyState, actor), LOG);
}
项目:hashsdn-controller    文件:MeteringBehavior.java   
public MeteringBehavior(final UntypedActor actor) {
    Preconditions.checkArgument(actor != null, "actor must not be null");
    this.meteredActor = actor;

    String actorName = actor.getSelf().path().name();
    init(actorName);
}
项目:peak-forecast    文件:ControllerVMImpl.java   
/** implementation du service Pause */   
@SuppressWarnings("serial")
public void pause(String listImages) {


    //Retrait des VM  dans le fichier de configuration du repartiteur (Nginx)
    System.out.println("Connexion sur le serveur de repartition de charge (NGINX) pour retirer les VM dans son fichier de configuration et le signaler");

    this.imageVirtuels.clear();
    String tab[]= listImages.split(" ");
    for (int i = 0; i < tab.length; i++) {
        this.imageVirtuels.add(new VirtuelImage(tab[i],tab[i],tab[i]));     
        //PB gestion des acces concurents sur le fichier a revoir(solution passer plustot la liste des VM)
        String commande="fab -f /home/daniel/scriptFabric/repartiteur/fabfile.py retirerServeur:namehost=172.17.0.30,username=root,passworduser=root,serveur="
            +addressipport(tab[i]);
        sh.system(commande);

    }

    // creation de l'actor ControllerVMSupervisor
    controllerVmSupervisor = systemVm.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
         return new ControllerVMSupervisor(imageVirtuels,pathFabFile,sh,new Props(WorkerPauseVM.class),listener);
        }
    }), "ControllerVMSupervisor");      

    // démarrer l'exécution
    controllerVmSupervisor.tell(new MessageExecuteService());   

}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void ask() throws Exception {
    BaseAskActorModel<Integer, String> model = new BaseAskActorModel<Integer, String>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            if (message instanceof String) {
                                getSender().tell(Integer.parseInt((String) message), getSelf());
                            } else {
                                unhandled(message);
                            }
                        }
                    };
                }
            }));
        }
    };

    assertThat(model.ask("100").get(), is(100));

    model.detach();
}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void askByConstructor() throws Exception {
    BaseAskActorModel<Integer, String> model = new BaseAskActorModel<Integer, String>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            if (message instanceof String) {
                                getSender().tell(Integer.parseInt((String) message), getSelf());
                            } else {
                                unhandled(message);
                            }
                        }
                    };
                }
            }));
        }
    };

    assertThat(model.ask("100").get(), is(100));

    model.detach();
}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void askWithScalaFuture() throws Exception {
    BaseAskActorModel<Integer, String> model = new BaseAskActorModel<Integer, String>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            if (message instanceof String) {
                                getSender().tell(Integer.parseInt((String) message), getSelf());
                            } else {
                                unhandled(message);
                            }
                        }
                    };
                }
            }));
        }
    };

    Future<Integer> f = model.askWithScalaFuture("100");

    assertThat(Await.result(f, Duration.apply("3 sec")), is(100));
    assertThat(model.getObject(), is(100));

    model.detach();
}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void askUpdatesObject() throws Exception {
    BaseAskActorModel<Integer, String> model = new BaseAskActorModel<Integer, String>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            if (message instanceof String) {
                                getSender().tell(Integer.parseInt((String) message), getSelf());
                            } else {
                                unhandled(message);
                            }
                        }
                    };
                }
            }));
        }
    };

    model.ask("100").get();
    assertThat(model.getObject(), is(100));

    model.detach();
}
项目:wicket-akka    文件:ActorModelTest.java   
@Test
public void tell() throws Exception {
    final AtomicBoolean b = new AtomicBoolean(false);

    TellActorModel<Integer, String> model = new TellActorModel<Integer, String>() {
        @Override
        protected ActorRef newActor() {
            return system().actorOf(Props.apply(new Creator<Actor>() {
                @Override
                public Actor create() throws Exception {
                    return new UntypedActor() {
                        @Override
                        public void onReceive(Object message) throws Exception {
                            if (message instanceof String) {
                                b.set(true);
                            } else {
                                unhandled(message);
                            }
                        }
                    };
                }
            }));
        }
    };

    model.tell("test");
    Thread.sleep(100);
    assertThat(b.get(), is(true));

    model.detach();
}
项目:openhim-mediator-xds    文件:PIXRequestActorTest.java   
private void sendTestRequest(ActorRef ref, Class<? extends UntypedActor> handler) {
    TestingUtils.launchActors(system, testConfig.getName(), Collections.singletonList(new MockLauncher.ActorToLaunch("mllp-connector", handler)));
    TestActorRef<PIXRequestActor> actor = TestActorRef.create(system, Props.create(PIXRequestActor.class, testConfig));

    Identifier fromId = new Identifier("1234", new AssigningAuthority("test-auth", "1.2.3", "ISO"));
    AssigningAuthority targetDomain = new AssigningAuthority("ECID", "ECID", "ECID");

    actor.tell(new ResolvePatientIdentifier(ref, ref, fromId, targetDomain), ref);
}
项目:java-test-demo    文件:Pi.java   
private void calculate(final int nrOfWorkers, final int nrOfElements, final int nrOfMessage) {
    ActorSystem system = ActorSystem.create("PiSystem");

    final ActorRef listener = system.actorOf(new Props(Listener.class),"listener");

    ActorRef master = system.actorOf(new Props(new UntypedActorFactory() {

        @Override
         public UntypedActor create() {
            return new Master(nrOfWorkers, nrOfMessage, nrOfElements, listener);
          }
    }));

    master.tell(new Calculate());
}
项目:akka-java-springfactory    文件:ActorFactoryBean.java   
@SuppressWarnings("unchecked")
private ActorRef doCreateObject() throws Exception {
    Props props;
    if (actorClass != null) {
        props = Props.create(new SpringCreator(ctx, Class.forName(actorClass), args));
    } else if (actorBeanName != null && actorBeanClass != null) {
        props = SpringProps.create(actorSystem, actorBeanName, (Class<? extends UntypedActor>) Class.forName(actorBeanClass));
    } else if (actorBeanClass != null) {
        props = SpringProps.create(actorSystem, (Class<? extends UntypedActor>) Class.forName(actorBeanClass));
    } else {
        props = SpringProps.create(actorSystem, actorBeanName);
    }

    if (props == null) {
        throw new BeanCreationException("Can not create ActorRef for given parameters, actorClass=" + actorClass + ", actorBeanClass=" + actorBeanClass + ", actorBeanName=" + actorBeanName);
    }

    if (routerConfig != null) {
        props = props.withRouter(routerConfig);
    }
    if (deploy != null) {
        props = props.withDeploy(deploy);
    }
    if (mailbox != null) {
        props = props.withMailbox(mailbox);
    }
    if (dispatcher != null) {
        props = props.withDispatcher(dispatcher);
    }

    return actorSystem.actorOf(props);
}
项目:hivemind    文件:DroneTest.java   
DroneValidatable(UntypedActor actor, TestActorRef<MockActor> sender,
        MockTrainingSet trainingSet, MockObjectiveFunction objectiveFunction) {
    super();
    this.actor = actor;
    this.sender = sender;
    this.trainingSet = trainingSet;
    this.objectiveFunction = objectiveFunction;
}
项目:trial    文件:WCMapReduceServer.java   
@SuppressWarnings("serial")
public WCMapReduceServer(int no_of_reduce_workers, int no_of_map_workers) {

    system = ActorSystem.create("WCMapReduceApp", ConfigFactory.load()
            .getConfig("WCMapReduceApp"));

    // create the aggregate Actor
    aggregateActor = system.actorOf(new Props(AggregateActor.class));

    // create the list of reduce Actors
    reduceRouter = system.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
            return new ReduceActor(aggregateActor);
        }
    }).withRouter(new RoundRobinRouter(no_of_reduce_workers)));

    // create the list of map Actors
    mapRouter = system.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
            return new MapActor(reduceRouter);
        }
    }).withRouter(new RoundRobinRouter(no_of_map_workers)));

    // create the overall WCMapReduce Actor that acts as the remote actor
    // for clients
    wcMapReduceActor = system.actorOf(new Props(new UntypedActorFactory() {
        public UntypedActor create() {
            return new WCMapReduceActor(aggregateActor, mapRouter);
        }
    }).withDispatcher("priorityMailBox-dispatcher"), "WCMapReduceActor");

}
项目:trial    文件:ExampleUnitTest.java   
@Test
public void testForwardingActor() {
    ActorRef forwardingActorRef = _system.actorOf(new Props(
            new UntypedActorFactory() {
                public UntypedActor create() {
                    return new ForwardingActor(testActor());
                }
            }));
    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    forwardingActorRef.tell("test message", super.testActor());
    expectMsg("test message");
}
项目:occurrence    文件:FromSolrDownloadAction.java   
/**
 * This method it's mirror of the 'main' method, is kept for clarity in parameters usage.
 */
public static void run(WorkflowConfiguration workflowConfiguration, DownloadJobConfiguration configuration) {
  final Injector injector = createInjector(workflowConfiguration, configuration);
  CuratorFramework curator = injector.getInstance(CuratorFramework.class);

  // Create an Akka system
  ActorSystem system = ActorSystem.create("DownloadSystem" + configuration.getDownloadKey());

  // create the master
  ActorRef master = system.actorOf(new Props(new UntypedActorFactory() {
    public UntypedActor create() {
      return injector.getInstance(DownloadMaster.class);
    }
  }), "DownloadMaster" + configuration.getDownloadKey());

  // start the calculation
  master.tell(new DownloadMaster.Start());
  while (!master.isTerminated()) {
    try {
      Thread.sleep(SLEEP_TIME_BEFORE_TERMINATION);
    } catch (InterruptedException ie) {
      LOG.error("Thread interrupted", ie);
    }
  }
  system.shutdown();
  curator.close();
}
项目:cloudkeeper    文件:CompositeModuleInterpreterActor.java   
@Override
public UntypedActor create() {
    return new CompositeModuleInterpreterActor(this);
}
项目:cloudkeeper    文件:AdministratorActorCreator.java   
@Override
public UntypedActor create() {
    return new AdministratorActor();
}
项目:cloudkeeper    文件:TopLevelInterpreterActor.java   
@Override
public UntypedActor create() {
    return new TopLevelInterpreterActor(this);
}
项目:cloudkeeper    文件:SimpleModuleInterpreterActor.java   
@Override
public UntypedActor create() {
    return new SimpleModuleInterpreterActor(this);
}
项目:cloudkeeper    文件:MasterInterpreterActorCreator.java   
@Override
public UntypedActor create() {
    return new MasterInterpreterActor(firstExecutionId);
}
项目:cloudkeeper    文件:InputModuleInterpreterActor.java   
@Override
public UntypedActor create() {
    return new InputModuleInterpreterActor(this);
}
项目:cloudkeeper    文件:LoopModuleInterpreterActor.java   
@Override
public UntypedActor create() {
    return new LoopModuleInterpreterActor(this);
}
项目:cloudkeeper    文件:ExecutorActor.java   
@Override
public UntypedActor create() {
    return new ExecutorActor(simpleModuleExecutor);
}
项目:cloudkeeper    文件:InstanceProviderActorCreator.java   
@Override
public UntypedActor create() {
    return new InstanceProviderActor(this);
}
项目:cloudkeeper    文件:ExecutorActorCreator.java   
@Override
public UntypedActor create() {
    return new ExecutorActor(simpleModuleExecutor);
}
项目:fnf.clientapi    文件:LogMessage.java   
public LogMessage(Class<? extends UntypedActor> source, String message) {
    this.source = source;
    this.message = message;
}