Search in sources :

Example 1 with LOCALSubmission

use of org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission in project airavata by apache.

the class DocumentCreatorNew method createLocalHostDocs.

public String createLocalHostDocs() throws AppCatalogException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    // Define compute resource host
    ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription("localhost", new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })), new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })));
    // host.setIsEmpty(true);
    host.setComputeResourceId(client.registerComputeResource(authzToken, host));
    LOCALSubmission localSubmission = new LOCALSubmission();
    ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.FORK, null, null, null);
    localSubmission.setResourceJobManager(resourceJobManager);
    client.addLocalSubmissionDetails(authzToken, host.getComputeResourceId(), 1, localSubmission);
    LOCALDataMovement localDataMovement = new LOCALDataMovement();
    client.addLocalDataMovementDetails(authzToken, host.getComputeResourceId(), 1, localDataMovement);
    // Define application module
    ApplicationModule module = DocumentCreatorUtils.createApplicationModule("echo", "1.0.0", "Local host echo applications");
    module.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module));
    // Define application interfaces
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    // application.setIsEmpty(false);
    application.setApplicationName("SimpleEcho0");
    application.addToApplicationModules(module.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("echo_input", "echo_input", "Echo Input Data", null, DataType.STRING));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("echo_output", null, DataType.STRING));
    application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
    // Define application deployment
    ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), module.getAppModuleId(), "/bin/echo", ApplicationParallelismType.SERIAL, "Local echo app depoyment");
    deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
    // Define gateway profile
    ComputeResourcePreference computeResourcePreference = DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/tmp", null, false, null, null, null);
    gatewayResourceProfile = new GatewayResourceProfile();
    // gatewayResourceProfile.setGatewayID("default");
    gatewayResourceProfile.setGatewayID(DEFAULT_GATEWAY);
    gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
    String gatewayId = client.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
    gatewayResourceProfile.setGatewayID(gatewayId);
    client.addGatewayComputeResourcePreference(authzToken, gatewayResourceProfile.getGatewayID(), host.getComputeResourceId(), computeResourcePreference);
    return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
Also used : LOCALSubmission(org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 2 with LOCALSubmission

use of org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission in project airavata by apache.

the class GFacEngineImpl method getResourceJobManager.

public static ResourceJobManager getResourceJobManager(ProcessContext processCtx) throws AppCatalogException, GFacException {
    List<JobSubmissionInterface> jobSubmissionInterfaces = Factory.getDefaultAppCatalog().getComputeResource().getComputeResource(processCtx.getComputeResourceId()).getJobSubmissionInterfaces();
    ResourceJobManager resourceJobManager = null;
    JobSubmissionInterface jsInterface = null;
    for (JobSubmissionInterface jobSubmissionInterface : jobSubmissionInterfaces) {
        if (jobSubmissionInterface.getJobSubmissionProtocol() == processCtx.getJobSubmissionProtocol()) {
            jsInterface = jobSubmissionInterface;
            break;
        }
    }
    if (jsInterface == null) {
        throw new GFacException("Job Submission interface cannot be empty at this point");
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.SSH) {
        SSHJobSubmission sshJobSubmission = Factory.getDefaultAppCatalog().getComputeResource().getSSHJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        // fixme - Move this to populate process
        processCtx.setMonitorMode(sshJobSubmission.getMonitorMode());
        // context method.
        resourceJobManager = sshJobSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.LOCAL) {
        LOCALSubmission localSubmission = Factory.getDefaultAppCatalog().getComputeResource().getLocalJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        resourceJobManager = localSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.SSH_FORK) {
        SSHJobSubmission sshJobSubmission = Factory.getDefaultAppCatalog().getComputeResource().getSSHJobSubmission(jsInterface.getJobSubmissionInterfaceId());
        // fixme - Move this to populate process
        processCtx.setMonitorMode(sshJobSubmission.getMonitorMode());
        resourceJobManager = sshJobSubmission.getResourceJobManager();
    } else if (jsInterface.getJobSubmissionProtocol() == JobSubmissionProtocol.CLOUD) {
        return null;
    } else {
        throw new GFacException("Unsupported JobSubmissionProtocol - " + jsInterface.getJobSubmissionProtocol().name());
    }
    if (resourceJobManager == null) {
        throw new GFacException("Resource Job Manager is empty.");
    }
    return resourceJobManager;
}
Also used : LOCALSubmission(org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission) JobSubmissionInterface(org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface) GFacException(org.apache.airavata.gfac.core.GFacException) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)

Aggregations

LOCALSubmission (org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission)2 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)2 GFacException (org.apache.airavata.gfac.core.GFacException)1 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)1 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)1 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)1 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)1 JobSubmissionInterface (org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface)1 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)1 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)1 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)1