Search in sources :

Example 1 with ShutdownListener

use of es.bsc.compss.types.resources.ShutdownListener in project compss by bsc-wdc.

the class NIOAdaptor method shutdownNotification.

@Override
public void shutdownNotification(Connection c) {
    ClosingWorker closing = STOPPING_NODES.remove(c);
    NIOWorkerNode worker = closing.worker;
    removedNode(worker);
    ShutdownListener listener = closing.listener;
    listener.notifyEnd();
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) ExecutorShutdownListener(es.bsc.compss.types.resources.ExecutorShutdownListener)

Example 2 with ShutdownListener

use of es.bsc.compss.types.resources.ShutdownListener in project compss by bsc-wdc.

the class NIOAdaptor method stop.

@Override
public void stop() {
    LOGGER.debug("NIO Adaptor stopping workers...");
    Set<NIOWorkerNode> workers = new HashSet<>();
    workers.addAll(NODES);
    Semaphore sem = new Semaphore(0);
    ShutdownListener sl = new ShutdownListener(sem);
    for (NIOWorkerNode worker : workers) {
        LOGGER.debug("- Stopping worker " + worker.getName());
        sl.addOperation();
        worker.stop(sl);
    }
    LOGGER.debug("- Waiting for workers to shutdown...");
    sl.enable();
    try {
        sem.acquire();
    } catch (Exception e) {
        LOGGER.error("ERROR: Exception raised on worker shutdown");
    }
    LOGGER.debug("- Workers stopped");
    LOGGER.debug("- Shutting down TM...");
    TM.shutdown(null);
    LOGGER.debug("NIO Adaptor stop completed!");
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) ExecutorShutdownListener(es.bsc.compss.types.resources.ExecutorShutdownListener) Semaphore(java.util.concurrent.Semaphore) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) CommException(es.bsc.comm.exceptions.CommException) HashSet(java.util.HashSet)

Example 3 with ShutdownListener

use of es.bsc.compss.types.resources.ShutdownListener in project compss by bsc-wdc.

the class StopWorkerAction method doAction.

@Override
protected void doAction() {
    (new Thread() {

        @SuppressWarnings("unchecked")
        @Override
        public void run() {
            Worker<WorkerResourceDescription> wResource = (Worker<WorkerResourceDescription>) worker.getResource();
            Thread.currentThread().setName(wResource.getName() + " stopper");
            wResource.retrieveData(true);
            Semaphore sem = new Semaphore(0);
            ShutdownListener sl = new ShutdownListener(sem);
            wResource.stop(sl);
            sl.enable();
            try {
                sem.acquire();
            } catch (Exception e) {
                LOGGER.error("ERROR: Exception raised on worker shutdown", e);
                ErrorManager.warn("Exception stopping worker. Check runtime.log for more details", e);
                notifyError();
            }
            notifyCompleted();
        }
    }).start();
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) Worker(es.bsc.compss.types.resources.Worker) Semaphore(java.util.concurrent.Semaphore) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException)

Example 4 with ShutdownListener

use of es.bsc.compss.types.resources.ShutdownListener in project compss by bsc-wdc.

the class AbstractConnector method terminateAll.

@Override
public void terminateAll() {
    terminate = true;
    dead.terminate();
    synchronized (IPToVM) {
        for (VM vm : IPToVM.values()) {
            LOGGER.info("[Abstract Connector] Retrieving data from VM " + vm.getName());
            vm.getWorker().retrieveData(false);
            LOGGER.info("[Abstract Connector] Destroying VM " + vm.getName());
            Semaphore sem = new Semaphore(0);
            ShutdownListener sl = new ShutdownListener(sem);
            vm.getWorker().stop(sl);
            sl.enable();
            try {
                sem.acquire();
            } catch (Exception e) {
                LOGGER.error("ERROR: Exception raised on worker shutdown");
            }
            try {
                destroy(vm.getEnvId());
            } catch (Exception e) {
                LOGGER.error("ERROR: Exception while trying to destroy the virtual machine " + vm.getName(), e);
            }
        }
    }
    // Clear all
    synchronized (IPToVM) {
        IPToVM.clear();
    }
    synchronized (vmsToDelete) {
        vmsToDelete.clear();
    }
    synchronized (vmsAlive) {
        vmsAlive.clear();
    }
    // Close connector
    close();
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) Semaphore(java.util.concurrent.Semaphore) ConcurrentModificationException(java.util.ConcurrentModificationException)

Example 5 with ShutdownListener

use of es.bsc.compss.types.resources.ShutdownListener in project compss by bsc-wdc.

the class ResourceManager method stopNodes.

/**
 * Stops all the nodes within the pool
 */
public static void stopNodes() {
    // Log resource
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    RESOURCES_LOGGER.info("INFO_MSG = [Stopping all workers]");
    RUNTIME_LOGGER.info("Stopping all workers");
    // Stop all Cloud VM
    if (cloudManager.isUseCloud()) {
        // Transfer files
        RESOURCES_LOGGER.debug("DEBUG_MSG = [Terminating cloud instances...]");
        try {
            cloudManager.terminateALL();
            RESOURCES_LOGGER.info("TOTAL_EXEC_COST = " + cloudManager.getTotalCost());
        } catch (Exception e) {
            RESOURCES_LOGGER.error(COMPSsConstants.TS + ": " + DEL_VM_ERR, e);
        }
        RESOURCES_LOGGER.info("INFO_MSG = [Cloud instances terminated]");
    }
    // Physical worker (COMM) is erased now - because of cloud
    if (pool != null && !pool.getStaticResources().isEmpty()) {
        RESOURCES_LOGGER.debug("DEBUG_MSG = [Resource Manager retrieving data from workers...]");
        for (Worker<? extends WorkerResourceDescription> r : pool.getStaticResources()) {
            r.retrieveData(false);
        }
        Semaphore sem = new Semaphore(0);
        ShutdownListener sl = new ShutdownListener(sem);
        RESOURCES_LOGGER.debug("DEBUG_MSG = [Resource Manager stopping workers...]");
        for (Worker<? extends WorkerResourceDescription> r : pool.getStaticResources()) {
            r.stop(sl);
        }
        RESOURCES_LOGGER.debug("DEBUG_MSG = [Waiting for workers to shutdown...]");
        sl.enable();
        try {
            sem.acquire();
        } catch (Exception e) {
            RESOURCES_LOGGER.error("ERROR_MSG= [ERROR: Exception raised on worker shutdown]");
        }
        RESOURCES_LOGGER.info("INFO_MSG = [Workers stopped]");
    }
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) Semaphore(java.util.concurrent.Semaphore) NoResourceAvailableException(es.bsc.compss.exceptions.NoResourceAvailableException) ProjectFileValidationException(es.bsc.compss.types.project.exceptions.ProjectFileValidationException) InitNodeException(es.bsc.compss.exceptions.InitNodeException) ConnectorException(es.bsc.compss.connectors.ConnectorException) ResourcesFileValidationException(es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)

Aggregations

ShutdownListener (es.bsc.compss.types.resources.ShutdownListener)6 Semaphore (java.util.concurrent.Semaphore)5 ConnectorException (es.bsc.compss.connectors.ConnectorException)2 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)2 ExecutorShutdownListener (es.bsc.compss.types.resources.ExecutorShutdownListener)2 CommException (es.bsc.comm.exceptions.CommException)1 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 InitNodeException (es.bsc.compss.exceptions.InitNodeException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)1 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)1 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)1 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 Worker (es.bsc.compss.types.resources.Worker)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)1 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)1 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)1 ResourcesFileValidationException (es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)1