Search in sources :

Example 6 with Twister2RuntimeException

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);
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

Example 7 with Twister2RuntimeException

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.");
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception)

Example 8 with Twister2RuntimeException

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);
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception)

Example 9 with Twister2RuntimeException

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);
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception)

Example 10 with Twister2RuntimeException

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);
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception)

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