Search in sources :

Example 61 with Twister2RuntimeException

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

the class BufferedCollectionPartition method loadFromFS.

/**
 * This method loads existing frames on disk
 */
private void loadFromFS() {
    try {
        FileStatus[] fileStatuses = this.fileSystem.listFiles(this.rootPath);
        this.filesList = Arrays.stream(fileStatuses).map(FileStatus::getPath).filter(p -> p.getName().contains(EXTENSION)).sorted(Comparator.comparingLong(path -> Long.parseLong(path.getName().replace(EXTENSION, "")))).collect(Collectors.toList());
        this.fileCounter = fileStatuses.length;
    } catch (IOException e) {
        throw new Twister2RuntimeException("Failed to load frames from file system", e);
    }
}
Also used : DataInputStream(java.io.DataInputStream) Arrays(java.util.Arrays) Iterator(java.util.Iterator) FileStatus(edu.iu.dsc.tws.api.data.FileStatus) DataPartitionConsumer(edu.iu.dsc.tws.api.dataset.DataPartitionConsumer) MessageType(edu.iu.dsc.tws.api.comms.messaging.types.MessageType) Collection(java.util.Collection) IOException(java.io.IOException) Config(edu.iu.dsc.tws.api.config.Config) UUID(java.util.UUID) MessageTypes(edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) ArrayList(java.util.ArrayList) FileSystem(edu.iu.dsc.tws.api.data.FileSystem) List(java.util.List) DataOutputStream(java.io.DataOutputStream) Closeable(java.io.Closeable) Path(edu.iu.dsc.tws.api.data.Path) Queue(java.util.Queue) Comparator(java.util.Comparator) LinkedList(java.util.LinkedList) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) FileStatus(edu.iu.dsc.tws.api.data.FileStatus) IOException(java.io.IOException)

Example 62 with Twister2RuntimeException

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

the class ZKMasterController method jobScaled.

@Override
public void jobScaled(int change, int numberOfWorkers1) {
    if (change < 0) {
        scaledDownWorkers = new LinkedList<>();
        for (int i = numberOfWorkers1; i < numberOfWorkers; i++) {
            scaledDownWorkers.add(i);
        }
    }
    this.numberOfWorkers = numberOfWorkers1;
    // generate en event and inform all other workers
    JobMasterAPI.JobScaled jobScaled = JobMasterAPI.JobScaled.newBuilder().setNumberOfWorkers(numberOfWorkers1).setChange(change).build();
    JobMasterAPI.JobEvent jobEvent = JobMasterAPI.JobEvent.newBuilder().setJobScaled(jobScaled).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 63 with Twister2RuntimeException

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

the class ZKMasterController method allJoined.

@Override
public void allJoined() {
    List<JobMasterAPI.WorkerInfo> workers = workerMonitor.getWorkerInfoList();
    JobMasterAPI.AllJoined allWorkersJoined = JobMasterAPI.AllJoined.newBuilder().addAllWorkerInfo(workers).setNumberOfWorkers(workers.size()).build();
    JobMasterAPI.JobEvent jobEvent = JobMasterAPI.JobEvent.newBuilder().setAllJoined(allWorkersJoined).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 64 with Twister2RuntimeException

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

the class MPIWorkerStarter method broadCastMasterInformation.

/**
 * Broadcast the job master information to workers
 *
 * @param rank rank
 */
private void broadCastMasterInformation(int rank) {
    byte[] workerBytes = wInfo.toByteArray();
    int length = workerBytes.length;
    IntBuffer countSend = MPI.newIntBuffer(1);
    if (rank == 0) {
        countSend.put(length);
    }
    try {
        MPI.COMM_WORLD.bcast(countSend, 1, MPI.INT, 0);
        length = countSend.get(0);
        ByteBuffer sendBuffer = MPI.newByteBuffer(length);
        if (rank == 0) {
            sendBuffer.put(workerBytes);
        }
        MPI.COMM_WORLD.bcast(sendBuffer, length, MPI.BYTE, 0);
        byte[] jmInfoBytes = new byte[length];
        if (rank != 0) {
            sendBuffer.get(jmInfoBytes);
            JobMasterAPI.WorkerInfo masterInfo = JobMasterAPI.WorkerInfo.newBuilder().mergeFrom(jmInfoBytes).build();
            config = Config.newBuilder().putAll(config).put(JobMasterContext.JOB_MASTER_PORT, masterInfo.getPort()).put(JobMasterContext.JOB_MASTER_IP, masterInfo.getNodeInfo().getNodeIP()).build();
        } else {
            config = Config.newBuilder().putAll(config).put(JobMasterContext.JOB_MASTER_PORT, wInfo.getPort()).put(JobMasterContext.JOB_MASTER_IP, wInfo.getNodeInfo().getNodeIP()).build();
        }
    } catch (MPIException mpie) {
        throw new Twister2RuntimeException("Error when broadcasting Job Master information", mpie);
    } catch (InvalidProtocolBufferException ipbe) {
        throw new Twister2RuntimeException("Error when decoding Job Master information", ipbe);
    }
}
Also used : MPIException(mpi.MPIException) JobMasterAPI(edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) IntBuffer(java.nio.IntBuffer) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ByteBuffer(java.nio.ByteBuffer)

Example 65 with Twister2RuntimeException

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

the class NetworkUtils method findFreePorts.

/**
 * Returns the list of free ports on localhost.
 * A ServerSocket is started on each port
 * These ports must be released after the JMWorkerAgent is started and
 * before IWorker is started in MPIWorkerManager/WorkerManager
 * using releaseWorkerPorts method
 *
 * @return a list of free ports
 */
public static Map<String, Integer> findFreePorts(List<String> portNames) {
    List<ServerSocket> sockets = new ArrayList<>();
    Map<String, Integer> freePorts = new HashMap<>();
    try {
        for (String portName : portNames) {
            ServerSocket socket = new ServerSocket(0);
            socket.setReuseAddress(true);
            freePorts.put(portName, socket.getLocalPort());
            sockets.add(socket);
        }
        WorkerEnvironment.putSharedValue("socketsForFreePorts", sockets);
        return freePorts;
    } catch (IOException e) {
        throw new Twister2RuntimeException("Could not find free TCP/IP ports");
    }
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException)

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