Search in sources :

Example 1 with NormResultDataMessage

use of ml.shifu.shifu.message.NormResultDataMessage in project shifu by ShifuML.

the class DataNormalizeWorker method handleMsg.

/*
     * (non-Javadoc)
     * 
     * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
     */
@Override
public void handleMsg(Object message) {
    if (message instanceof NormPartRawDataMessage) {
        NormPartRawDataMessage msg = (NormPartRawDataMessage) message;
        List<String> rawDataList = msg.getRawDataList();
        int targetMsgCnt = msg.getTotalMsgCnt();
        List<List<Double>> normalizedDataList = normalizeData(rawDataList);
        nextActorRef.tell(new NormResultDataMessage(targetMsgCnt, rawDataList, normalizedDataList), this.getSelf());
    } else {
        unhandled(message);
    }
}
Also used : NormPartRawDataMessage(ml.shifu.shifu.message.NormPartRawDataMessage) ArrayList(java.util.ArrayList) List(java.util.List) NormResultDataMessage(ml.shifu.shifu.message.NormResultDataMessage)

Example 2 with NormResultDataMessage

use of ml.shifu.shifu.message.NormResultDataMessage in project shifu by ShifuML.

the class NormalizeDataActor 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 ScanNormInputDataMessage(scanners.size(), scanner), getSelf());
        }
    } else if (message instanceof NormResultDataMessage) {
        NormResultDataMessage msg = (NormResultDataMessage) message;
        int targetMsgCnt = msg.getTargetMsgCnt();
        writeDataIntoFile(msg.getNormalizedDataList());
        writeSelectDataIntoFile(msg.getSelectDataList());
        resultCnt++;
        if (resultCnt == targetMsgCnt) {
            log.info("Received " + resultCnt + " messages. Finished normalizing train data.");
            normDataWriter.close();
            selectDataWriter.close();
            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) NormResultDataMessage(ml.shifu.shifu.message.NormResultDataMessage) ScanNormInputDataMessage(ml.shifu.shifu.message.ScanNormInputDataMessage)

Aggregations

NormResultDataMessage (ml.shifu.shifu.message.NormResultDataMessage)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Scanner (java.util.Scanner)1 AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)1 ExceptionMessage (ml.shifu.shifu.message.ExceptionMessage)1 NormPartRawDataMessage (ml.shifu.shifu.message.NormPartRawDataMessage)1 ScanNormInputDataMessage (ml.shifu.shifu.message.ScanNormInputDataMessage)1