Search in sources :

Example 1 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class Factory method getDataMovementRemoteCluster.

public static RemoteCluster getDataMovementRemoteCluster(ProcessContext processContext) throws GFacException, AiravataException, CredentialStoreException {
    String storageResourceId = processContext.getStorageResourceId();
    DataMovementProtocol dataMovementProtocol = processContext.getDataMovementProtocol();
    String key = new StringBuilder(processContext.getComputeResourceLoginUserName()).append(':').append(dataMovementProtocol.name()).append(':').append(storageResourceId).append(":").append(processContext.getStorageResourceCredentialToken()).toString();
    RemoteCluster remoteCluster = remoteClusterMap.get(key);
    if (remoteCluster == null) {
        JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
        if (dataMovementProtocol == DataMovementProtocol.LOCAL) {
            remoteCluster = new LocalRemoteCluster(processContext.getStorageResourceServerInfo(), jobManagerConfiguration, null);
        } else if (dataMovementProtocol == DataMovementProtocol.SCP) {
            remoteCluster = new HPCRemoteCluster(processContext.getStorageResourceServerInfo(), jobManagerConfiguration, Factory.getStorageSSHKeyAuthentication(processContext));
        } else {
            throw new GFacException("No remote cluster implementation map to job data movement protocol " + dataMovementProtocol.name());
        }
        remoteClusterMap.put(key, remoteCluster);
    } else {
        AuthenticationInfo authentication = remoteCluster.getAuthentication();
        if (authentication instanceof SSHKeyAuthentication) {
            SSHKeyAuthentication sshKeyAuthentication = (SSHKeyAuthentication) authentication;
            if (!sshKeyAuthentication.getUserName().equals(processContext.getStorageResourceLoginUserName())) {
                JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
                dataMovementProtocol = processContext.getDataMovementProtocol();
                if (dataMovementProtocol == DataMovementProtocol.SCP) {
                    remoteCluster = new HPCRemoteCluster(processContext.getStorageResourceServerInfo(), jobManagerConfiguration, Factory.getStorageSSHKeyAuthentication(processContext));
                }
            }
        }
    }
    return remoteCluster;
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) JobManagerConfiguration(org.apache.airavata.gfac.core.JobManagerConfiguration) DataMovementProtocol(org.apache.airavata.model.data.movement.DataMovementProtocol) RemoteCluster(org.apache.airavata.gfac.core.cluster.RemoteCluster) SSHKeyAuthentication(org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication) AuthenticationInfo(org.apache.airavata.gfac.core.authentication.AuthenticationInfo)

Example 2 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class Factory method getJobSubmissionRemoteCluster.

/**
 * Factory class manage reomete cluster map, this will solve too many connections/ sessions issues with cluster
 * communications.
 * @param processContext
 * @return
 * @throws GFacException
 * @throws AppCatalogException
 * @throws AiravataException
 */
public static RemoteCluster getJobSubmissionRemoteCluster(ProcessContext processContext) throws GFacException, AppCatalogException, AiravataException, CredentialStoreException {
    String computeResourceId = processContext.getComputeResourceId();
    JobSubmissionProtocol jobSubmissionProtocol = processContext.getJobSubmissionProtocol();
    String key = new StringBuilder(processContext.getComputeResourceLoginUserName()).append(':').append(jobSubmissionProtocol.name()).append(':').append(computeResourceId).append(':').append(processContext.getComputeResourceCredentialToken()).toString();
    RemoteCluster remoteCluster = remoteClusterMap.get(key);
    if (remoteCluster == null) {
        JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
        if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL || jobSubmissionProtocol == JobSubmissionProtocol.LOCAL_FORK) {
            remoteCluster = new LocalRemoteCluster(processContext.getComputeResourceServerInfo(), jobManagerConfiguration, null);
        } else if (jobSubmissionProtocol == JobSubmissionProtocol.SSH || jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK || jobSubmissionProtocol == JobSubmissionProtocol.CLOUD) {
            remoteCluster = new HPCRemoteCluster(processContext.getComputeResourceServerInfo(), jobManagerConfiguration, Factory.getComputerResourceSSHKeyAuthentication(processContext));
        } else {
            throw new GFacException("No remote cluster implementation map to job submission protocol " + jobSubmissionProtocol.name());
        }
        remoteClusterMap.put(key, remoteCluster);
    } else {
        AuthenticationInfo authentication = remoteCluster.getAuthentication();
        if (authentication instanceof SSHKeyAuthentication) {
            SSHKeyAuthentication sshKeyAuthentication = (SSHKeyAuthentication) authentication;
            if (!sshKeyAuthentication.getUserName().equals(processContext.getComputeResourceLoginUserName())) {
                JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
                if (jobSubmissionProtocol == JobSubmissionProtocol.SSH || jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK) {
                    remoteCluster = new HPCRemoteCluster(processContext.getComputeResourceServerInfo(), jobManagerConfiguration, Factory.getComputerResourceSSHKeyAuthentication(processContext));
                }
            }
        }
    }
    return remoteCluster;
}
Also used : JobSubmissionProtocol(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol) GFacException(org.apache.airavata.gfac.core.GFacException) JobManagerConfiguration(org.apache.airavata.gfac.core.JobManagerConfiguration) RemoteCluster(org.apache.airavata.gfac.core.cluster.RemoteCluster) SSHKeyAuthentication(org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication) AuthenticationInfo(org.apache.airavata.gfac.core.authentication.AuthenticationInfo)

Example 3 with GFacException

use of org.apache.airavata.gfac.core.GFacException 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;
    }
}
Also used : LSFJobConfiguration(org.apache.airavata.gfac.impl.job.LSFJobConfiguration) GFacException(org.apache.airavata.gfac.core.GFacException) UGEJobConfiguration(org.apache.airavata.gfac.impl.job.UGEJobConfiguration) ForkJobConfiguration(org.apache.airavata.gfac.impl.job.ForkJobConfiguration) ResourceConfig(org.apache.airavata.gfac.core.config.ResourceConfig) OutputParser(org.apache.airavata.gfac.core.cluster.OutputParser) SlurmJobConfiguration(org.apache.airavata.gfac.impl.job.SlurmJobConfiguration) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) PBSJobConfiguration(org.apache.airavata.gfac.impl.job.PBSJobConfiguration)

Example 4 with GFacException

use of org.apache.airavata.gfac.core.GFacException 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();
}
Also used : JobSubmitterTaskConfig(org.apache.airavata.gfac.core.config.JobSubmitterTaskConfig) JobManagerConfiguration(org.apache.airavata.gfac.core.JobManagerConfiguration) ArchiveTask(org.apache.airavata.gfac.impl.task.ArchiveTask) ExperimentCatalog(org.apache.airavata.registry.cpi.ExperimentCatalog) JobMonitor(org.apache.airavata.gfac.core.monitor.JobMonitor) LoggerFactory(org.slf4j.LoggerFactory) CancelRequestWatcherImpl(org.apache.airavata.gfac.impl.watcher.CancelRequestWatcherImpl) ResourceJobManagerType(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType) Credential(org.apache.airavata.credential.store.credential.Credential) ServerSettings(org.apache.airavata.common.utils.ServerSettings) Publisher(org.apache.airavata.messaging.core.Publisher) Map(java.util.Map) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) SlurmJobConfiguration(org.apache.airavata.gfac.impl.job.SlurmJobConfiguration) MessagingFactory(org.apache.airavata.messaging.core.MessagingFactory) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) SSHKeyAuthentication(org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication) RabbitMQPublisher(org.apache.airavata.messaging.core.impl.RabbitMQPublisher) UUID(java.util.UUID) HostScheduler(org.apache.airavata.gfac.core.scheduler.HostScheduler) RedeliveryRequestWatcherImpl(org.apache.airavata.gfac.impl.watcher.RedeliveryRequestWatcherImpl) MessageHandler(org.apache.airavata.messaging.core.MessageHandler) AppCatalog(org.apache.airavata.registry.cpi.AppCatalog) List(java.util.List) AuroraJobMonitor(org.apache.airavata.gfac.monitor.cloud.AuroraJobMonitor) CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryPolicy(org.apache.curator.RetryPolicy) RedeliveryRequestWatcher(org.apache.airavata.gfac.core.watcher.RedeliveryRequestWatcher) CacheBuilder(com.google.common.cache.CacheBuilder) SSHCredential(org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) DataTransferTaskConfig(org.apache.airavata.gfac.core.config.DataTransferTaskConfig) JobSubmitterTaskConfig(org.apache.airavata.gfac.core.config.JobSubmitterTaskConfig) Task(org.apache.airavata.gfac.core.task.Task) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) ForkJobConfiguration(org.apache.airavata.gfac.impl.job.ForkJobConfiguration) PBSJobConfiguration(org.apache.airavata.gfac.impl.job.PBSJobConfiguration) Type(org.apache.airavata.messaging.core.Type) DataMovementProtocol(org.apache.airavata.model.data.movement.DataMovementProtocol) HashMap(java.util.HashMap) UGEJobConfiguration(org.apache.airavata.gfac.impl.job.UGEJobConfiguration) Constructor(java.lang.reflect.Constructor) CancelRequestWatcher(org.apache.airavata.gfac.core.watcher.CancelRequestWatcher) ArrayList(java.util.ArrayList) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) RegistryException(org.apache.airavata.registry.cpi.RegistryException) MonitorMode(org.apache.airavata.model.appcatalog.computeresource.MonitorMode) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacUtils(org.apache.airavata.gfac.core.GFacUtils) LSFJobConfiguration(org.apache.airavata.gfac.impl.job.LSFJobConfiguration) RegistryFactory(org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory) ResourceConfig(org.apache.airavata.gfac.core.config.ResourceConfig) Logger(org.slf4j.Logger) GFacException(org.apache.airavata.gfac.core.GFacException) RemoteCluster(org.apache.airavata.gfac.core.cluster.RemoteCluster) GFacYamlConfigruation(org.apache.airavata.gfac.core.config.GFacYamlConfigruation) JobSubmissionProtocol(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol) EmailBasedMonitor(org.apache.airavata.gfac.monitor.email.EmailBasedMonitor) TimeUnit(java.util.concurrent.TimeUnit) AuthenticationInfo(org.apache.airavata.gfac.core.authentication.AuthenticationInfo) GFacContext(org.apache.airavata.gfac.core.context.GFacContext) GFacEngine(org.apache.airavata.gfac.core.GFacEngine) RemovalListener(com.google.common.cache.RemovalListener) Cache(com.google.common.cache.Cache) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) OutputParser(org.apache.airavata.gfac.core.cluster.OutputParser) ServerInfo(org.apache.airavata.gfac.core.cluster.ServerInfo) com.jcraft.jsch(com.jcraft.jsch) Subscriber(org.apache.airavata.messaging.core.Subscriber) ArchiveTask(org.apache.airavata.gfac.impl.task.ArchiveTask) Task(org.apache.airavata.gfac.core.task.Task) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) GFacException(org.apache.airavata.gfac.core.GFacException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) GFacException(org.apache.airavata.gfac.core.GFacException) JobSubmissionTask(org.apache.airavata.gfac.core.task.JobSubmissionTask) ResourceConfig(org.apache.airavata.gfac.core.config.ResourceConfig) DataTransferTaskConfig(org.apache.airavata.gfac.core.config.DataTransferTaskConfig) GFacYamlConfigruation(org.apache.airavata.gfac.core.config.GFacYamlConfigruation)

Example 5 with GFacException

use of org.apache.airavata.gfac.core.GFacException in project airavata by apache.

the class Factory method getMonitorService.

public static JobMonitor getMonitorService(MonitorMode monitorMode) throws AiravataException, GFacException {
    JobMonitor jobMonitor = jobMonitorServices.get(monitorMode);
    if (jobMonitor == null) {
        synchronized (JobMonitor.class) {
            jobMonitor = jobMonitorServices.get(monitorMode);
            if (jobMonitor == null) {
                switch(monitorMode) {
                    case JOB_EMAIL_NOTIFICATION_MONITOR:
                        EmailBasedMonitor emailBasedMonitor = new EmailBasedMonitor(Factory.getResourceConfig());
                        jobMonitorServices.put(MonitorMode.JOB_EMAIL_NOTIFICATION_MONITOR, emailBasedMonitor);
                        jobMonitor = emailBasedMonitor;
                        new Thread(emailBasedMonitor).start();
                        break;
                    case CLOUD_JOB_MONITOR:
                        AuroraJobMonitor auroraJobMonitor = AuroraJobMonitor.getInstance();
                        new Thread(auroraJobMonitor).start();
                        jobMonitorServices.put(MonitorMode.CLOUD_JOB_MONITOR, auroraJobMonitor);
                        jobMonitor = auroraJobMonitor;
                        break;
                    default:
                        throw new GFacException("Unsupported monitor mode :" + monitorMode.name());
                }
            }
        }
    }
    return jobMonitor;
}
Also used : GFacException(org.apache.airavata.gfac.core.GFacException) EmailBasedMonitor(org.apache.airavata.gfac.monitor.email.EmailBasedMonitor) AuroraJobMonitor(org.apache.airavata.gfac.monitor.cloud.AuroraJobMonitor) JobMonitor(org.apache.airavata.gfac.core.monitor.JobMonitor) AuroraJobMonitor(org.apache.airavata.gfac.monitor.cloud.AuroraJobMonitor)

Aggregations

GFacException (org.apache.airavata.gfac.core.GFacException)73 IOException (java.io.IOException)24 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)19 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)16 JSchException (com.jcraft.jsch.JSchException)15 RegistryException (org.apache.airavata.registry.cpi.RegistryException)15 AiravataException (org.apache.airavata.common.exception.AiravataException)14 TaskStatus (org.apache.airavata.model.status.TaskStatus)13 URISyntaxException (java.net.URISyntaxException)12 ErrorModel (org.apache.airavata.model.commons.ErrorModel)11 CredentialStoreException (org.apache.airavata.credential.store.store.CredentialStoreException)10 TException (org.apache.thrift.TException)9 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)8 DefaultClientConfiguration (eu.unicore.util.httpclient.DefaultClientConfiguration)7 URI (java.net.URI)7 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)7 Session (com.jcraft.jsch.Session)6 InvalidKeyException (java.security.InvalidKeyException)6 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)6 JobModel (org.apache.airavata.model.job.JobModel)6