use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class AkkaSystemExecutor method submitDecisionTreeTrainJob.
/**
* Submit job to training decision-tree model
*
* @param modelConfig
* - configuration for model
* @param columnConfigList
* - configurations for columns
* @param scanners
* - scanners of normalized training data
* @param trainers
* - model trainer
*/
public void submitDecisionTreeTrainJob(final ModelConfig modelConfig, final List<ColumnConfig> columnConfigList, List<Scanner> scanners, final List<AbstractTrainer> trainers) {
actorSystem = ActorSystem.create("ShifuActorSystem");
final AkkaExecStatus akkaStatus = new AkkaExecStatus(true);
log.info("Create Akka system to train dt-model");
ActorRef modelTrainerRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = 2394968604729416422L;
public UntypedActor create() {
return new TrainDtModelActor(modelConfig, columnConfigList, akkaStatus, trainers);
}
}), "dt-model-trainer");
modelTrainerRef.tell(new AkkaActorInputMessage(scanners), modelTrainerRef);
// wait for termination
actorSystem.awaitTermination();
checkAkkaStatus(akkaStatus);
}
use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class CalculateStatsActor method onReceive.
/* (non-Javadoc)
* @see akka.actor.UntypedActor#onReceive(java.lang.Object)
*/
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof AkkaActorInputMessage) {
resultCnt = 0;
AkkaActorInputMessage msg = (AkkaActorInputMessage) message;
List<Scanner> scanners = msg.getScanners();
log.debug("Num of Scanners: " + scanners.size());
for (Scanner scanner : scanners) {
dataLoadRef.tell(new ScanStatsRawDataMessage(scanners.size(), scanner), getSelf());
}
} else if (message instanceof StatsResultMessage) {
StatsResultMessage statsRstMsg = (StatsResultMessage) message;
ColumnConfig columnConfig = statsRstMsg.getColumnConfig();
columnConfigList.set(columnConfig.getColumnNum(), columnConfig);
resultCnt++;
if (resultCnt == columnNumToActorMap.size()) {
log.info("Received " + resultCnt + " messages. Finished Calculating Stats.");
PathFinder pathFinder = new PathFinder(modelConfig);
JSONUtils.writeValue(new File(pathFinder.getColumnConfigPath()), columnConfigList);
getContext().system().shutdown();
}
} else if (message instanceof ExceptionMessage) {
// since some children actors meet some exception, shutdown the system
ExceptionMessage msg = (ExceptionMessage) message;
getContext().system().shutdown();
// and wrapper the exception into Return status
addExceptionIntoCondition(msg.getException());
} else {
unhandled(message);
}
}
Aggregations