use of storage.StorageException in project compss by bsc-wdc.
the class JavaInvoker method externalExecution.
private Object externalExecution() throws JobExecutionException {
// Invoke the requested method from the external platform
// WARN: ExternalExecution is only supported for methods with PSCO as target object
int n = method.getParameterAnnotations().length;
ClassPool pool = ClassPool.getDefault();
Class<?>[] cParams = method.getParameterTypes();
CtClass[] ctParams = new CtClass[n];
for (int i = 0; i < n; i++) {
try {
ctParams[i] = pool.getCtClass(((Class<?>) cParams[i]).getName());
} catch (NotFoundException e) {
throw new JobExecutionException(ERROR_CLASS_NOT_FOUND + " " + cParams[i].getName(), e);
}
}
String descriptor;
try {
descriptor = method.getName() + Descriptor.ofMethod(pool.getCtClass(method.getReturnType().getName()), ctParams);
} catch (NotFoundException e) {
throw new JobExecutionException(ERROR_CLASS_NOT_FOUND + " " + method.getReturnType().getName(), e);
}
// Check and retrieve target PSCO Id
String id = null;
try {
id = ((StubItf) target.getValue()).getID();
} catch (Exception e) {
throw new JobExecutionException(ERROR_EXTERNAL_NO_PSCO, e);
}
if (id == null) {
throw new JobExecutionException(ERROR_EXTERNAL_NO_PSCO);
}
// Call Storage executeTask
if (LOGGER.isDebugEnabled()) {
LOGGER.info("External ExecuteTask " + method.getName() + " with target PSCO Id " + id + " in " + nw.getHostName());
} else {
LOGGER.info("External ExecuteTask " + method.getName());
}
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.Event.STORAGE_EXECUTETASK.getId(), NIOTracer.Event.STORAGE_EXECUTETASK.getType());
}
PSCOCallbackHandler callback = new PSCOCallbackHandler();
try {
String call_result = StorageItf.executeTask(id, descriptor, values, nw.getHostName(), callback);
LOGGER.debug(call_result);
// Wait for execution
callback.waitForCompletion();
} catch (StorageException e) {
throw new JobExecutionException(ERROR_STORAGE_CALL, e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new JobExecutionException(ERROR_CALLBACK_INTERRUPTED, e);
} finally {
if (NIOTracer.isActivated()) {
NIOTracer.emitEvent(NIOTracer.EVENT_END, NIOTracer.Event.STORAGE_EXECUTETASK.getType());
}
}
// Process the return status
CallbackEvent.EventType callStatus = callback.getStatus();
if (!callStatus.equals(CallbackEvent.EventType.SUCCESS)) {
throw new JobExecutionException(ERROR_EXTERNAL_EXECUTION);
}
// Process return value
Object retValue = null;
if (method.getReturnType().getName().compareTo(void.class.getName()) != 0) {
try {
retValue = callback.getResult();
} catch (StorageException e) {
LOGGER.warn(WARN_RET_VALUE_EXCEPTION, e);
retValue = null;
}
}
return retValue;
}
use of storage.StorageException in project compss by bsc-wdc.
the class GATWorker method parseArguments.
/**
* Parses the all the arguments except the application parameters
*
* @param args
* args for the execution: arg[0]: boolean enable debug arg[1]: String with Storage configuration arg[2]:
* Number of nodes for multi-node tasks (N) arg[3,N]: N strings with multi-node hostnames arg[3+N+1]:
* Number of computing units arg[3+N+2]: Method type (M=3+N+2) arg[M,M - M+1]: Method dependant
* parameters Others
*/
private static void parseArguments(String[] args) {
// Default flags
GATWorker.taskSandboxWorkingDir = new File(args[0]);
GATWorker.debug = Boolean.valueOf(args[1]);
GATWorker.storageConf = args[2];
int argPosition = DEFAULT_FLAGS_SIZE;
GATWorker.methodType = MethodType.valueOf(args[argPosition++]);
GATWorker.methodDefinition = null;
switch(GATWorker.methodType) {
case METHOD:
// classname, methodname
GATWorker.methodDefinition = new String[] { args[argPosition], args[argPosition + 1] };
argPosition += 2;
break;
case MPI:
// mpiRunner, mpiBinary
GATWorker.methodDefinition = new String[] { args[argPosition], args[argPosition + 1] };
argPosition += 2;
break;
case DECAF:
// mpiRunner, mpiBinary
GATWorker.methodDefinition = new String[] { args[argPosition], args[argPosition + 1], args[argPosition + 2], args[argPosition + 3], args[argPosition + 4] };
argPosition += 5;
break;
case OMPSS:
// binary
GATWorker.methodDefinition = new String[] { args[argPosition] };
argPosition += 1;
break;
case OPENCL:
// kernel
GATWorker.methodDefinition = new String[] { args[argPosition] };
argPosition += 1;
break;
case BINARY:
// binary
GATWorker.methodDefinition = new String[] { args[argPosition] };
argPosition += 1;
break;
}
// Execution information for multi-node tasks
GATWorker.numNodes = Integer.parseInt(args[argPosition++]);
GATWorker.hostnames = new ArrayList<>();
for (int i = 0; i < GATWorker.numNodes; ++i) {
GATWorker.hostnames.add(args[argPosition++]);
}
GATWorker.cus = Integer.parseInt(args[argPosition++]);
// Get if has target or not
GATWorker.hasTarget = Boolean.parseBoolean(args[argPosition++]);
// Get return type if specified
String returnType = args[argPosition++];
if (returnType == null || returnType.equals("null") || returnType.isEmpty()) {
GATWorker.hasReturn = false;
} else {
GATWorker.hasReturn = true;
}
// Get application number of parameters
GATWorker.numParams = Integer.parseInt(args[argPosition++]);
GATWorker.initialAppParamsPosition = argPosition;
// Check received arguments
if (args.length < 2 * GATWorker.numParams + GATWorker.initialAppParamsPosition) {
ErrorManager.error(ERROR_APP_PARAMETERS);
}
// Check if we must enable the storage
System.setProperty(COMPSsConstants.STORAGE_CONF, GATWorker.storageConf);
if (GATWorker.storageConf != null && !GATWorker.storageConf.equals("") && !GATWorker.storageConf.equals("null")) {
try {
StorageItf.init(GATWorker.storageConf);
} catch (StorageException e) {
ErrorManager.fatal(ERROR_STORAGE_CONF + GATWorker.storageConf, e);
}
}
}
use of storage.StorageException in project compss by bsc-wdc.
the class PersistentLocation method getURIs.
@Override
public List<MultiURI> getURIs() {
// Retrieve locations from Back-end
List<String> locations = null;
try {
locations = StorageItf.getLocations(this.id);
} catch (StorageException e) {
ErrorManager.error("ERROR: Cannot retrieve locations of " + this.id + " from Storage Back-end");
}
if (locations == null) {
ErrorManager.error("ERROR: Cannot retrieve locations of " + this.id + " from Storage Back-end");
}
// Retrieve URIs from hosts
LinkedList<MultiURI> uris = new LinkedList<>();
for (String hostName : locations) {
Resource host = Resource.getResource(hostName);
if (host != null) {
uris.add(new MultiURI(Protocol.PERSISTENT_URI, host, this.id));
} else {
LOGGER.warn("Storage Back-End returned non-registered host " + hostName + ". Skipping URI in host");
}
}
return uris;
}
use of storage.StorageException in project compss by bsc-wdc.
the class LogicalData method loadFromStorage.
/**
* Loads the value of the LogicalData from a file
*
* @throws CannotLoadException
* @throws IOException
* @throws ClassNotFoundException
* @throws StorageException
* @throws UnstartedNodeException
*
* @throws Exception
*/
public synchronized void loadFromStorage() throws CannotLoadException {
if (value != null) {
// Value is already loaded in memory
return;
}
for (DataLocation loc : this.locations) {
switch(loc.getType()) {
case PRIVATE:
case SHARED:
// Get URI and deserialize object if possible
MultiURI u = loc.getURIInHost(Comm.getAppHost());
if (u == null) {
continue;
}
String path = u.getPath();
if (path.startsWith(File.separator)) {
try {
this.value = Serializer.deserialize(path);
} catch (ClassNotFoundException | IOException e) {
// Check next location since deserialization was invalid
this.value = null;
continue;
}
String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
SimpleURI uri = new SimpleURI(targetPath);
try {
DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
addLocation(tgtLoc);
} catch (IOException e) {
// Check next location since location was invalid
this.value = null;
continue;
}
}
return;
case PERSISTENT:
PersistentLocation pLoc = (PersistentLocation) loc;
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.Event.STORAGE_GETBYID.getId(), Tracer.Event.STORAGE_GETBYID.getType());
}
try {
this.value = StorageItf.getByID(pLoc.getId());
this.id = pLoc.getId();
} catch (StorageException se) {
// Check next location since cannot retrieve the object from the storage Back-end
continue;
} finally {
if (Tracer.isActivated()) {
Tracer.emitEvent(Tracer.EVENT_END, Tracer.Event.STORAGE_GETBYID.getType());
}
}
String targetPath = Protocol.OBJECT_URI.getSchema() + this.name;
SimpleURI uri = new SimpleURI(targetPath);
try {
DataLocation tgtLoc = DataLocation.createLocation(Comm.getAppHost(), uri);
addLocation(tgtLoc);
} catch (IOException e) {
// Check next location since location was invalid
this.value = null;
continue;
}
return;
}
}
// Any location has been able to load the value
throw new CannotLoadException("Object has not any valid location available in the master");
}
use of storage.StorageException in project compss by bsc-wdc.
the class PersistentLocation method getHosts.
@Override
public List<Resource> getHosts() {
LOGGER.debug("Get PSCO locations for " + this.id);
// Retrieve locations from Back-end
List<String> locations = null;
try {
locations = StorageItf.getLocations(this.id);
} catch (StorageException e) {
ErrorManager.error("ERROR: Cannot retrieve locations of " + this.id + " from Storage Back-end");
}
if (locations == null) {
ErrorManager.error("ERROR: Cannot retrieve locations of " + this.id + " from Storage Back-end");
}
// Get hosts
List<Resource> hosts = new LinkedList<>();
for (String hostName : locations) {
Resource host = Resource.getResource(hostName);
if (host != null) {
hosts.add(host);
} else {
LOGGER.warn("Storage Back-End returned non-registered host " + hostName);
}
}
return hosts;
}
Aggregations