Search in sources :

Example 1 with Twister2RuntimeException

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);
    }
}
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 2 with Twister2RuntimeException

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

Example 3 with Twister2RuntimeException

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;
}
Also used : Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) ChildData(org.apache.curator.framework.recipes.cache.ChildData)

Example 4 with Twister2RuntimeException

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;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Config(edu.iu.dsc.tws.api.config.Config) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) TaskSchedulerException(edu.iu.dsc.tws.api.compute.exceptions.TaskSchedulerException) WorkerPlan(edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan) TaskSchedulePlan(edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)

Example 5 with Twister2RuntimeException

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

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