use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class LocalClassLoader method loadClass.
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (!name.startsWith("java.") && !name.startsWith("sun.") && !twsClassesToExclude.contains(name) && !this.excludedPackage(name)) {
InputStream is = getResourceAsStream(name.replace(".", "/") + ".class");
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int readBytes;
while ((readBytes = is.read(buffer)) != -1) {
baos.write(buffer, 0, readBytes);
}
byte[] bytes = baos.toByteArray();
return defineClass(name, bytes, 0, bytes.length);
} catch (NullPointerException nex) {
throw new ClassNotFoundException(name);
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error loading " + name, e);
throw new Twister2RuntimeException(e);
}
} else {
return super.loadClass(name);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class JobZNodeManager method deleteJobZNode.
/**
* delete job znode from zk server
*/
public static void deleteJobZNode(CuratorFramework client, String rootPath, String jobID) {
try {
String jobDir = ZKUtils.jobDir(rootPath, jobID);
if (client.checkExists().forPath(jobDir) != null) {
client.delete().guaranteed().deletingChildrenIfNeeded().forPath(jobDir);
LOG.info("JobDirectory deleted from ZooKeeper: " + jobDir);
} else {
LOG.info("JobDirectory does not exist at ZooKeeper: " + jobDir);
}
} catch (Exception e) {
throw new Twister2RuntimeException("Can not delete job znode.");
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class JobZNodeManager method createJobEndTimeZNode.
/**
* Create job end time znode
*/
public static void createJobEndTimeZNode(CuratorFramework client, String rootPath, String jobID) {
String endTimePath = ZKUtils.jobEndTimePath(rootPath, jobID);
long endTime = System.currentTimeMillis();
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(endTimePath, Longs.toByteArray(endTime));
LOG.info("Job End Time ZNode created: " + endTimePath);
} catch (Exception e) {
throw new Twister2RuntimeException("Can not create job end time znode: " + endTimePath, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class JobZNodeManager method createJstZNode.
/**
* Create job submission time znode
*/
public static void createJstZNode(CuratorFramework client, String rootPath, String jobID, long jsTime) {
String jstPath = ZKUtils.jobSubmisionTimePath(rootPath, jobID);
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(jstPath, Longs.toByteArray(jsTime));
LOG.info("Job Submission Time ZNode created: " + jstPath);
} catch (Exception e) {
throw new Twister2RuntimeException("Can not create job submission time znode: " + jstPath, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class JobZNodeManager method createJobZNode.
/**
* Create job znode
* Assumes that there is no znode exists in the ZooKeeper
* Add job object as its body
*/
public static void createJobZNode(CuratorFramework client, String rootPath, JobAPI.Job job) {
String jobDir = ZKUtils.jobDir(rootPath, job.getJobId());
JobWithState jobWithState = new JobWithState(job, JobAPI.JobState.STARTING);
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(jobDir, jobWithState.toByteArray());
LOG.info("Job ZNode created: " + jobDir);
} catch (Exception e) {
throw new Twister2RuntimeException("Job ZNode can not be created for the path: " + jobDir, e);
}
}
Aggregations