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)));
}
}
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;
}
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;
}
}
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);
}
}
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;
}
}
Aggregations