Search in sources :

Example 1 with JobManagerConfiguration

use of org.apache.airavata.gfac.core.JobManagerConfiguration 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 JobManagerConfiguration

use of org.apache.airavata.gfac.core.JobManagerConfiguration 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)

Aggregations

GFacException (org.apache.airavata.gfac.core.GFacException)2 JobManagerConfiguration (org.apache.airavata.gfac.core.JobManagerConfiguration)2 AuthenticationInfo (org.apache.airavata.gfac.core.authentication.AuthenticationInfo)2 SSHKeyAuthentication (org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication)2 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)2 JobSubmissionProtocol (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol)1 DataMovementProtocol (org.apache.airavata.model.data.movement.DataMovementProtocol)1