use of es.bsc.compss.types.resources.MethodWorker in project compss by bsc-wdc.
the class ExternalAdaptationManager method normalRemove.
private void normalRemove(String name) {
MethodWorker w = (MethodWorker) ResourceManager.getWorker(name);
if (w != null) {
// TODO: ResourceManager.reduceWholeWorker(w);
RUNTIME_LOGGER.info(LOG_PREFIX + "TODO: Resource " + name + " removed.");
writePipe(resultPipe, ACK);
} else {
RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: Resource " + name + " not found.");
writePipe(resultPipe, "ERROR: Error creating resource " + name + " not found.");
}
}
use of es.bsc.compss.types.resources.MethodWorker 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.MethodWorker in project compss by bsc-wdc.
the class ResourceLoader method createMethodWorker.
private static MethodWorker createMethodWorker(String name, MethodResourceDescription rd, Map<String, String> sharedDisks, MethodConfiguration mc) {
// Compute task count
int taskCount = getValidMinimum(mc.getLimitOfTasks(), rd.getTotalCPUComputingUnits());
mc.setLimitOfTasks(taskCount);
int taskCountGPU = getValidMinimum(mc.getLimitOfGPUTasks(), rd.getTotalGPUComputingUnits());
mc.setLimitOfGPUTasks(taskCountGPU);
int taskCountFPGA = getValidMinimum(mc.getLimitOfFPGATasks(), rd.getTotalFPGAComputingUnits());
mc.setLimitOfFPGATasks(taskCountFPGA);
int taskCountOther = getValidMinimum(mc.getLimitOfOTHERSTasks(), rd.getTotalOTHERComputingUnits());
mc.setLimitOfOTHERSTasks(taskCountOther);
// Create the method worker
MethodWorker methodWorker = new MethodWorker(name, rd, mc, sharedDisks);
return methodWorker;
}
use of es.bsc.compss.types.resources.MethodWorker 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.MethodWorker in project compss by bsc-wdc.
the class ResourceManagerTest method createMethodWorker.
private static MethodWorker createMethodWorker(String name, MethodResourceDescription rd, HashMap<String, String> sharedDisks, MethodConfiguration mc) {
// Compute task count
int taskCount;
int limitOfTasks = mc.getLimitOfTasks();
int computingUnits = rd.getTotalCPUComputingUnits();
if (limitOfTasks < 0 && computingUnits < 0) {
taskCount = 0;
} else {
taskCount = Math.max(limitOfTasks, computingUnits);
}
mc.setLimitOfTasks(taskCount);
limitOfTasks = mc.getLimitOfGPUTasks();
computingUnits = rd.getTotalGPUComputingUnits();
if (limitOfTasks < 0 && computingUnits < 0) {
taskCount = 0;
} else {
taskCount = Math.max(limitOfTasks, computingUnits);
}
mc.setLimitOfGPUTasks(taskCount);
limitOfTasks = mc.getLimitOfFPGATasks();
computingUnits = rd.getTotalFPGAComputingUnits();
if (limitOfTasks < 0 && computingUnits < 0) {
taskCount = 0;
} else {
taskCount = Math.max(limitOfTasks, computingUnits);
}
mc.setLimitOfFPGATasks(taskCount);
limitOfTasks = mc.getLimitOfOTHERSTasks();
computingUnits = rd.getTotalOTHERComputingUnits();
if (limitOfTasks < 0 && computingUnits < 0) {
taskCount = 0;
} else {
taskCount = Math.max(limitOfTasks, computingUnits);
}
mc.setLimitOfOTHERSTasks(taskCount);
MethodWorker methodWorker = new MethodWorker(name, rd, mc, sharedDisks);
return methodWorker;
}
Aggregations