Search in sources :

Example 1 with NIOMessageHandler

use of es.bsc.compss.nio.NIOMessageHandler in project compss by bsc-wdc.

the class NIOWorker method main.

public static void main(String[] args) {
    // Check arguments length
    if (args.length != (NUM_PARAMS_NIO_WORKER)) {
        if (WORKER_LOGGER_DEBUG) {
            WORKER_LOGGER.debug("Received parameters: ");
            for (int i = 0; i < args.length; ++i) {
                WORKER_LOGGER.debug("Param " + i + ":  " + args[i]);
            }
        }
        ErrorManager.fatal(ERROR_INCORRECT_NUM_PARAMS);
    }
    // Parse arguments
    isWorkerDebugEnabled = Boolean.valueOf(args[0]);
    int maxSnd = Integer.parseInt(args[1]);
    int maxRcv = Integer.parseInt(args[2]);
    String workerIP = args[3];
    int wPort = Integer.parseInt(args[4]);
    int mPort = Integer.parseInt(args[5]);
    int computingUnitsCPU = Integer.parseInt(args[6]);
    int computingUnitsGPU = Integer.parseInt(args[7]);
    String cpuMap = args[8];
    String gpuMap = args[9];
    int limitOfTasks = Integer.parseInt(args[10]);
    String appUuid = args[11];
    String lang = args[12];
    String workingDir = args[13];
    String installDir = args[14];
    String appDir = args[15];
    String libPath = args[16];
    String classpath = args[17];
    String pythonpath = args[18];
    String trace = args[19];
    String extraeFile = args[20];
    String host = args[21];
    storageConf = args[22];
    executionType = args[23];
    persistentC = Boolean.parseBoolean(args[24]);
    // Print arguments
    if (isWorkerDebugEnabled) {
        WORKER_LOGGER.debug("maxSnd: " + String.valueOf(maxSnd));
        WORKER_LOGGER.debug("maxRcv: " + String.valueOf(maxRcv));
        WORKER_LOGGER.debug("WorkerName: " + workerIP);
        WORKER_LOGGER.debug("WorkerPort: " + String.valueOf(wPort));
        WORKER_LOGGER.debug("MasterPort: " + String.valueOf(mPort));
        WORKER_LOGGER.debug("Computing Units CPU: " + String.valueOf(computingUnitsCPU));
        WORKER_LOGGER.debug("Computing Units GPU: " + String.valueOf(computingUnitsGPU));
        WORKER_LOGGER.debug("User defined CPU Map: " + cpuMap);
        WORKER_LOGGER.debug("User defined GPU Map: " + gpuMap);
        WORKER_LOGGER.debug("Limit Of Tasks: " + String.valueOf(limitOfTasks));
        WORKER_LOGGER.debug("App uuid: " + appUuid);
        WORKER_LOGGER.debug("WorkingDir:" + workingDir);
        WORKER_LOGGER.debug("Install Dir: " + installDir);
        WORKER_LOGGER.debug("Tracing: " + trace);
        WORKER_LOGGER.debug("Extrae config File: " + extraeFile);
        WORKER_LOGGER.debug("Host: " + host);
        WORKER_LOGGER.debug("LibraryPath: " + libPath);
        WORKER_LOGGER.debug("Classpath: " + classpath);
        WORKER_LOGGER.debug("Pythonpath: " + pythonpath);
        WORKER_LOGGER.debug("StorageConf: " + storageConf);
        WORKER_LOGGER.debug("executionType: " + executionType);
        WORKER_LOGGER.debug("Persistent c: " + persistentC);
        WORKER_LOGGER.debug("Remove Sanbox WD: " + removeWD);
    }
    // Configure storage
    System.setProperty(COMPSsConstants.STORAGE_CONF, storageConf);
    try {
        if (storageConf == null || storageConf.equals("") || storageConf.equals("null")) {
            WORKER_LOGGER.warn("No storage configuration file passed");
        } else {
            StorageItf.init(storageConf);
        }
    } catch (StorageException e) {
        ErrorManager.fatal("Error loading storage configuration file: " + storageConf, e);
    }
    // Configure tracing
    System.setProperty(COMPSsConstants.EXTRAE_CONFIG_FILE, extraeFile);
    tracing_level = Integer.parseInt(trace);
    if (tracing_level > 0) {
        NIOTracer.init(tracing_level);
        NIOTracer.emitEvent(NIOTracer.Event.START.getId(), NIOTracer.Event.START.getType());
        try {
            tracingID = Integer.parseInt(host);
            NIOTracer.setWorkerInfo(installDir, workerIP, workingDir, tracingID);
        } catch (Exception e) {
            WORKER_LOGGER.error("No valid hostID provided to the tracing system. Provided ID: " + host);
        }
    }
    /*
         * ***********************************************************************************************************
         * LAUNCH THE WORKER
         *************************************************************************************************************/
    NIOWorker nw = new NIOWorker(maxSnd, maxRcv, workerIP, mPort, computingUnitsCPU, computingUnitsGPU, cpuMap, gpuMap, limitOfTasks, appUuid, lang, workingDir, installDir, appDir, libPath, classpath, pythonpath);
    NIOMessageHandler mh = new NIOMessageHandler(nw);
    // Initialize the Transfer Manager
    WORKER_LOGGER.debug("  Initializing the TransferManager structures...");
    try {
        TM.init(NIO_EVENT_MANAGER_CLASS, null, mh);
    } catch (CommException ce) {
        WORKER_LOGGER.error("Error initializing Transfer Manager on worker " + nw.getHostName(), ce);
        // Shutdown the Worker since the error it is not recoverable
        nw.shutdown(null);
        return;
    }
    // Start the Transfer Manager thread (starts the EventManager)
    WORKER_LOGGER.debug("  Starting TransferManager Thread");
    TM.start();
    try {
        TM.startServer(new NIONode(null, wPort));
    } catch (CommException ce) {
        WORKER_LOGGER.error("Error starting TransferManager Server at Worker" + nw.getHostName(), ce);
        nw.shutdown(null);
        return;
    }
    if (NIOTracer.isActivated()) {
        NIOTracer.emitEvent(NIOTracer.EVENT_END, NIOTracer.Event.START.getType());
    }
    // Wait for the Transfer Manager thread to finish (the shutdown is received on that thread)
    try {
        TM.join();
    } catch (InterruptedException ie) {
        WORKER_LOGGER.warn("TransferManager interrupted", ie);
        Thread.currentThread().interrupt();
    }
}
Also used : NIOMessageHandler(es.bsc.compss.nio.NIOMessageHandler) NIONode(es.bsc.comm.nio.NIONode) CommException(es.bsc.comm.exceptions.CommException) StorageException(storage.StorageException) StorageException(storage.StorageException) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) IOException(java.io.IOException) CommException(es.bsc.comm.exceptions.CommException) InitializationException(es.bsc.compss.nio.worker.exceptions.InitializationException) AtomicMoveNotSupportedException(java.nio.file.AtomicMoveNotSupportedException) InvalidMapException(es.bsc.compss.nio.worker.exceptions.InvalidMapException)

Example 2 with NIOMessageHandler

use of es.bsc.compss.nio.NIOMessageHandler in project compss by bsc-wdc.

the class NIOAdaptor method init.

@Override
public void init() {
    LOGGER.info("Initializing NIO Adaptor...");
    this.masterNode = new NIONode(null, MASTER_PORT);
    // Instantiate the NIO Message Handler
    final NIOMessageHandler mhm = new NIOMessageHandler(this);
    // Init the Transfer Manager
    LOGGER.debug("  Initializing the TransferManager structures...");
    try {
        TM.init(NIO_EVENT_MANAGER_CLASS, null, mhm);
    } catch (CommException ce) {
        String errMsg = "Error initializing the TransferManager";
        ErrorManager.error(errMsg, ce);
    }
    /* Init tracing values */
    tracing = System.getProperty(COMPSsConstants.TRACING) != null && Integer.parseInt(System.getProperty(COMPSsConstants.TRACING)) > 0;
    tracing_level = Integer.parseInt(System.getProperty(COMPSsConstants.TRACING));
    // Start the server
    LOGGER.debug("  Starting transfer server...");
    try {
        TM.startServer(masterNode);
    } catch (CommException ce) {
        String errMsg = "Error starting transfer server";
        ErrorManager.error(errMsg, ce);
    }
    // Start the Transfer Manager thread (starts the EventManager)
    LOGGER.debug("  Starting TransferManager Thread");
    TM.start();
}
Also used : NIONode(es.bsc.comm.nio.NIONode) NIOMessageHandler(es.bsc.compss.nio.NIOMessageHandler) CommException(es.bsc.comm.exceptions.CommException)

Aggregations

CommException (es.bsc.comm.exceptions.CommException)2 NIONode (es.bsc.comm.nio.NIONode)2 NIOMessageHandler (es.bsc.compss.nio.NIOMessageHandler)2 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 InitializationException (es.bsc.compss.nio.worker.exceptions.InitializationException)1 InvalidMapException (es.bsc.compss.nio.worker.exceptions.InvalidMapException)1 IOException (java.io.IOException)1 AtomicMoveNotSupportedException (java.nio.file.AtomicMoveNotSupportedException)1 StorageException (storage.StorageException)1