use of es.bsc.compss.types.resources.jaxb.PriceType in project compss by bsc-wdc.
the class WSAdaptor method constructConfiguration.
@Override
public Configuration constructConfiguration(Object project_properties, Object resources_properties) throws ConstructConfigurationException {
es.bsc.compss.types.project.jaxb.ServiceType s_project = (es.bsc.compss.types.project.jaxb.ServiceType) project_properties;
es.bsc.compss.types.resources.jaxb.ServiceType s_resources = (es.bsc.compss.types.resources.jaxb.ServiceType) resources_properties;
String wsdl = null;
if (s_project != null) {
wsdl = s_project.getWsdl();
} else if (s_resources != null) {
wsdl = s_resources.getWsdl();
} else {
// No wsdl (service unique key), throw exception
throw new ConstructConfigurationException("Cannot configure service because no WSDL provided");
}
WSConfiguration config = new WSConfiguration(this.getClass().getName(), wsdl);
if (s_project != null) {
config.setLimitOfTasks(s_project.getLimitOfTasks());
}
if (s_resources != null) {
config.setServiceName(s_resources.getName());
config.setNamespace(s_resources.getNamespace());
String servicePort = s_resources.getPort();
if (servicePort != null && !servicePort.isEmpty()) {
config.setPort(s_resources.getPort());
}
PriceType p = s_resources.getPrice();
if (p != null) {
config.setPricePerUnitTime(p.getPricePerUnit());
config.setPriceUnitTime(p.getTimeUnit());
}
}
return config;
}
use of es.bsc.compss.types.resources.jaxb.PriceType in project compss by bsc-wdc.
the class Validator method validateImage.
private void validateImage(ImageType image) throws InvalidElementException {
// Validate inner elements
List<Object> innerElements = image.getAdaptorsOrOperatingSystemOrSoftware();
if (innerElements != null) {
boolean adaptorsTagFound = false;
boolean OSTagFound = false;
boolean softwareTagFound = false;
boolean sdTagFound = false;
boolean priceTagFound = false;
boolean creationTimeTagFound = false;
for (Object obj : innerElements) {
if (obj instanceof AdaptorsListType) {
if (adaptorsTagFound) {
throw new InvalidElementException("Image", "Attribute Adaptors", "Appears more than once");
} else {
adaptorsTagFound = true;
validateAdaptors(((AdaptorsListType) obj));
}
} else if (obj instanceof OSType) {
if (OSTagFound) {
throw new InvalidElementException("Image", "Attribute OperatingSystem", "Appears more than once");
} else {
OSTagFound = true;
validateOS(((OSType) obj));
}
} else if (obj instanceof SoftwareListType) {
if (softwareTagFound) {
throw new InvalidElementException("Image", "Attribute Software", "Appears more than once");
} else {
softwareTagFound = true;
validateSoftwareList(((SoftwareListType) obj));
}
} else if (obj instanceof AttachedDisksListType) {
if (sdTagFound) {
throw new InvalidElementException("Image", "Attribute AttachedDisks", "Appears more than once");
} else {
sdTagFound = true;
this.validateAttachedDisksList(((AttachedDisksListType) obj));
}
} else if (obj instanceof PriceType) {
if (priceTagFound) {
throw new InvalidElementException("Image", "Attribute Price", "Appears more than once");
} else {
priceTagFound = true;
validatePrice(((PriceType) obj));
}
} else if (obj instanceof java.lang.Integer) {
// Creation time (int)
if (creationTimeTagFound) {
throw new InvalidElementException("Image", "Attribute CreationTime", "Appears more than once");
} else {
creationTimeTagFound = true;
// Nothing to validate since it is an integer
}
} else {
throw new InvalidElementException("Image", "Attribute " + obj.getClass(), "Incorrect attribute");
}
}
// Check minimum appearences
if (!adaptorsTagFound) {
throw new InvalidElementException("Image ", "Attribute Adaptors", "Doesn't appear");
}
} else {
// Empty inner elements
throw new InvalidElementException("Image", "", "Content is empty");
}
}
use of es.bsc.compss.types.resources.jaxb.PriceType in project compss by bsc-wdc.
the class Validator method validateInstance.
private void validateInstance(InstanceTypeType instance) throws InvalidElementException {
// Validate inner elements
List<Object> innerElements = instance.getProcessorOrMemoryOrStorage();
if (innerElements != null) {
List<String> processorNames = new ArrayList<String>();
boolean processorTagFound = false;
boolean memoryTagFound = false;
boolean storageTagFound = false;
boolean priceTagFound = false;
for (Object obj : innerElements) {
if (obj instanceof ProcessorType) {
processorTagFound = true;
ProcessorType p = (ProcessorType) obj;
if (processorNames.contains(p.getName())) {
throw new InvalidElementException("Instance", "Attribute Processor " + p.getName(), "Appears more than once");
} else {
processorNames.add(p.getName());
validateProcessor(((ProcessorType) obj));
}
} else if (obj instanceof MemoryType) {
if (memoryTagFound) {
throw new InvalidElementException("Instance", "Attribute Memory", "Appears more than once");
} else {
memoryTagFound = true;
validateMemory(((MemoryType) obj));
}
} else if (obj instanceof StorageType) {
if (storageTagFound) {
throw new InvalidElementException("Instance", "Attribute Storage", "Appears more than once");
} else {
storageTagFound = true;
validateStorage(((StorageType) obj));
}
} else if (obj instanceof PriceType) {
if (priceTagFound) {
throw new InvalidElementException("Instance", "Attribute Price", "Appears more than once");
} else {
priceTagFound = true;
validatePrice(((PriceType) obj));
}
} else {
throw new InvalidElementException("Instance", "Attribute " + obj.getClass(), "Incorrect attribute");
}
}
// Check minimum appearences
if (!processorTagFound) {
throw new InvalidElementException("Insntace", "Attribute Processor", "Doesn't appear");
}
} else {
// Empty inner elements
throw new InvalidElementException("InstanceType", "", "Content is empty");
}
}
use of es.bsc.compss.types.resources.jaxb.PriceType in project compss by bsc-wdc.
the class Validator method validateComputeNode.
/**
* Validates the given ComputeNodeType @cn with the current ResourcesFileType The content is correct if no exception
* is raised
*
* @param cn
* @throws InvalidElementException
*/
public void validateComputeNode(ComputeNodeType cn) throws InvalidElementException {
// Check that name isn't used
int num = 0;
for (String c : rf.getComputeNodes_names()) {
if (c.equals(cn.getName())) {
num = num + 1;
}
}
if (num > 1) {
// ComputeNode already exists
throw new InvalidElementException("ComputeNode", cn.getName(), "Name already in use");
}
// Check inner elements
List<Object> innerElements = cn.getProcessorOrAdaptorsOrMemory();
if (innerElements != null) {
List<String> processorNames = new ArrayList<String>();
boolean processorTagFound = false;
boolean adaptorsTagFound = false;
boolean memoryTagFound = false;
boolean storageTagFound = false;
boolean osTagFound = false;
boolean softwareTagFound = false;
boolean sharedDisksTagFound = false;
boolean priceTagFound = false;
for (Object obj : innerElements) {
if (obj instanceof ProcessorType) {
ProcessorType p = (ProcessorType) obj;
if (processorNames.contains(p.getName())) {
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Processor" + p.getName(), "Appears more than once");
} else {
processorTagFound = true;
processorNames.add(p.getName());
validateProcessor(p);
}
} else if (obj instanceof AdaptorsListType) {
if (adaptorsTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
adaptorsTagFound = true;
validateAdaptors(((AdaptorsListType) obj));
}
} else if (obj instanceof MemoryType) {
if (memoryTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
memoryTagFound = true;
validateMemory(((MemoryType) obj));
}
} else if (obj instanceof StorageType) {
if (storageTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
storageTagFound = true;
validateStorage(((StorageType) obj));
}
} else if (obj instanceof OSType) {
if (osTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
osTagFound = true;
validateOS(((OSType) obj));
}
} else if (obj instanceof SoftwareListType) {
if (softwareTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
softwareTagFound = true;
validateSoftwareList(((SoftwareListType) obj));
}
} else if (obj instanceof AttachedDisksListType) {
if (sharedDisksTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
sharedDisksTagFound = true;
validateAttachedDisksList(((AttachedDisksListType) obj));
}
} else if (obj instanceof PriceType) {
if (priceTagFound) {
// Second occurency, throw exception
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
} else {
priceTagFound = true;
validatePrice(((PriceType) obj));
}
} else {
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Incorrect attribute");
}
}
// Check minimum appearences
if (!processorTagFound) {
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Processor", "Doesn't appear");
}
if (!adaptorsTagFound) {
throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Adaptors", "Doesn't appear");
}
} else {
// Empty inner elements
throw new InvalidElementException("ComputeNode " + cn.getName(), "", "Content is empty");
}
}
Aggregations