use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKPersStateManager method createPersStateDir.
/**
* Create job znode for persistent states
* Assumes that there is no znode exists in the ZooKeeper
* This method should be called by the submitting client
*/
public static void createPersStateDir(CuratorFramework client, String rootPath, String jobID) {
String persStatePath = ZKUtils.persDir(rootPath, jobID);
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(persStatePath);
LOG.info("Job PersStateDir created: " + persStatePath);
} catch (Exception e) {
throw new Twister2RuntimeException("PersStateDir can not be created for the path: " + persStatePath, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKMasterController method workerRestarted.
@Override
public void workerRestarted(JobMasterAPI.WorkerInfo workerInfo) {
// generate en event and inform all other workers
JobMasterAPI.WorkerRestarted workerRestarted = JobMasterAPI.WorkerRestarted.newBuilder().setWorkerInfo(workerInfo).build();
JobMasterAPI.JobEvent jobEvent = JobMasterAPI.JobEvent.newBuilder().setRestarted(workerRestarted).build();
try {
ZKEventsManager.publishEvent(client, rootPath, jobID, jobEvent);
} catch (Twister2Exception e) {
throw new Twister2RuntimeException(e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKBarrierHandler method getInitialWorkersAtBarrier.
private long getInitialWorkersAtBarrier(PathChildrenCache childrenCache, Set<Integer> workersAtBarrier) {
long timeout = 0;
List<ChildData> existingWorkerZnodes = childrenCache.getCurrentData();
for (ChildData child : existingWorkerZnodes) {
String fullPath = child.getPath();
int workerID = ZKUtils.getWorkerIDFromPersPath(fullPath);
workersAtBarrier.add(workerID);
if (timeout == 0) {
try {
ZKBarrierManager.readWorkerTimeout(client, fullPath);
} catch (Twister2Exception e) {
throw new Twister2RuntimeException(e);
}
}
}
return timeout;
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class TaskScheduler method generateTaskSchedulePlans.
private Map<String, TaskSchedulePlan> generateTaskSchedulePlans(String className) {
Class<?> taskSchedulerClass;
Method method;
Map<String, TaskSchedulePlan> taskSchedulePlanMap;
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<?>[] { WorkerPlan.class, ComputeGraph[].class });
taskSchedulePlanMap = (Map<String, TaskSchedulePlan>) method.invoke(newInstance, new Object[] { workerPlan, computeGraphs });
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | InstantiationException | ClassNotFoundException | TaskSchedulerException e) {
throw new Twister2RuntimeException(e);
}
return taskSchedulePlanMap;
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class LocalSubmitter method prepare.
/**
* This method sets the necessary initial configurations to execute the twister2 core classes
*/
private static LocalSubmitter prepare(String configDir) {
System.setProperty("cluster_type", "standalone");
// do a simple config dir validation
File cDir = new File(configDir, "standalone");
for (String file : FILES_LIST) {
File toCheck = new File(cDir, file);
if (!toCheck.exists()) {
throw new Twister2RuntimeException("Couldn't find " + file + " in config directory specified.");
}
}
System.setProperty("config_dir", configDir);
System.setProperty("twister2_home", System.getProperty("java.io.tmpdir"));
// setup logging
try {
File commonConfig = new File(configDir, "common");
FileInputStream fis = new FileInputStream(new File(commonConfig, "logger.properties"));
LogManager.getLogManager().readConfiguration(fis);
} catch (IOException e) {
LOG.warning("Couldn't load logging configuration");
}
prepared = true;
return new LocalSubmitter();
}
Aggregations