use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class NIOJob method prepareJob.
public NIOTask prepareJob() {
AbstractMethodImplementation absMethodImpl = (AbstractMethodImplementation) this.impl;
// This is a workarround for Python
if (absMethodImpl.getMethodType().equals(MethodType.METHOD)) {
MethodImplementation mImpl = (MethodImplementation) absMethodImpl;
String methodName = mImpl.getAlternativeMethodName();
if (methodName == null || methodName.isEmpty()) {
mImpl.setAlternativeMethodName(taskParams.getName());
}
}
boolean hasTarget = taskParams.hasTargetObject();
boolean hasReturn = taskParams.hasReturnValue();
LinkedList<NIOParam> params = addParams();
MethodResourceDescription reqs = absMethodImpl.getRequirements();
int numParams = params.size();
if (taskParams.hasReturnValue()) {
numParams--;
}
// Create NIOTask
NIOTask nt = new NIOTask(LANG, debug, absMethodImpl, hasTarget, hasReturn, params, numParams, reqs, this.slaveWorkersNodeNames, this.taskId, this.taskParams.getId(), this.jobId, this.history, this.transferId);
return nt;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class CloudTypeManager method newCoreElementsDetected.
public void newCoreElementsDetected(List<Integer> newCores) {
int coreCount = CoreManager.getCoreCount();
for (CloudInstanceTypeDescription type : types.values()) {
int[][] slotsI = new int[coreCount][];
// Copy actual values
int[] slotsC = Arrays.copyOf(type.getSlotsCore(), coreCount);
for (int i = 0; i < type.getSlotsImplLength(); ++i) {
int[] slotsImpl = type.getSpecificSlotsImpl(i);
slotsI[i] = slotsImpl.clone();
}
// Get new values
for (int coreId : newCores) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
int implsSize = impls.size();
slotsI[coreId] = new int[implsSize];
for (int implId = 0; implId < implsSize; ++implId) {
Implementation impl = impls.get(implId);
if (impl.getTaskType() == TaskType.METHOD) {
MethodResourceDescription rd = (MethodResourceDescription) impl.getRequirements();
Integer into = type.getResourceDescription().canHostSimultaneously(rd);
slotsC[coreId] = Math.max(slotsC[coreId], into);
slotsI[coreId][implId] = into;
}
}
}
type.setSlotsCore(slotsC);
type.setSlotsImpl(slotsI);
}
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceLoader method createInstance.
private static CloudInstanceTypeDescription createInstance(es.bsc.compss.types.resources.jaxb.InstanceTypeType instance) {
// Add the name
// String name = instance.getName();
String type = instance.getName();
MethodResourceDescription mrd = new MethodResourceDescription();
List<es.bsc.compss.types.resources.jaxb.ProcessorType> processors = resources.getProcessors(instance);
if (processors != null) {
for (es.bsc.compss.types.resources.jaxb.ProcessorType p : processors) {
String procName = p.getName();
int computingUnits = resources.getProcessorComputingUnits(p);
String architecture = resources.getProcessorArchitecture(p);
float speed = resources.getProcessorSpeed(p);
String procType = resources.getProcessorType(p);
float internalMemory = resources.getProcessorMemorySize(p);
ProcessorPropertyType procProp = resources.getProcessorProperty(p);
String propKey = (procProp != null) ? procProp.getKey() : "";
String propValue = (procProp != null) ? procProp.getValue() : "";
mrd.addProcessor(procName, computingUnits, architecture, speed, procType, internalMemory, propKey, propValue);
}
}
mrd.setMemorySize(resources.getMemorySize(instance));
mrd.setMemoryType(resources.getMemoryType(instance));
mrd.setStorageSize(resources.getStorageSize(instance));
mrd.setStorageType(resources.getStorageType(instance));
es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(instance);
if (p != null) {
mrd.setPriceTimeUnit(p.getTimeUnit());
mrd.setPricePerUnit(p.getPricePerUnit());
}
return new CloudInstanceTypeDescription(type, mrd);
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceLoader method loadComputeNode.
private static boolean loadComputeNode(ComputeNodeType cn_project, es.bsc.compss.types.resources.jaxb.ComputeNodeType cn_resources) {
// Add the name
String name = cn_project.getName();
/* Add properties given by the resources file **************************************** */
MethodResourceDescription mrd = new MethodResourceDescription();
List<es.bsc.compss.types.resources.jaxb.ProcessorType> processors = resources.getProcessors(cn_resources);
if (processors != null) {
for (es.bsc.compss.types.resources.jaxb.ProcessorType p : processors) {
String procName = p.getName();
int computingUnits = resources.getProcessorComputingUnits(p);
String architecture = resources.getProcessorArchitecture(p);
float speed = resources.getProcessorSpeed(p);
String type = resources.getProcessorType(p);
float internalMemory = resources.getProcessorMemorySize(p);
ProcessorPropertyType procProp = resources.getProcessorProperty(p);
String propKey = (procProp != null) ? procProp.getKey() : "";
String propValue = (procProp != null) ? procProp.getValue() : "";
mrd.addProcessor(procName, computingUnits, architecture, speed, type, internalMemory, propKey, propValue);
}
}
mrd.setMemorySize(resources.getMemorySize(cn_resources));
mrd.setMemoryType(resources.getMemoryType(cn_resources));
mrd.setStorageSize(resources.getStorageSize(cn_resources));
mrd.setStorageType(resources.getStorageType(cn_resources));
mrd.setOperatingSystemType(resources.getOperatingSystemType(cn_resources));
mrd.setOperatingSystemDistribution(resources.getOperatingSystemDistribution(cn_resources));
mrd.setOperatingSystemVersion(resources.getOperatingSystemVersion(cn_resources));
List<String> apps = resources.getApplications(cn_resources);
if (apps != null) {
for (String appName : apps) {
mrd.addApplication(appName);
}
}
es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(cn_resources);
if (p != null) {
mrd.setPriceTimeUnit(p.getTimeUnit());
mrd.setPricePerUnit(p.getPricePerUnit());
}
// Add Shared Disks (Name, mountpoint)
Map<String, String> sharedDisks = resources.getSharedDisks(cn_resources);
if (sharedDisks != null) {
List<String> declaredSharedDisks = resources.getSharedDisks_names();
for (String diskName : sharedDisks.keySet()) {
if (declaredSharedDisks == null || !declaredSharedDisks.contains(diskName)) {
ErrorManager.warn("SharedDisk " + diskName + " defined in the ComputeNode " + name + " is not defined in the resources.xml. Skipping");
sharedDisks.remove(diskName);
// TODO: Check the disk information (size and type)
}
}
}
// Add the adaptors properties (queue types and adaptor properties)
// TODO Support multiple adaptor properties
String loadedAdaptor = System.getProperty(COMPSsConstants.COMM_ADAPTOR);
List<String> queues_project = project.getAdaptorQueues(cn_project, loadedAdaptor);
List<String> queues_resources = resources.getAdaptorQueues(cn_resources, loadedAdaptor);
if (queues_project == null) {
// Has no tag adaptors on project, get default resources complete
for (String queue : queues_resources) {
mrd.addHostQueue(queue);
}
} else {
// Project defines a subset of queues
for (String queue : queues_resources) {
if (queues_project.contains(queue)) {
mrd.addHostQueue(queue);
}
}
}
Object adaptorProperties_project = project.getAdaptorProperties(cn_project, loadedAdaptor);
Object adaptorProperties_resources = resources.getAdaptorProperties(cn_resources, loadedAdaptor);
MethodConfiguration config = null;
try {
config = (MethodConfiguration) Comm.constructConfiguration(loadedAdaptor, adaptorProperties_project, adaptorProperties_resources);
} catch (ConstructConfigurationException cce) {
ErrorManager.warn("Adaptor " + loadedAdaptor + " configuration constructor failed", cce);
return false;
}
// If we have reached this point the config is SURELY not null
/* Add properties given by the project file **************************************** */
config.setHost(cn_project.getName());
config.setUser(project.getUser(cn_project));
config.setInstallDir(project.getInstallDir(cn_project));
config.setWorkingDir(project.getWorkingDir(cn_project));
int limitOfTasks = project.getLimitOfTasks(cn_project);
if (limitOfTasks >= 0) {
config.setLimitOfTasks(limitOfTasks);
} else {
config.setLimitOfTasks(mrd.getTotalCPUComputingUnits());
}
config.setTotalComputingUnits(mrd.getTotalCPUComputingUnits());
config.setTotalGPUComputingUnits(mrd.getTotalGPUComputingUnits());
config.setTotalFPGAComputingUnits(mrd.getTotalFPGAComputingUnits());
config.setTotalOTHERComputingUnits(mrd.getTotalOTHERComputingUnits());
ApplicationType app = project.getApplication(cn_project);
if (app != null) {
config.setAppDir(app.getAppDir());
config.setLibraryPath(app.getLibraryPath());
config.setClasspath(app.getClasspath());
config.setPythonpath(app.getPythonpath());
}
/* Pass all the information to the ResourceManager to insert it into the Runtime ** */
LOGGER.debug("Adding method worker " + name);
MethodWorker methodWorker = createMethodWorker(name, mrd, sharedDisks, config);
ResourceManager.addStaticResource(methodWorker);
// If we have reached this point the method worker has been correctly created
return true;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceManager method printResourcesState.
/**
* Prints out the resources state
*/
public static void printResourcesState() {
RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
StringBuilder resourceState = new StringBuilder();
resourceState.append("RESOURCES_INFO = [").append("\n");
synchronized (pool) {
for (Worker<? extends WorkerResourceDescription> resource : pool.findAllResources()) {
resourceState.append("\t").append("RESOURCE = [").append("\n");
resourceState.append("\t\t").append("NAME = ").append(resource.getName()).append("\n");
resourceState.append("\t\t").append("TYPE = ").append(resource.getType().toString()).append("\n");
if (resource.getType() == Type.SERVICE) {
resourceState.append("\t\t").append("CPUS = 0\n");
resourceState.append("\t\t").append("MEMORY = 0\n");
} else {
MethodResourceDescription mrd = (MethodResourceDescription) resource.getDescription();
resourceState.append("\t\t").append("CPUS = ").append(mrd.getTotalCPUComputingUnits()).append("\n");
resourceState.append("\t\t").append("MEMORY = ").append(mrd.getMemorySize()).append("\n");
}
int[] coreSlots = resource.getSimultaneousTasks();
resourceState.append("\t\t").append("CAN_RUN = [").append("\n");
for (int i = 0; i < coreSlots.length; i++) {
resourceState.append("\t\t\t").append("CORE = [").append("\n");
resourceState.append("\t\t\t").append("\t").append("COREID = ").append(i).append("\n");
resourceState.append("\t\t\t").append("\t").append("NUM_SLOTS = ").append(coreSlots[i]).append("\n");
resourceState.append("\t\t\t").append("]").append("\n");
}
// End CAN_RUN
resourceState.append("\t\t").append("]").append("\n");
// End RESOURCE
resourceState.append("\t").append("]\n");
}
}
// END RESOURCES_INFO
resourceState.append("]").append("\n");
resourceState.append("CLOUD_INFO = [").append("\n");
if (cloudManager.isUseCloud()) {
resourceState.append("\t").append("CURRENT_CLOUD_VM_COUNT = ").append(cloudManager.getCurrentVMCount()).append("\n");
try {
resourceState.append("\t").append("CREATION_TIME = ").append(Long.toString(cloudManager.getNextCreationTime())).append("\n");
} catch (Exception ex) {
resourceState.append("\t").append("CREATION_TIME = ").append(120000l).append("\n");
}
resourceState.append("\t").append("PENDING_RESOURCES = [").append("\n");
for (ResourceCreationRequest rcr : cloudManager.getPendingRequests()) {
resourceState.append("\t\t").append("RESOURCE = [").append("\n");
CloudMethodResourceDescription cmrd = rcr.getRequested();
resourceState.append("\t\t\t").append("NAME = ").append(cmrd.getName()).append("\n");
resourceState.append("\t\t\t").append("TYPE = ").append(Type.WORKER.toString()).append("\n");
resourceState.append("\t\t\t").append("CPUS = ").append(cmrd.getTotalCPUComputingUnits()).append("\n");
resourceState.append("\t\t\t").append("MEMORY = ").append(cmrd.getMemorySize()).append("\n");
resourceState.append("\t\t\t").append("CAN_RUN = [").append("\n");
int[][] simTasks = rcr.requestedSimultaneousTaskCount();
for (int coreId = 0; coreId < simTasks.length; coreId++) {
int coreSlots = 0;
for (int implId = 0; implId < simTasks[coreId].length; implId++) {
coreSlots = Math.max(coreSlots, simTasks[coreId][implId]);
}
resourceState.append("\t\t\t\t").append("CORE = [").append("\n");
resourceState.append("\t\t\t\t\t").append("COREID = ").append(coreId).append("\n");
resourceState.append("\t\t\t\t\t").append("NUM_SLOTS = ").append(coreSlots).append("\n");
resourceState.append("\t\t\t\t").append("]").append("\n");
}
// End CAN_RUN
resourceState.append("\t\t\t").append("]").append("\n");
// End RESOURCE
resourceState.append("\t\t").append("]").append("\n");
}
// End PENDING_RESOURCES
resourceState.append("\t").append("]").append("\n");
}
// END CLOUD_INFO
resourceState.append("]");
RESOURCES_LOGGER.info(resourceState.toString());
}
Aggregations