Search in sources :

Example 26 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class BufferedCollectionPartition method get.

public T get(int index) {
    // read from memory
    if (index < this.dataList.size()) {
        return this.dataList.get(index);
    } else {
        // iterate over files
        long currentSize = this.dataList.size();
        for (int fileIndex = 0; fileIndex < this.filesList.size(); fileIndex++) {
            Path nextFile = this.filesList.get(fileIndex);
            try {
                DataInputStream reader = new DataInputStream(fileSystem.open(nextFile));
                long noOfFrames = reader.readLong();
                if (index < currentSize + noOfFrames) {
                    if (cachedFileIndex != fileIndex) {
                        cachedFileIndex = fileIndex;
                        this.currentFileCache = new ArrayList<>();
                        // read from this file
                        for (long i = 0; i < noOfFrames; i++) {
                            int size = reader.readInt();
                            byte[] data = new byte[size];
                            reader.read(data);
                            this.currentFileCache.add(data);
                        }
                    }
                    // not we have this file in cache
                    return (T) dataType.getDataPacker().unpackFromByteArray(this.currentFileCache.get((int) (index - this.dataList.size() - currentSize)));
                } else {
                    currentSize += noOfFrames;
                }
            } catch (IOException ioex) {
                throw new Twister2RuntimeException("Failed to read from file : " + nextFile);
            }
        }
        return (T) dataType.getDataPacker().unpackFromByteArray(this.buffers.get((int) (index - currentSize)));
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 27 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class BufferedCollectionPartition method clear.

@Override
public void clear() {
    // cleanup files
    for (Path path : this.filesList) {
        try {
            this.fileSystem.delete(path, true);
        } catch (IOException e) {
            throw new Twister2RuntimeException("Failed to delete the temporary file : " + path.toString(), e);
        }
    }
    super.clear();
    this.filesList.clear();
    this.buffers.clear();
    this.bufferedBytes = 0;
    this.fileCounter = 0;
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) IOException(java.io.IOException)

Example 28 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class DataSource method getNextSplit.

public InputSplit<T> getNextSplit(int id) {
    InputSplitAssigner<T> assigner = input.getInputSplitAssigner(splits);
    InputSplit<T> split = assigner.getNextInputSplit("localhost", id);
    if (split != null) {
        try {
            split.open(config);
        } catch (IOException e) {
            throw new Twister2RuntimeException("Failed to open the input split because, it", e);
        }
        return split;
    } else {
        return null;
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) IOException(java.io.IOException)

Example 29 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class Twister2ArrowFileReader method initInputFile.

public void initInputFile() {
    try {
        LOG.info("arrow schema:" + Schema.fromJSON(arrowSchema));
        Path path = new Path(arrowInputFile);
        this.fileSystem = FileSystemUtils.get(path);
        this.fsDataInputStream = fileSystem.open(path);
        this.fileInputStream = new FileInputStream(arrowInputFile);
        this.arrowFileReader = new ArrowFileReader(new SeekableReadChannel(fileInputStream.getChannel()), rootAllocator);
        this.root = arrowFileReader.getVectorSchemaRoot();
        arrowBlocks = arrowFileReader.getRecordBlocks();
        LOG.info("\nReading the arrow file : " + arrowInputFile + "\tFile size:" + arrowInputFile.length() + "\tschema:" + root.getSchema().toString() + "\tArrow Blocks Size: " + arrowBlocks.size());
    } catch (FileNotFoundException e) {
        throw new Twister2RuntimeException("File Not Found", e);
    } catch (Exception ioe) {
        throw new Twister2RuntimeException("IOException Occured", ioe);
    }
}
Also used : Path(edu.iu.dsc.tws.api.data.Path) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) ArrowFileReader(org.apache.arrow.vector.ipc.ArrowFileReader) FileNotFoundException(java.io.FileNotFoundException) SeekableReadChannel(org.apache.arrow.vector.ipc.SeekableReadChannel) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

Example 30 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class MPIWorkerManager method execute.

public boolean execute(Config config, JobAPI.Job job, IWorkerController workerController, IPersistentVolume persistentVolume, IVolatileVolume volatileVolume, IWorker managedWorker) {
    int workerID = workerController.getWorkerInfo().getWorkerID();
    LOG.info("Waiting on the init barrier before starting IWorker: " + workerID + " with restartCount: " + workerController.workerRestartCount() + " and with re-executionCount: " + JobProgress.getWorkerExecuteCount());
    try {
        workerController.waitOnInitBarrier();
        firstInitBarrierProceeded = true;
    } catch (TimeoutException e) {
        throw new Twister2RuntimeException("Could not pass through the init barrier", e);
    }
    // if it is executing for the first time, release worker ports
    if (JobProgress.getWorkerExecuteCount() == 0) {
        NetworkUtils.releaseWorkerPorts();
    }
    JobProgressImpl.setJobStatus(JobProgress.JobStatus.EXECUTING);
    JobProgressImpl.increaseWorkerExecuteCount();
    try {
        managedWorker.execute(config, job, workerController, persistentVolume, volatileVolume);
        return true;
    } catch (JobFaultyException jfe) {
        // a worker in the cluster should have failed
        JobProgressImpl.setJobStatus(JobProgress.JobStatus.FAULTY);
        throw jfe;
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) JobFaultyException(edu.iu.dsc.tws.api.exceptions.JobFaultyException) TimeoutException(edu.iu.dsc.tws.api.exceptions.TimeoutException)

Aggregations

Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)65 Twister2Exception (edu.iu.dsc.tws.api.exceptions.Twister2Exception)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)10 JobMasterAPI (edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI)8 Path (edu.iu.dsc.tws.api.data.Path)7 Config (edu.iu.dsc.tws.api.config.Config)6 File (java.io.File)5 TimeoutException (edu.iu.dsc.tws.api.exceptions.TimeoutException)4 FileInputStream (java.io.FileInputStream)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 Twister2JobState (edu.iu.dsc.tws.api.scheduler.Twister2JobState)3 ArrowTableBuilder (edu.iu.dsc.tws.common.table.ArrowTableBuilder)3 TableRuntime (edu.iu.dsc.tws.common.table.arrow.TableRuntime)3 List (java.util.List)3 Map (java.util.Map)3 Logger (java.util.logging.Logger)3 MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)2 TaskSchedulerException (edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException)2