Search in sources :

Example 6 with VerificationException

use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.

the class TSetReduceExample method execute.

@Override
public void execute(WorkerEnvironment workerEnv) {
    super.execute(workerEnv);
    BatchEnvironment env = TSetEnvironment.initBatch(workerEnv);
    // set the parallelism of source to task stage 0
    int srcPara = jobParameters.getTaskStages().get(0);
    int sinkPara = jobParameters.getTaskStages().get(1);
    SourceTSet<int[]> source = env.createSource(new TestBaseSource(), srcPara).setName("Source");
    ReduceTLink<int[]> reduce = source.reduce((t1, t2) -> {
        int[] val = new int[t1.length];
        for (int i = 0; i < t1.length; i++) {
            val[i] = t1[i] + t2[i];
        }
        return val;
    });
    SinkTSet<int[]> sink = reduce.sink(value -> {
        experimentData.setOutput(value);
        LOG.info("Result : " + Arrays.toString(value));
        try {
            verify(OperationNames.REDUCE);
        } catch (VerificationException e) {
            LOG.info("Exception Message : " + e.getMessage());
        }
        return true;
    });
    env.run(sink);
}
Also used : BatchEnvironment(edu.iu.dsc.tws.tset.env.BatchEnvironment) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException)

Aggregations

VerificationException (edu.iu.dsc.tws.examples.verification.VerificationException)6 BatchEnvironment (edu.iu.dsc.tws.tset.env.BatchEnvironment)4 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)2 ExperimentVerification (edu.iu.dsc.tws.examples.verification.ExperimentVerification)2 Iterator (java.util.Iterator)2 OperationNames (edu.iu.dsc.tws.api.compute.OperationNames)1 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)1 TSetContext (edu.iu.dsc.tws.api.tset.TSetContext)1 SinkFunc (edu.iu.dsc.tws.api.tset.fn.SinkFunc)1 BaseTSetBatchWorker (edu.iu.dsc.tws.examples.tset.BaseTSetBatchWorker)1 TSetEnvironment (edu.iu.dsc.tws.tset.env.TSetEnvironment)1 GatherTLink (edu.iu.dsc.tws.tset.links.batch.GatherTLink)1 SinkTSet (edu.iu.dsc.tws.tset.sets.batch.SinkTSet)1 SourceTSet (edu.iu.dsc.tws.tset.sets.batch.SourceTSet)1 Arrays (java.util.Arrays)1 Logger (java.util.logging.Logger)1