use of es.bsc.compss.nio.master.configuration.NIOConfiguration in project compss by bsc-wdc.
the class NIOAdaptor method constructConfiguration.
@Override
public Configuration constructConfiguration(Object project_properties, Object resources_properties) throws ConstructConfigurationException {
NIOConfiguration config = new NIOConfiguration(this.getClass().getName());
es.bsc.compss.types.project.jaxb.NIOAdaptorProperties props_project = (es.bsc.compss.types.project.jaxb.NIOAdaptorProperties) project_properties;
es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties props_resources = (es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties) resources_properties;
// Get ports
int min_project = (props_project != null) ? props_project.getMinPort() : -1;
int min_resources = -1;
if (props_resources != null) {
min_resources = props_resources.getMinPort();
} else {
// MinPort on resources is mandatory
throw new ConstructConfigurationException("Resources file doesn't contain a minimum port value");
}
int max_project = (props_project != null) ? props_project.getMaxPort() : -1;
int max_resources = (props_resources != null) ? props_resources.getMaxPort() : -1;
// Merge port ranges
int min_final = -1;
if (min_project < 0) {
min_final = min_resources;
} else if (min_project < min_resources) {
LOGGER.warn("resources.xml MinPort is more restrictive than project.xml. Loading resources.xml values");
min_final = min_resources;
} else {
min_final = min_project;
}
int max_final = -1;
if (max_project < 0) {
if (max_resources < 0) {
// No max port defined
LOGGER.warn("MaxPort not defined in resources.xml/project.xml. Loading no limit");
} else {
LOGGER.warn("resources.xml MaxPort is more restrictive than project.xml. Loading resources.xml values");
max_final = max_resources;
}
} else if (max_resources < 0) {
max_final = max_project;
} else if (max_project < max_resources) {
max_final = max_project;
} else {
LOGGER.warn("resources.xml MaxPort is more restrictive than project.xml. Loading resources.xml values");
max_final = max_resources;
}
LOGGER.info("NIO Min Port: " + min_final);
LOGGER.info("NIO MAX Port: " + max_final);
config.setMinPort(min_final);
config.setMaxPort(max_final);
// Add remote execution command
String remoteExecutionCommand = props_resources.getRemoteExecutionCommand();
if (remoteExecutionCommand == null || remoteExecutionCommand.isEmpty()) {
remoteExecutionCommand = NIOConfiguration.DEFAULT_REMOTE_EXECUTION_COMMAND;
}
if (!NIOConfiguration.AVAILABLE_REMOTE_EXECUTION_COMMANDS.contains(remoteExecutionCommand)) {
throw new ConstructConfigurationException("Invalid remote execution command on resources file");
}
config.setRemoteExecutionCommand(remoteExecutionCommand);
return config;
}
Aggregations