use of org.apache.airavata.gfac.core.config.ResourceConfig in project airavata by apache.
the class Factory method getJobManagerConfiguration.
public static JobManagerConfiguration getJobManagerConfiguration(ResourceJobManager resourceJobManager) throws GFacException {
if (resourceJobManager == null)
return null;
ResourceConfig resourceConfig = Factory.getResourceConfig(resourceJobManager.getResourceJobManagerType());
OutputParser outputParser;
try {
Class<? extends OutputParser> aClass = Class.forName(resourceConfig.getCommandOutputParser()).asSubclass(OutputParser.class);
outputParser = aClass.getConstructor().newInstance();
} catch (Exception e) {
throw new GFacException("Error while instantiating output parser for " + resourceJobManager.getResourceJobManagerType().name());
}
String templateFileName = GFacUtils.getTemplateFileName(resourceJobManager.getResourceJobManagerType());
switch(resourceJobManager.getResourceJobManagerType()) {
case PBS:
return new PBSJobConfiguration(templateFileName, ".pbs", resourceJobManager.getJobManagerBinPath(), resourceJobManager.getJobManagerCommands(), outputParser);
case SLURM:
return new SlurmJobConfiguration(templateFileName, ".slurm", resourceJobManager.getJobManagerBinPath(), resourceJobManager.getJobManagerCommands(), outputParser);
case LSF:
return new LSFJobConfiguration(templateFileName, ".lsf", resourceJobManager.getJobManagerBinPath(), resourceJobManager.getJobManagerCommands(), outputParser);
case UGE:
return new UGEJobConfiguration(templateFileName, ".pbs", resourceJobManager.getJobManagerBinPath(), resourceJobManager.getJobManagerCommands(), outputParser);
case FORK:
return new ForkJobConfiguration(templateFileName, ".sh", resourceJobManager.getJobManagerBinPath(), resourceJobManager.getJobManagerCommands(), outputParser);
// We don't have a job configuration manager for CLOUD type
default:
return null;
}
}
use of org.apache.airavata.gfac.core.config.ResourceConfig in project airavata by apache.
the class Factory method loadConfiguration.
public static void loadConfiguration() throws GFacException {
GFacYamlConfigruation config = new GFacYamlConfigruation();
try {
for (JobSubmitterTaskConfig jobSubmitterTaskConfig : config.getJobSbumitters()) {
String taskClass = jobSubmitterTaskConfig.getTaskClass();
Class<?> aClass = Class.forName(taskClass);
Constructor<?> constructor = aClass.getConstructor();
JobSubmissionTask task = (JobSubmissionTask) constructor.newInstance();
task.init(jobSubmitterTaskConfig.getProperties());
jobSubmissionTask.put(jobSubmitterTaskConfig.getSubmissionProtocol(), task);
}
for (DataTransferTaskConfig dataTransferTaskConfig : config.getFileTransferTasks()) {
String taskClass = dataTransferTaskConfig.getTaskClass();
Class<?> aClass = Class.forName(taskClass);
Constructor<?> constructor = aClass.getConstructor();
Task task = (Task) constructor.newInstance();
task.init(dataTransferTaskConfig.getProperties());
dataMovementTask.put(dataTransferTaskConfig.getTransferProtocol(), task);
}
for (ResourceConfig resourceConfig : config.getResourceConfiguration()) {
resources.put(resourceConfig.getJobManagerType(), resourceConfig);
}
} catch (Exception e) {
throw new GFacException("Gfac config issue", e);
}
sessionCache = CacheBuilder.newBuilder().expireAfterAccess(ServerSettings.getSessionCacheAccessTimeout(), TimeUnit.MINUTES).removalListener((RemovalListener<String, Session>) removalNotification -> {
if (removalNotification.getValue().isConnected()) {
log.info("Disconnecting ssh session with key: " + removalNotification.getKey());
removalNotification.getValue().disconnect();
}
log.info("Removed ssh session with key: " + removalNotification.getKey());
}).build();
}
use of org.apache.airavata.gfac.core.config.ResourceConfig in project airavata by apache.
the class EmailBasedMonitor method populateAddressAndParserMap.
private void populateAddressAndParserMap(Map<ResourceJobManagerType, ResourceConfig> resourceConfigs) throws AiravataException {
for (Map.Entry<ResourceJobManagerType, ResourceConfig> resourceConfigEntry : resourceConfigs.entrySet()) {
ResourceJobManagerType type = resourceConfigEntry.getKey();
ResourceConfig config = resourceConfigEntry.getValue();
List<String> resourceEmailAddresses = config.getResourceEmailAddresses();
if (resourceEmailAddresses != null && !resourceEmailAddresses.isEmpty()) {
for (String resourceEmailAddress : resourceEmailAddresses) {
addressMap.put(resourceEmailAddress, type);
}
try {
Class<? extends EmailParser> emailParserClass = Class.forName(config.getEmailParser()).asSubclass(EmailParser.class);
EmailParser emailParser = emailParserClass.getConstructor().newInstance();
emailParserMap.put(type, emailParser);
} catch (Exception e) {
throw new AiravataException("Error while instantiation email parsers", e);
}
}
}
}
Aggregations