use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class TaskScheduler method generateTaskSchedulePlan.
private TaskSchedulePlan generateTaskSchedulePlan(String className) {
Class<?> taskSchedulerClass;
Method method;
TaskSchedulePlan taskSchedulePlan;
try {
taskSchedulerClass = getClass().getClassLoader().loadClass(className);
Object newInstance = taskSchedulerClass.newInstance();
method = taskSchedulerClass.getMethod("initialize", new Class<?>[] { Config.class });
method.invoke(newInstance, config);
method = taskSchedulerClass.getMethod("schedule", new Class<?>[] { ComputeGraph.class, WorkerPlan.class });
taskSchedulePlan = (TaskSchedulePlan) method.invoke(newInstance, computeGraph, workerPlan);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException | ClassNotFoundException | TaskSchedulerException e) {
throw new Twister2RuntimeException(e);
}
if (taskSchedulePlan != null) {
Map<Integer, WorkerSchedulePlan> containersMap = taskSchedulePlan.getContainersMap();
for (Map.Entry<Integer, WorkerSchedulePlan> entry : containersMap.entrySet()) {
Integer integer = entry.getKey();
WorkerSchedulePlan workerSchedulePlan = entry.getValue();
Set<TaskInstancePlan> containerPlanTaskInstances = workerSchedulePlan.getTaskInstances();
LOG.fine("Task Details for Container Id:" + integer);
for (TaskInstancePlan ip : containerPlanTaskInstances) {
LOG.fine("Task Id:" + ip.getTaskId() + "\tTask Index" + ip.getTaskIndex() + "\tTask Name:" + ip.getTaskName());
}
}
}
return taskSchedulePlan;
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class RowSourceOp method prepare.
@Override
public void prepare(Config cfg, TaskContext ctx) {
super.prepare(cfg, ctx);
runtime = WorkerEnvironment.getSharedValue(TableRuntime.TABLE_RUNTIME_CONF, TableRuntime.class);
if (runtime == null) {
throw new Twister2RuntimeException("Table runtime must be set");
}
schema = (RowSchema) ctx.getConfig(TSetConstants.OUTPUT_SCHEMA_KEY);
tableMaxSize = cfg.getLongValue("twister2.table.max.size", tableMaxSize);
builder = new ArrowTableBuilder(schema.toArrowSchema(), runtime.getRootAllocator());
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class RowComupteCollectorOp method prepare.
@Override
public void prepare(Config cfg, TaskContext ctx) {
super.prepare(cfg, ctx);
runtime = WorkerEnvironment.getSharedValue(TableRuntime.TABLE_RUNTIME_CONF, TableRuntime.class);
if (runtime == null) {
throw new Twister2RuntimeException("Table runtime must be set");
}
schema = (RowSchema) ctx.getConfig(TSetConstants.OUTPUT_SCHEMA_KEY);
tableMaxSize = cfg.getLongValue("twister2.table.max.size", tableMaxSize);
builder = new ArrowTableBuilder(schema.toArrowSchema(), runtime.getRootAllocator());
collectorImp = new CollectorImp();
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class DataGeneratorSource method generateData.
public void generateData() {
try {
int numOfFiles = 1;
int sizeMargin = 100;
KMeansDataGenerator.generateData("txt", new Path(dataDirectory), numOfFiles, dsize, sizeMargin, dim, config);
KMeansDataGenerator.generateData("txt", new Path(centroidDirectory), numOfFiles, csize, sizeMargin, dim, config);
} catch (IOException ioe) {
throw new Twister2RuntimeException("Failed to create input data:", ioe);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class BufferedCollectionPartition method flush.
public void flush() {
if (this.buffers.isEmpty()) {
return;
}
Path filePath = new Path(this.rootPath, (this.fileCounter++) + EXTENSION);
try (DataOutputStream outputStream = new DataOutputStream(this.fileSystem.create(filePath))) {
outputStream.writeLong(this.buffers.size());
Iterator<byte[]> bufferIt = this.buffers.iterator();
while (bufferIt.hasNext()) {
byte[] next = bufferIt.next();
outputStream.writeInt(next.length);
outputStream.write(next);
}
} catch (IOException e) {
throw new Twister2RuntimeException("Couldn't flush partitions to the disk", e);
}
this.filesList.add(filePath);
this.buffers.clear();
this.bufferedBytes = 0;
}
Aggregations