Search in sources :

Example 6 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage 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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) ColumnConfig(ml.shifu.shifu.container.obj.ColumnConfig) StatsResultMessage(ml.shifu.shifu.message.StatsResultMessage) PathFinder(ml.shifu.shifu.fs.PathFinder) File(java.io.File) ScanStatsRawDataMessage(ml.shifu.shifu.message.ScanStatsRawDataMessage)

Aggregations

Scanner (java.util.Scanner)6 AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)6 ExceptionMessage (ml.shifu.shifu.message.ExceptionMessage)6 File (java.io.File)2 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)2 PathFinder (ml.shifu.shifu.fs.PathFinder)2 ScanEvalDataMessage (ml.shifu.shifu.message.ScanEvalDataMessage)2 ScanStatsRawDataMessage (ml.shifu.shifu.message.ScanStatsRawDataMessage)2 StatsResultMessage (ml.shifu.shifu.message.StatsResultMessage)2 TrainResultMessage (ml.shifu.shifu.message.TrainResultMessage)2 EvalResultMessage (ml.shifu.shifu.message.EvalResultMessage)1 NormResultDataMessage (ml.shifu.shifu.message.NormResultDataMessage)1 ScanNormInputDataMessage (ml.shifu.shifu.message.ScanNormInputDataMessage)1 ScanTrainDataMessage (ml.shifu.shifu.message.ScanTrainDataMessage)1