use of storage.StorageException in project compss by bsc-wdc.
the class Comm method init.
/**
* Communications initializer
*/
public static void init() {
appHost = new MasterResource();
try {
if (STORAGE_CONF == null || STORAGE_CONF.equals("") || STORAGE_CONF.equals("null")) {
LOGGER.warn("No storage configuration file passed");
} else {
LOGGER.debug("Initializing Storage with: " + STORAGE_CONF);
StorageItf.init(STORAGE_CONF);
}
} catch (StorageException e) {
LOGGER.fatal("Error loading storage configuration file: " + STORAGE_CONF, e);
System.exit(1);
}
loadAdaptorsJars();
/*
* Initializes the Tracer activation value to enable querying Tracer.isActivated()
*/
if (System.getProperty(COMPSsConstants.TRACING) != null && Integer.parseInt(System.getProperty(COMPSsConstants.TRACING)) > 0) {
LOGGER.debug("Tracing is activated");
int tracing_level = Integer.parseInt(System.getProperty(COMPSsConstants.TRACING));
Tracer.init(tracing_level);
Tracer.emitEvent(Tracer.Event.STATIC_IT.getId(), Tracer.Event.STATIC_IT.getType());
}
}
use of storage.StorageException in project compss by bsc-wdc.
the class NIOWorkerNode method newReplica.
private void newReplica(StorageCopy sc) {
String targetHostname = this.getName();
LogicalData srcLD = sc.getSourceData();
LogicalData targetLD = sc.getTargetData();
LOGGER.debug("Ask for new Replica of " + srcLD.getName() + " to " + targetHostname);
// Get the PSCO to replicate
String pscoId = srcLD.getId();
// Get the current locations
List<String> currentLocations = new LinkedList<>();
try {
currentLocations = StorageItf.getLocations(pscoId);
} catch (StorageException se) {
// Cannot obtain current locations from back-end
sc.end(OpEndState.OP_FAILED, se);
return;
}
if (!currentLocations.contains(targetHostname)) {
// Perform replica
LOGGER.debug("Performing new replica for PSCO " + pscoId);
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.Event.STORAGE_NEWREPLICA.getId(), NIOTracer.Event.STORAGE_NEWREPLICA.getType());
}
try {
// TODO: WARN New replica is NOT necessary because we can't prefetch data
// StorageItf.newReplica(pscoId, targetHostname);
} finally {
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.EVENT_END, NIOTracer.Event.STORAGE_NEWREPLICA.getType());
}
}
} else {
LOGGER.debug("PSCO " + pscoId + " already present. Skip replica.");
}
// Update information
sc.setFinalTarget(pscoId);
if (targetLD != null) {
targetLD.setId(pscoId);
}
// Notify successful end
sc.end(OpEndState.OP_OK);
}
use of storage.StorageException 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();
}
}
use of storage.StorageException in project compss by bsc-wdc.
the class NIOWorker method shutdown.
// Shutdown the worker, at this point there are no active transfers
@Override
public void shutdown(Connection closingConnection) {
WORKER_LOGGER.debug("Entering shutdown method on worker");
// Stop the Data Manager
dataManager.stop();
// Finish the main thread
if (closingConnection != null) {
closingConnection.sendCommand(new CommandShutdownACK());
closingConnection.finishConnection();
}
TM.shutdown(closingConnection);
// End storage
String storageConf = System.getProperty(COMPSsConstants.STORAGE_CONF);
if (storageConf != null && !storageConf.equals("") && !storageConf.equals("null")) {
try {
StorageItf.finish();
} catch (StorageException e) {
WORKER_LOGGER.error("Error releasing storage library: " + e.getMessage(), e);
}
}
// Remove workingDir
if (removeWD) {
WORKER_LOGGER.debug("Erasing Worker Sandbox WorkingDir: " + this.workingDir);
try {
removeFolder(this.workingDir);
} catch (IOException ioe) {
WORKER_LOGGER.error("Exception", ioe);
}
}
WORKER_LOGGER.debug("Finish shutdown method on worker");
}
use of storage.StorageException in project compss by bsc-wdc.
the class Invoker method processParameter.
private void processParameter(NIOParam np, int i) throws JobExecutionException {
// We need to use wrapper classes for basic types, reflection will unwrap automatically
this.streams[i] = np.getStream();
this.prefixes[i] = np.getPrefix();
switch(np.getType()) {
case BOOLEAN_T:
this.types[i] = boolean.class;
this.values[i] = np.getValue();
break;
case CHAR_T:
this.types[i] = char.class;
this.values[i] = np.getValue();
break;
case BYTE_T:
this.types[i] = byte.class;
this.values[i] = np.getValue();
break;
case SHORT_T:
this.types[i] = short.class;
this.values[i] = np.getValue();
break;
case INT_T:
this.types[i] = int.class;
this.values[i] = np.getValue();
break;
case LONG_T:
this.types[i] = long.class;
this.values[i] = np.getValue();
break;
case FLOAT_T:
this.types[i] = float.class;
this.values[i] = np.getValue();
break;
case DOUBLE_T:
this.types[i] = double.class;
this.values[i] = np.getValue();
break;
case STRING_T:
this.types[i] = String.class;
this.values[i] = np.getValue();
break;
case FILE_T:
this.types[i] = String.class;
this.values[i] = np.getOriginalName();
this.writeFinalValue[i] = np.isWriteFinalValue();
break;
case OBJECT_T:
this.renamings[i] = np.getValue().toString();
this.writeFinalValue[i] = np.isWriteFinalValue();
// Get object
Object obj;
try {
obj = this.nw.getObject(this.renamings[i]);
} catch (SerializedObjectException soe) {
throw new JobExecutionException(ERROR_SERIALIZED_OBJ, soe);
}
// Check if object is null
if (obj == null) {
// This happens when 2 tasks have an INOUT PSCO that is persisted within the 1st task
try {
obj = this.nw.getPersistentObject(renamings[i]);
} catch (StorageException se) {
throw new JobExecutionException(ERROR_SERIALIZED_OBJ, se);
}
}
// Check if object is still null
if (obj == null) {
StringBuilder sb = new StringBuilder();
if (this.hasTarget && i == this.numParams - 1) {
sb.append("Target object");
} else {
sb.append("Object parameter ").append(i);
}
sb.append(" with renaming ").append(this.renamings[i]);
sb.append(" in MethodDefinition ").append(this.impl.getMethodDefinition());
sb.append(" is null!").append("\n");
throw new JobExecutionException(sb.toString());
}
// Store information as target or as normal parameter
if (this.hasTarget && i == this.numParams - 1) {
// Last parameter is the target object
this.target.setValue(obj);
} else {
// Any other parameter
this.types[i] = obj.getClass();
this.values[i] = obj;
}
break;
case PSCO_T:
this.renamings[i] = np.getValue().toString();
this.writeFinalValue[i] = np.isWriteFinalValue();
// Get ID
String id = this.renamings[i];
// Get Object
try {
obj = this.nw.getPersistentObject(id);
} catch (StorageException e) {
throw new JobExecutionException(ERROR_PERSISTENT_OBJ + " with id " + id, e);
}
// Check if object is null
if (obj == null) {
StringBuilder sb = new StringBuilder();
if (this.hasTarget && i == this.numParams - 1) {
sb.append("Target PSCO");
} else {
sb.append("PSCO parameter ").append(i);
}
sb.append(" with renaming ").append(this.renamings[i]);
sb.append(" in MethodDefinition ").append(this.impl.getMethodDefinition());
sb.append(" is null!").append("\n");
throw new JobExecutionException(sb.toString());
}
// Store information as target or as normal parameter
if (this.hasTarget && i == this.numParams - 1) {
// Last parameter is the target object
this.target.setValue(obj);
} else {
// Any other parameter
this.types[i] = obj.getClass();
this.values[i] = obj;
}
break;
case EXTERNAL_OBJECT_T:
this.types[i] = String.class;
this.values[i] = np.getValue();
this.writeFinalValue[i] = np.isWriteFinalValue();
break;
}
this.isFile[i] = (np.getType().equals(DataType.FILE_T));
this.canBePSCO[i] = (np.getType().equals(DataType.OBJECT_T)) || (np.getType().equals(DataType.PSCO_T));
}
Aggregations