Search in sources :

Example 1 with MessageSchema

use of edu.iu.dsc.tws.api.comms.packing.MessageSchema in project twister2 by DSC-SPIDAL.

the class SortJob method execute.

@Override
public void execute(Config cfg, JobAPI.Job job, IWorkerController workerController, IPersistentVolume persistentVolume, IVolatileVolume volatileVolume) {
    int workerID = workerController.getWorkerInfo().getWorkerID();
    // create a worker environment & setup the network
    WorkerEnvironment workerEnv = WorkerEnvironment.init(cfg, job, workerController, persistentVolume, volatileVolume);
    int noOfSources = cfg.getIntegerValue(ARG_TASKS_SOURCES, 4);
    int noOfTargets = cfg.getIntegerValue(ARG_TASKS_SINKS, 4);
    taskStages.add(noOfSources);
    taskStages.add(noOfTargets);
    // lets create the task plan
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(taskStages.get(0), taskStages.get(1), workerEnv).withFairDistribution();
    int valueSize = cfg.getIntegerValue(SortJob.ARG_VALUE_SIZE, 90);
    int keySize = cfg.getIntegerValue(SortJob.ARG_KEY_SIZE, 10);
    MessageSchema schema = MessageSchema.noSchema();
    if (cfg.getBooleanValue(ARG_FIXED_SCHEMA, false)) {
        LOG.info("Using fixed schema feature with message size : " + (keySize + valueSize) + " and key size : " + keySize);
        schema = MessageSchema.ofSize(keySize + valueSize, keySize);
    }
    gather = new BKeyedGather(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.BYTE_ARRAY, MessageTypes.BYTE_ARRAY, new RecordSave(), new ByteSelector(), true, new IntegerComparator(), true, schema);
    int thisSource = logicalPlanBuilder.getSourcesOnThisWorker().iterator().next();
    RecordSource source = new RecordSource(cfg, workerID, gather, thisSource);
    long start = System.currentTimeMillis();
    // run until we send
    source.run();
    // wait until we receive
    progress();
    LOG.info("Time: " + (System.currentTimeMillis() - start));
}
Also used : MessageSchema(edu.iu.dsc.tws.api.comms.packing.MessageSchema) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) BKeyedGather(edu.iu.dsc.tws.comms.batch.BKeyedGather) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment)

Aggregations

MessageSchema (edu.iu.dsc.tws.api.comms.packing.MessageSchema)1 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)1 BKeyedGather (edu.iu.dsc.tws.comms.batch.BKeyedGather)1 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)1