Search in sources :

Example 11 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class ZKBarrierManager method createBarrierDir.

/**
 * create parent directory for barrier
 */
public static void createBarrierDir(CuratorFramework client, String barrierDirPath) {
    try {
        client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(barrierDirPath);
        LOG.info("BarrierDirectory created: " + barrierDirPath);
    } catch (Exception e) {
        throw new Twister2RuntimeException("BarrierDirectory can not be created for the path: " + barrierDirPath, 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 12 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class ZKEphemStateManager method createEphemDir.

/**
 * create parent directory for ephemeral worker znodes
 */
public static void createEphemDir(CuratorFramework client, String rootPath, String jobID) {
    String ephemDirPath = ZKUtils.ephemDir(rootPath, jobID);
    try {
        client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(ephemDirPath);
        LOG.info("Job EphemStateDir created: " + ephemDirPath);
    } catch (Exception e) {
        throw new Twister2RuntimeException("EphemStateDir can not be created for the path: " + ephemDirPath, 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 13 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class ZKEventsManager method createEventsZNode.

/**
 * 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 createEventsZNode(CuratorFramework client, String rootPath, String jobID) {
    String eventsDir = ZKUtils.eventsDir(rootPath, jobID);
    try {
        client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(eventsDir);
        LOG.info("Job EventsZnode created: " + eventsDir);
    } catch (Exception e) {
        throw new Twister2RuntimeException("EventsZnode can not be created for the path: " + eventsDir, e);
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2Exception(edu.iu.dsc.tws.api.exceptions.Twister2Exception)

Example 14 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class RowSchema method fromArrow.

public static RowSchema fromArrow(org.apache.arrow.vector.types.pojo.Schema schema) {
    List<Field> fields = schema.getFields();
    List<TField> tFields = new ArrayList<>();
    for (Field f : fields) {
        TField tField;
        if (f.getFieldType().equals(ArrowTypes.INT_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.INTEGER);
        } else if (f.getFieldType().equals(ArrowTypes.LONG_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.LONG);
        } else if (f.getFieldType().equals(ArrowTypes.SHORT_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.SHORT);
        } else if (f.getFieldType().equals(ArrowTypes.FLOAT_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.FLOAT);
        } else if (f.getFieldType().equals(ArrowTypes.DOUBLE_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.DOUBLE);
        } else if (f.getFieldType().equals(ArrowTypes.STRING_FIELD_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.STRING);
        } else if (f.getFieldType().equals(ArrowTypes.BINARY_FILED_TYPE)) {
            tField = new TField(f.getName(), MessageTypes.BYTE);
        } else {
            throw new Twister2RuntimeException("Unknown type");
        }
        tFields.add(tField);
    }
    return new RowSchema(tFields);
}
Also used : Field(org.apache.arrow.vector.types.pojo.Field) TField(edu.iu.dsc.tws.common.table.TField) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) TField(edu.iu.dsc.tws.common.table.TField) ArrayList(java.util.ArrayList)

Example 15 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.

the class K8sWorkerUtils method initRestartFromCM.

/**
 * get restartCount from a ConfigMap in K8s master
 * if the worker/jm is starting for the first time,
 * we need to add the config restart count key to the config map
 * otherwise, we need to increase the restart count at the configmap
 * <p>
 * restartCount is returned as zero if the worker/jm is starting for the first time,
 * if it is more than zero, the worker is restarting
 */
public static int initRestartFromCM(KubernetesController controller, String jbID, String keyName) {
    int restartCount = controller.getRestartCount(jbID, keyName);
    // increase the count by 1 for the new value
    restartCount++;
    // add the key to configmap and set its value as zero
    if (restartCount == 0) {
        boolean added = controller.addConfigMapParam(jbID, keyName, 0 + "");
        if (!added) {
            throw new Twister2RuntimeException("Could not add the restartCount to ConfigMap");
        }
    // if restartCount is more than 0 after the increase, the worker has started before,
    // it is coming from failure, set new count
    } else if (restartCount > 0) {
        boolean updated = controller.updateConfigMapParam(jbID, keyName, restartCount + "");
        if (!updated) {
            throw new Twister2RuntimeException("Could not update the restartCount in ConfigMap");
        }
    }
    return restartCount;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

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