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();
}
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!");
}
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();
}
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();
}
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]");
}
}
Aggregations