use of es.bsc.compss.nio.NIOParam in project compss by bsc-wdc.
the class Executor method checkJobFiles.
private void checkJobFiles(NIOTask nt) throws JobExecutionException {
// Check if all the output files have been actually created (in case user has forgotten)
// No need to distinguish between IN or OUT files, because IN files will exist, and
// if there's one or more missing, they will be necessarily out.
boolean allOutFilesCreated = true;
for (NIOParam param : nt.getParams()) {
if (param.getType().equals(DataType.FILE_T)) {
String filepath = (String) param.getValue();
File f = new File(filepath);
// If using C binding we ignore potential errors
if (!f.exists() && (Lang.valueOf(nt.getLang().toUpperCase()) != Lang.C)) {
StringBuilder errMsg = new StringBuilder();
errMsg.append("ERROR: File with path '").append(filepath);
errMsg.append("' not generated by task with Method Definition ").append(nt.getMethodImplementation().getMethodDefinition());
System.out.println(errMsg.toString());
System.err.println(errMsg.toString());
allOutFilesCreated = false;
}
}
}
if (!allOutFilesCreated) {
throw new JobExecutionException(ERROR_OUT_FILES + nt.getMethodImplementation().getMethodDefinition());
}
}
use of es.bsc.compss.nio.NIOParam in project compss by bsc-wdc.
the class Executor method bindOriginalFilenamesToRenames.
/**
* Create symbolic links from files with the original name in task sandbox to the renamed file
*
* @param nt
* task description
* @param sandbox
* created sandbox
* @throws IOException
* @throws Exception
* returns exception is a problem occurs during creation
*/
private void bindOriginalFilenamesToRenames(NIOTask nt, File sandbox) throws IOException {
for (NIOParam param : nt.getParams()) {
if (param.getType().equals(DataType.FILE_T)) {
String renamedFilePath = (String) param.getValue();
File renamedFile = new File(renamedFilePath);
if (renamedFile.getName().equals(param.getOriginalName())) {
param.setOriginalName(renamedFilePath);
} else {
String newOrigFilePath = sandbox.getAbsolutePath() + File.separator + param.getOriginalName();
LOGGER.debug("Setting Original Name to " + newOrigFilePath);
param.setOriginalName(newOrigFilePath);
File newOrigFile = new File(newOrigFilePath);
if (renamedFile.exists()) {
// IN or INOUT File creating a symbolic link
if (!newOrigFile.exists()) {
LOGGER.debug("Creating symlink " + newOrigFile.toPath() + " pointing to " + renamedFile.toPath());
Files.createSymbolicLink(newOrigFile.toPath(), renamedFile.toPath());
} else {
if (Files.isSymbolicLink(newOrigFile.toPath())) {
Path oldRenamed = Files.readSymbolicLink(newOrigFile.toPath());
LOGGER.debug("Checking if " + renamedFile.getName() + " is equal to " + oldRenamed.getFileName().toString());
if (isMajorVersion(renamedFile.getName(), oldRenamed.getFileName().toString())) {
Files.delete(newOrigFile.toPath());
Files.createSymbolicLink(newOrigFile.toPath(), renamedFile.toPath());
}
}
}
}
}
}
}
}
use of es.bsc.compss.nio.NIOParam in project compss by bsc-wdc.
the class ExternalExecutor method addArguments.
private static void addArguments(ArrayList<String> lArgs, NIOTask nt, NIOWorker nw) throws JobExecutionException, SerializedObjectException {
lArgs.add(Boolean.toString(NIOTracer.isActivated()));
lArgs.add(Integer.toString(nt.getTaskId()));
lArgs.add(Boolean.toString(nt.isWorkerDebug()));
lArgs.add(STORAGE_CONF);
// The implementation to execute externally can only be METHOD but we double check it
if (nt.getMethodType() != MethodType.METHOD) {
throw new JobExecutionException(ERROR_UNSUPPORTED_JOB_TYPE);
}
// Add method classname and methodname
MethodImplementation impl = (MethodImplementation) nt.getMethodImplementation();
lArgs.add(String.valueOf(impl.getMethodType()));
lArgs.add(impl.getDeclaringClass());
lArgs.add(impl.getAlternativeMethodName());
// Slave nodes and cus description
lArgs.add(String.valueOf(nt.getSlaveWorkersNodeNames().size()));
lArgs.addAll(nt.getSlaveWorkersNodeNames());
lArgs.add(String.valueOf(nt.getResourceDescription().getTotalCPUComputingUnits()));
// Add target
lArgs.add(Boolean.toString(nt.hasTarget()));
// Add return type
if (nt.hasReturn()) {
DataType returnType = nt.getParams().getLast().getType();
lArgs.add(Integer.toString(returnType.ordinal()));
} else {
lArgs.add("null");
}
// Add parameters
lArgs.add(Integer.toString(nt.getNumParams()));
for (NIOParam np : nt.getParams()) {
DataType type = np.getType();
lArgs.add(Integer.toString(type.ordinal()));
lArgs.add(Integer.toString(np.getStream().ordinal()));
lArgs.add(np.getPrefix());
switch(type) {
case FILE_T:
// Passing originalName link instead of renamed file
String originalFile = "";
if (np.getData() != null) {
originalFile = np.getData().getName();
}
String destFile = new File(np.getValue().toString()).getName();
if (!isRuntimeRenamed(destFile)) {
// Treat corner case: Destfile is original name. Parameter is INPUT with shared disk, so
// destfile should be the same as the input.
destFile = originalFile;
}
lArgs.add(originalFile + ":" + destFile + ":" + np.isPreserveSourceData() + ":" + np.isWriteFinalValue() + ":" + np.getOriginalName());
break;
case OBJECT_T:
case PSCO_T:
case EXTERNAL_OBJECT_T:
lArgs.add(np.getValue().toString());
lArgs.add(np.isWriteFinalValue() ? "W" : "R");
break;
case STRING_T:
String value = np.getValue().toString();
String[] vals = value.split(" ");
int numSubStrings = vals.length;
lArgs.add(Integer.toString(numSubStrings));
for (String v : vals) {
lArgs.add(v);
}
break;
default:
lArgs.add(np.getValue().toString());
}
}
}
Aggregations