use of es.bsc.compss.types.parameter.ExternalObjectParameter in project compss by bsc-wdc.
the class TaskAnalyser method processTask.
/**
* Process the dependencies of a new task @currentTask
*
* @param currentTask
*/
public void processTask(Task currentTask) {
TaskDescription params = currentTask.getTaskDescription();
LOGGER.info("New " + (params.getType() == TaskType.METHOD ? "method" : "service") + " task(" + params.getName() + "), ID = " + currentTask.getId());
if (drawGraph) {
addNewTask(currentTask);
}
// Update task count
Integer methodId = params.getId();
Integer actualCount = currentTaskCount.get(methodId);
if (actualCount == null) {
actualCount = 0;
}
currentTaskCount.put(methodId, actualCount + 1);
// Update app id task count
Long appId = currentTask.getAppId();
Integer taskCount = appIdToTaskCount.get(appId);
if (taskCount == null) {
taskCount = 0;
}
taskCount++;
appIdToTaskCount.put(appId, taskCount);
Integer totalTaskCount = appIdToTotalTaskCount.get(appId);
if (totalTaskCount == null) {
totalTaskCount = 0;
}
totalTaskCount++;
appIdToTotalTaskCount.put(appId, totalTaskCount);
// Check scheduling enforcing data
int constrainingParam = -1;
if (params.getType() == TaskType.SERVICE && params.hasTargetObject()) {
if (params.hasReturnValue()) {
constrainingParam = params.getParameters().length - 2;
} else {
constrainingParam = params.getParameters().length - 1;
}
}
Parameter[] parameters = params.getParameters();
for (int paramIdx = 0; paramIdx < parameters.length; paramIdx++) {
Parameter p = parameters[paramIdx];
if (DEBUG) {
LOGGER.debug("* Parameter : " + p);
}
// Conversion: direction -> access mode
AccessMode am = AccessMode.R;
switch(p.getDirection()) {
case IN:
am = AccessMode.R;
break;
case OUT:
am = AccessMode.W;
break;
case INOUT:
am = AccessMode.RW;
break;
}
// Inform the Data Manager about the new accesses
DataAccessId daId;
switch(p.getType()) {
case FILE_T:
FileParameter fp = (FileParameter) p;
daId = DIP.registerFileAccess(am, fp.getLocation());
break;
case PSCO_T:
ObjectParameter pscop = (ObjectParameter) p;
// Check if its PSCO class and persisted to infer its type
pscop.setType(DataType.PSCO_T);
daId = DIP.registerObjectAccess(am, pscop.getValue(), pscop.getCode());
break;
case EXTERNAL_OBJECT_T:
ExternalObjectParameter externalPSCOparam = (ExternalObjectParameter) p;
// Check if its PSCO class and persisted to infer its type
externalPSCOparam.setType(DataType.EXTERNAL_OBJECT_T);
daId = DIP.registerExternalObjectAccess(am, externalPSCOparam.getId(), externalPSCOparam.getCode());
break;
case OBJECT_T:
ObjectParameter op = (ObjectParameter) p;
// Check if its PSCO class and persisted to infer its type
if (op.getValue() instanceof StubItf && ((StubItf) op.getValue()).getID() != null) {
op.setType(DataType.PSCO_T);
}
daId = DIP.registerObjectAccess(am, op.getValue(), op.getCode());
break;
default:
/*
* Basic types (including String). The only possible access mode is R (already checked by the API)
*/
continue;
}
// Add dependencies to the graph and register output values for future dependencies
DependencyParameter dp = (DependencyParameter) p;
dp.setDataAccessId(daId);
switch(am) {
case R:
checkDependencyForRead(currentTask, dp);
if (paramIdx == constrainingParam) {
DataAccessId.RAccessId raId = (DataAccessId.RAccessId) dp.getDataAccessId();
DataInstanceId dependingDataId = raId.getReadDataInstance();
if (dependingDataId != null) {
if (dependingDataId.getVersionId() > 1) {
currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
}
}
}
break;
case RW:
checkDependencyForRead(currentTask, dp);
if (paramIdx == constrainingParam) {
DataAccessId.RWAccessId raId = (DataAccessId.RWAccessId) dp.getDataAccessId();
DataInstanceId dependingDataId = raId.getReadDataInstance();
if (dependingDataId != null) {
if (dependingDataId.getVersionId() > 1) {
currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
}
}
}
registerOutputValues(currentTask, dp);
break;
case W:
registerOutputValues(currentTask, dp);
break;
}
}
}
use of es.bsc.compss.types.parameter.ExternalObjectParameter in project compss by bsc-wdc.
the class COMPSsRuntimeImpl method processParameters.
/*
* ************************************************************************************************************
* PRIVATE HELPER METHODS
* ********************************************************************************************************
*/
private Parameter[] processParameters(int parameterCount, Object[] parameters) {
Parameter[] pars = new Parameter[parameterCount];
// Parameter parsing needed, object is not serializable
int i = 0;
for (int npar = 0; npar < parameterCount; ++npar) {
DataType type = (DataType) parameters[i + 1];
Direction direction = (Direction) parameters[i + 2];
Stream stream = (Stream) parameters[i + 3];
String prefix = (String) parameters[i + 4];
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(" Parameter " + (npar + 1) + " has type " + type.name());
}
switch(type) {
case FILE_T:
try {
String fileName = (String) parameters[i];
String originalName = new File(fileName).getName();
DataLocation location = createLocation((String) parameters[i]);
pars[npar] = new FileParameter(direction, stream, prefix, location, originalName);
} catch (Exception e) {
LOGGER.error(ERROR_FILE_NAME, e);
ErrorManager.fatal(ERROR_FILE_NAME, e);
}
break;
case PSCO_T:
case OBJECT_T:
pars[npar] = new ObjectParameter(direction, stream, prefix, parameters[i], oReg.newObjectParameter(parameters[i]));
break;
case EXTERNAL_OBJECT_T:
String id = (String) parameters[i];
pars[npar] = new ExternalObjectParameter(direction, stream, prefix, id, externalObjectHashcode(id));
break;
default:
/*
* Basic types (including String). The only possible direction is IN, warn otherwise
*/
if (direction != Direction.IN) {
LOGGER.warn(WARN_WRONG_DIRECTION + "Parameter " + npar + " is a basic type, therefore it must have IN direction");
}
pars[npar] = new BasicTypeParameter(type, Direction.IN, stream, prefix, parameters[i]);
break;
}
i += 5;
}
return pars;
}
Aggregations