use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class GATJob method prepareJob.
private JobDescription prepareJob() throws Exception {
// Get the information related to the job
logger.debug("Preparing GAT Job " + this.jobId);
TaskDescription taskParams = this.taskParams;
String targetPath = getResourceNode().getInstallDir();
String targetHost = getResourceNode().getHost();
String targetUser = getResourceNode().getUser();
if (userNeeded && !targetUser.isEmpty()) {
targetUser += "@";
} else {
targetUser = "";
}
SoftwareDescription sd = new SoftwareDescription();
sd.setExecutable(targetPath + WORKER_SCRIPT_PATH + WORKER_SCRIPT_NAME);
ArrayList<String> lArgs = new ArrayList<String>();
// Common arguments: language working_dir lib_path num_obsolete [obs1... obsN] tracing [event_type task_id
// slot_id]
lArgs.add(LANG);
lArgs.add(getResourceNode().getWorkingDir());
lArgs.add(getResourceNode().getLibPath());
LogicalData[] obsoleteFiles = getResource().pollObsoletes();
if (obsoleteFiles != null) {
lArgs.add("" + obsoleteFiles.length);
for (LogicalData ld : obsoleteFiles) {
String renaming = ld.getName();
lArgs.add(renaming);
}
} else {
lArgs.add("0");
}
// Check sandbox working dir
boolean isSpecific = false;
String sandboxDir = null;
AbstractMethodImplementation absImpl = (AbstractMethodImplementation) this.impl;
switch(absImpl.getMethodType()) {
case BINARY:
BinaryImplementation binaryImpl = (BinaryImplementation) absImpl;
sandboxDir = binaryImpl.getWorkingDir();
isSpecific = true;
break;
case MPI:
MPIImplementation mpiImpl = (MPIImplementation) absImpl;
sandboxDir = mpiImpl.getWorkingDir();
isSpecific = true;
break;
case DECAF:
DecafImplementation decafImpl = (DecafImplementation) absImpl;
sandboxDir = decafImpl.getWorkingDir();
isSpecific = true;
break;
case OMPSS:
OmpSsImplementation ompssImpl = (OmpSsImplementation) absImpl;
sandboxDir = ompssImpl.getWorkingDir();
isSpecific = true;
break;
case OPENCL:
OpenCLImplementation openclImpl = (OpenCLImplementation) absImpl;
sandboxDir = openclImpl.getWorkingDir();
isSpecific = true;
break;
case METHOD:
sandboxDir = null;
break;
}
if (sandboxDir == null || sandboxDir.isEmpty() || sandboxDir.equals(Constants.UNASSIGNED)) {
sandboxDir = getResourceNode().getWorkingDir() + File.separator + "sandBox" + File.separator + "job_" + this.jobId;
isSpecific = false;
}
// Processing parameters to get symlinks pairs to create (symlinks) and how to pass parameters in the GAT
// Job(paramArgs)
ArrayList<String> symlinks = new ArrayList<>();
ArrayList<String> paramArgs = new ArrayList<>();
processParameters(sandboxDir, symlinks, paramArgs);
// Adding info to create symlinks between renamed files and original names
lArgs.add(Boolean.toString(isSpecific));
lArgs.add(sandboxDir);
if (symlinks.size() > 0) {
lArgs.add(String.valueOf(symlinks.size()));
lArgs.addAll(symlinks);
} else {
lArgs.add("0");
}
lArgs.add(Boolean.toString(Tracer.isActivated()));
lArgs.add(getHostName());
if (debug) {
logger.debug("hostName " + getHostName());
}
if (Tracer.isActivated()) {
// event type
lArgs.add(String.valueOf(Tracer.getTaskEventsType()));
// task id
lArgs.add(String.valueOf(this.taskParams.getId() + 1));
int slot = Tracer.getNextSlot(targetHost);
// slot id
lArgs.add(String.valueOf(slot));
sd.addAttribute("slot", slot);
}
// Language-dependent arguments: taskSandbox_dir app_dir classpath pythonpath debug storage_conf
// method_impl_type method_impl_params
// numSlaves [slave1,..,slaveN] numCus
// has_target num_params par_type_1 par_1 ... par_type_n par_n
lArgs.add(sandboxDir);
lArgs.add(getResourceNode().getAppDir());
lArgs.add(getClasspath());
lArgs.add(getPythonpath());
lArgs.add(String.valueOf(debug));
lArgs.add(STORAGE_CONF);
lArgs.add(String.valueOf(absImpl.getMethodType()));
switch(absImpl.getMethodType()) {
case METHOD:
MethodImplementation methodImpl = (MethodImplementation) absImpl;
lArgs.add(methodImpl.getDeclaringClass());
String methodName = methodImpl.getAlternativeMethodName();
if (methodName == null || methodName.isEmpty()) {
methodName = taskParams.getName();
}
lArgs.add(methodName);
break;
case MPI:
MPIImplementation mpiImpl = (MPIImplementation) absImpl;
lArgs.add(mpiImpl.getMpiRunner());
lArgs.add(mpiImpl.getBinary());
break;
case DECAF:
DecafImplementation decafImpl = (DecafImplementation) absImpl;
lArgs.add(targetPath + DecafImplementation.SCRIPT_PATH);
String dfScript = decafImpl.getDfScript();
if (!dfScript.startsWith(File.separator)) {
String appPath = getResourceNode().getAppDir();
dfScript = appPath + File.separator + dfScript;
}
lArgs.add(dfScript);
String dfExecutor = decafImpl.getDfExecutor();
if (dfExecutor == null || dfExecutor.isEmpty() || dfExecutor.equals(Constants.UNASSIGNED)) {
dfExecutor = "executor.sh";
}
if (!dfExecutor.startsWith(File.separator) && !dfExecutor.startsWith("./")) {
dfExecutor = "./" + dfExecutor;
}
lArgs.add(dfExecutor);
String dfLib = decafImpl.getDfLib();
if (dfLib == null || dfLib.isEmpty()) {
dfLib = Constants.UNASSIGNED;
}
lArgs.add(dfLib);
lArgs.add(decafImpl.getMpiRunner());
break;
case OMPSS:
OmpSsImplementation ompssImpl = (OmpSsImplementation) absImpl;
lArgs.add(ompssImpl.getBinary());
break;
case OPENCL:
OpenCLImplementation openclImpl = (OpenCLImplementation) absImpl;
lArgs.add(openclImpl.getKernel());
break;
case BINARY:
BinaryImplementation binaryImpl = (BinaryImplementation) absImpl;
lArgs.add(binaryImpl.getBinary());
break;
}
// Slave nodes and cus description
lArgs.add(String.valueOf(slaveWorkersNodeNames.size()));
lArgs.addAll(slaveWorkersNodeNames);
lArgs.add(String.valueOf(((MethodResourceDescription) this.impl.getRequirements()).getTotalCPUComputingUnits()));
// Add parameter arguments already processed
lArgs.addAll(paramArgs);
// Conversion vector -> array
String[] arguments = new String[lArgs.size()];
arguments = lArgs.toArray(arguments);
try {
sd.setArguments(arguments);
} catch (NullPointerException e) {
StringBuilder sb = new StringBuilder("Null argument parameter of job " + this.jobId + " " + absImpl.getMethodDefinition() + "\n");
int i = 0;
for (Parameter param : taskParams.getParameters()) {
sb.append("Parameter ").append(i).append("\n");
DataType type = param.getType();
sb.append("\t Type: ").append(param.getType()).append("\n");
if (type == DataType.FILE_T || type == DataType.OBJECT_T) {
DependencyParameter dPar = (DependencyParameter) param;
DataAccessId dAccId = dPar.getDataAccessId();
sb.append("\t Target: ").append(dPar.getDataTarget()).append("\n");
if (type == DataType.OBJECT_T) {
if (dAccId instanceof RAccessId) {
sb.append("\t Direction: " + "R").append("\n");
} else {
// for the worker to know it must write the object to disk
sb.append("\t Direction: " + "W").append("\n");
}
}
} else if (type == DataType.STRING_T) {
BasicTypeParameter btParS = (BasicTypeParameter) param;
// Check spaces
String value = btParS.getValue().toString();
int numSubStrings = value.split(" ").length;
sb.append("\t Num Substrings: " + Integer.toString(numSubStrings)).append("\n");
sb.append("\t Value:" + value).append("\n");
} else {
// Basic types
BasicTypeParameter btParB = (BasicTypeParameter) param;
sb.append("\t Value: " + btParB.getValue().toString()).append("\n");
}
i++;
}
logger.error(sb.toString());
listener.jobFailed(this, JobEndStatus.SUBMISSION_FAILED);
}
sd.addAttribute("jobId", jobId);
// JEA Changed to allow execution in MN
sd.addAttribute(SoftwareDescription.WALLTIME_MAX, absImpl.getRequirements().getWallClockLimit());
if (absImpl.getRequirements().getHostQueues().size() > 0) {
sd.addAttribute(SoftwareDescription.JOB_QUEUE, absImpl.getRequirements().getHostQueues().get(0));
}
sd.addAttribute("coreCount", absImpl.getRequirements().getTotalCPUComputingUnits());
sd.addAttribute("gpuCount", absImpl.getRequirements().getTotalGPUComputingUnits());
sd.addAttribute("fpgaCount", absImpl.getRequirements().getTotalFPGAComputingUnits());
sd.addAttribute(SoftwareDescription.MEMORY_MAX, absImpl.getRequirements().getMemorySize());
// sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, "/tmp/");
sd.addAttribute(SoftwareDescription.SANDBOX_ROOT, getResourceNode().getWorkingDir());
sd.addAttribute(SoftwareDescription.SANDBOX_USEROOT, "true");
sd.addAttribute(SoftwareDescription.SANDBOX_DELETE, "false");
/*
* sd.addAttribute(SoftwareDescription.SANDBOX_PRESTAGE_STDIN, "false");
* sd.addAttribute(SoftwareDescription.SANDBOX_POSTSTAGE_STDOUT, "false");
* sd.addAttribute(SoftwareDescription.SANDBOX_POSTSTAGE_STDERR, "false");
*/
if (debug) {
// Set standard output file for job
File outFile = GAT.createFile(context, Protocol.ANY_URI.getSchema() + File.separator + JOBS_DIR + "job" + jobId + "_" + this.getHistory() + ".out");
sd.setStdout(outFile);
}
if (debug || usingGlobus) {
// Set standard error file for job
File errFile = GAT.createFile(context, Protocol.ANY_URI.getSchema() + File.separator + JOBS_DIR + "job" + jobId + "_" + this.getHistory() + ".err");
sd.setStderr(errFile);
}
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(RES_ATTR, Protocol.ANY_URI.getSchema() + targetUser + targetHost);
attributes.put("Jobname", "compss_remote_job_" + jobId);
ResourceDescription rd = new HardwareResourceDescription(attributes);
if (debug) {
logger.debug("Ready to submit job " + jobId + ":");
logger.debug(" * Host: " + targetHost);
logger.debug(" * Executable: " + sd.getExecutable());
StringBuilder sb = new StringBuilder(" - Arguments:");
for (String arg : sd.getArguments()) {
sb.append(" ").append(arg);
}
logger.debug(sb.toString());
}
JobDescription jd = new JobDescription(sd, rd);
// jd.setProcessCount(method.getRequirements().getProcessorCoreCount());
return jd;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class CloudManagerTest method createProvider.
private static CloudProvider createProvider(CloudManager cm) {
String providerName = "Provider" + (int) (Math.random() * 10000);
Map<String, String> properties = new HashMap<>();
CloudProvider cp = null;
try {
cp = cm.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
} catch (Exception e) {
fail("Could not create the Cloud Provider");
}
String imageName = "IMAGE" + (int) (Math.random() * 10000);
CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
cp.addCloudImage(cid);
String typeName = "TYPE" + (int) (Math.random() * 10000);
float type1Memory = (float) Math.random() * 5;
MethodResourceDescription mrd1 = new MethodResourceDescription();
mrd1.setMemorySize(type1Memory);
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
cp.addInstanceType(citd);
return cp;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceManagerTest method testStaticWorkersOperations.
@Test
public void testStaticWorkersOperations() {
// Add Method Resource 1
MethodResourceDescription mrd1 = new MethodResourceDescription();
Float memory1 = 10f + (float) Math.random();
mrd1.setMemorySize(memory1);
MethodConfiguration mc1 = null;
try {
mc1 = (MethodConfiguration) Comm.constructConfiguration(FakeMethodAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String worker1Name = "Worker" + (int) (Math.random() * 10000);
MethodWorker mw1 = createMethodWorker(worker1Name, mrd1, new HashMap<>(), mc1);
ResourceManager.addStaticResource(mw1);
if (ResourceManager.getTotalNumberOfWorkers() != 1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(mw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker1Name) != mw1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(worker1Name).getName().equals(worker1Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (((MethodResourceDescription) ResourceManager.getWorker(worker1Name).getDescription()).getMemorySize() != mrd1.getMemorySize()) {
fail("ResourceManager is not properly adding Method Workers");
}
// Add Method Resource 2
MethodResourceDescription mrd2 = new MethodResourceDescription();
Float memory2 = 10f + (float) Math.random();
mrd2.setMemorySize(memory2);
MethodConfiguration mc2 = null;
try {
mc2 = (MethodConfiguration) Comm.constructConfiguration(FakeMethodAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String worker2Name = "Worker" + (int) (Math.random() * 10000);
MethodWorker mw2 = createMethodWorker(worker2Name, mrd2, new HashMap<>(), mc2);
ResourceManager.addStaticResource(mw2);
if (ResourceManager.getTotalNumberOfWorkers() != 2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(mw2)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker2Name) != mw2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(worker2Name).getName().equals(worker2Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (((MethodResourceDescription) ResourceManager.getWorker(worker2Name).getDescription()).getMemorySize() != mrd2.getMemorySize()) {
fail("ResourceManager is not properly adding Method Workers");
}
// Add Service Resource 1
ServiceResourceDescription srd1 = new ServiceResourceDescription("service1", "namespace1", "port1", 2);
ServiceConfiguration sc1 = null;
try {
sc1 = (ServiceConfiguration) Comm.constructConfiguration(FakeServiceAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String wsdl1 = "WSDL" + (int) (Math.random() * 10000);
ServiceWorker sw1 = createServiceWorker(wsdl1, srd1, sc1);
ResourceManager.addStaticResource(sw1);
if (ResourceManager.getTotalNumberOfWorkers() != 3) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(sw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(wsdl1) != sw1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(wsdl1).getName().equals(wsdl1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!((ServiceResourceDescription) ResourceManager.getWorker(wsdl1).getDescription()).getNamespace().equals(srd1.getNamespace())) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(sw1);
if (ResourceManager.getTotalNumberOfWorkers() != 2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(sw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(wsdl1) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(mw1);
if (ResourceManager.getTotalNumberOfWorkers() != 1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(worker1Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker1Name) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(mw2);
if (ResourceManager.getTotalNumberOfWorkers() != 0) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(worker2Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker2Name) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceManagerTest method addProvider.
private static CloudProvider addProvider() {
String providerName = "Provider" + (int) (Math.random() * 10000);
Map<String, String> properties = new HashMap<>();
CloudProvider cp = null;
try {
cp = ResourceManager.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
} catch (Exception e) {
fail("Could not create the Cloud Provider");
}
String imageName = "IMAGE" + (int) (Math.random() * 10000);
CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
cp.addCloudImage(cid);
String typeName = "TYPE" + (int) (Math.random() * 10000);
float type1Memory = (float) Math.random() * 5;
MethodResourceDescription mrd1 = new MethodResourceDescription();
mrd1.setMemorySize(type1Memory);
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
cp.addInstanceType(citd);
return cp;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceOptimizer method getUnfulfilledConstraints.
// Removes from the list all the Constraints fulfilled by existing
// resources
@SuppressWarnings("unchecked")
private static List<ConstraintsCore>[] getUnfulfilledConstraints() {
int coreCount = CoreManager.getCoreCount();
List<ConstraintsCore>[] unfulfilledConstraints = new LinkedList[coreCount];
int[] maxSimTasks = ResourceManager.getTotalSlots();
for (int coreId = 0; coreId < coreCount; coreId++) {
unfulfilledConstraints[coreId] = new LinkedList<>();
if (maxSimTasks[coreId] == 0) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
if (impl.getTaskType() == TaskType.METHOD) {
MethodResourceDescription requirements = (MethodResourceDescription) impl.getRequirements();
CloudMethodResourceDescription cd = new CloudMethodResourceDescription(requirements);
ConstraintsCore cc = new ConstraintsCore(cd, coreId, unfulfilledConstraints[coreId]);
unfulfilledConstraints[coreId].add(cc);
}
}
}
}
return unfulfilledConstraints;
}
Aggregations