Search in sources :

Example 41 with Twister2RuntimeException

use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project beam by apache.

the class Twister2Runner method setupSystem.

private void setupSystem(Twister2PipelineOptions options) {
    prepareFilesToStage(options);
    zipFilesToStage(options);
    System.setProperty("cluster_type", options.getClusterType());
    System.setProperty("job_file", options.getJobFileZip());
    System.setProperty("job_type", options.getJobType());
    if (isLocalMode(options)) {
        System.setProperty("twister2_home", System.getProperty("java.io.tmpdir"));
        System.setProperty("config_dir", System.getProperty("java.io.tmpdir") + "/conf/");
    } else {
        System.setProperty("twister2_home", options.getTwister2Home());
        System.setProperty("config_dir", options.getTwister2Home() + "/conf/");
        // do a simple config dir validation
        File cDir = new File(System.getProperty("config_dir"), options.getClusterType());
        String[] filesList = new String[] { "core.yaml", "network.yaml", "data.yaml", "resource.yaml", "task.yaml" };
        for (String file : filesList) {
            File toCheck = new File(cDir, file);
            if (!toCheck.exists()) {
                throw new Twister2RuntimeException("Couldn't find " + file + " in config directory specified.");
            }
        }
        // setup logging
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(new File(cDir, "logger.properties"));
            LogManager.getLogManager().readConfiguration(fis);
            fis.close();
        } catch (IOException e) {
            LOG.warning("Couldn't load logging configuration");
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    LOG.info(e.getMessage());
                }
            }
        }
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 42 with Twister2RuntimeException

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

the class ZKEventsManager method initEventCounter.

public static void initEventCounter(CuratorFramework client, String rootPath, String jobID) {
    String eventsDir = ZKUtils.eventsDir(rootPath, jobID);
    try {
        eventCounter = client.getChildren().forPath(eventsDir).size();
        LOG.info("eventCounter is set to: " + eventCounter);
    } catch (Exception e) {
        throw new Twister2RuntimeException("Could not get children of events directory: " + 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 43 with Twister2RuntimeException

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

the class TCPChannel method iSend.

/**
 * Send a buffer
 * @param buffer buffer
 * @param size size of the buffer, we assume start from 0th position
 * @param workerID the worker id
 * @param edge the edg
 * @return the reference message created
 */
public TCPMessage iSend(ByteBuffer buffer, int size, int workerID, int edge) {
    SocketChannel ch = clientChannels.get(workerID);
    if (ch == null) {
        throw new Twister2RuntimeException("Can not send to an un-connected worker: " + workerID);
    }
    Client client = clients.get(workerID);
    return client.send(ch, buffer, size, edge);
}
Also used : SocketChannel(java.nio.channels.SocketChannel) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

Example 44 with Twister2RuntimeException

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

the class RowSchema method toArrowSchema.

public org.apache.arrow.vector.types.pojo.Schema toArrowSchema() {
    List<Field> fields = new ArrayList<>();
    for (TField f : types) {
        Field field;
        if (f.getType().equals(MessageTypes.INTEGER)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(32, true), null), null);
        } else if (f.getType().equals(MessageTypes.LONG)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(64, true), null), null);
        } else if (f.getType().equals(MessageTypes.SHORT)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(16, true), null), null);
        } else if (f.getType().equals(MessageTypes.FLOAT)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null), null);
        } else if (f.getType().equals(MessageTypes.DOUBLE)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), null), null);
        } else if (f.getType().equals(MessageTypes.STRING)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.Binary(), null), null);
        } else if (f.getType().equals(MessageTypes.BYTE)) {
            field = new Field(f.getName(), new FieldType(false, new ArrowType.Binary(), null), null);
        } else {
            throw new Twister2RuntimeException("Un-known type");
        }
        fields.add(field);
    }
    return new org.apache.arrow.vector.types.pojo.Schema(fields);
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) TField(edu.iu.dsc.tws.common.table.TField) ArrayList(java.util.ArrayList) ArrowType(org.apache.arrow.vector.types.pojo.ArrowType) FieldType(org.apache.arrow.vector.types.pojo.FieldType) Field(org.apache.arrow.vector.types.pojo.Field) TField(edu.iu.dsc.tws.common.table.TField)

Example 45 with Twister2RuntimeException

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

the class ZKPersStateManager method updateJobMasterStatus.

/**
 * update jm status at ZK
 */
public static void updateJobMasterStatus(CuratorFramework client, String rootPath, String jobID, String jmAddress, JobMasterState state) {
    String jmPersPath = ZKUtils.jmPersPath(rootPath, jobID);
    try {
        byte[] znodeBody = ZKUtils.encodeJobMasterZnode(jmAddress, state.getNumber());
        client.setData().forPath(jmPersPath, znodeBody);
    } catch (Exception e) {
        throw new Twister2RuntimeException("Can not update job master pers state znode.", 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