Examples of JobExecutionContext


Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

     * @param experimentID
     * @return
     * @throws GFacException
     */
    public boolean submitJob(String experimentID,String taskID, String gatewayID) throws GFacException {
        JobExecutionContext jobExecutionContext = null;
        try {
            jobExecutionContext = createJEC(experimentID, taskID, gatewayID);
            return submitJob(jobExecutionContext);
        } catch (Exception e) {
            log.error("Error inovoking the job with experiment ID: " + experimentID);
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

            throw new GFacException(e);
        }
    }

    private JobExecutionContext createJEC(String experimentID, String taskID, String gatewayID) throws Exception {
        JobExecutionContext jobExecutionContext;
        TaskDetails taskData = (TaskDetails) registry.get(RegistryModelType.TASK_DETAIL, taskID);

        // this is wear our new model and old model is mapping (so serviceName in ExperimentData and service name in ServiceDescriptor
        // has to be same.

        // 1. Get the Task from the task ID and construct the Job object and save it in to registry
        // 2. Add another property to jobExecutionContext and read them inside the provider and use it.
        String serviceName = taskData.getApplicationId();
        if (serviceName == null) {
            throw new GFacException("Error executing the job because there is not Application Name in this Experiment:  " + serviceName );
        }
      
        ServiceDescription serviceDescription = airavataRegistry2.getServiceDescriptor(serviceName);
        if (serviceDescription == null ) {
            throw new GFacException("Error executing the job because there is not Application Name in this Experiment:  " + serviceName );
        }
        String hostName;
        HostDescription hostDescription = null;
        if(taskData.getTaskScheduling().getResourceHostId() != null){
            hostName = taskData.getTaskScheduling().getResourceHostId();
            hostDescription = airavataRegistry2.getHostDescriptor(hostName);
        }else{
            List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
              Map<String, ApplicationDescription> applicationDescriptors = airavataRegistry2.getApplicationDescriptors(serviceName);
              for (String hostDescName : applicationDescriptors.keySet()) {
                  registeredHosts.add(airavataRegistry2.getHostDescriptor(hostDescName));
              }
              Class<? extends HostScheduler> aClass = Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
             HostScheduler hostScheduler = aClass.newInstance();
             //TODO cleanup
            hostDescription = registeredHosts.get(0);//hostScheduler.schedule(registeredHosts);
          hostName = hostDescription.getType().getHostName();
        }
        if(hostDescription == null){
          throw new GFacException("Error executing the job as the host is not registered " + hostName)
        }
        ApplicationDescription applicationDescription = airavataRegistry2.getApplicationDescriptors(serviceName, hostName);
        URL resource = GFacImpl.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
        Properties configurationProperties = ServerSettings.getProperties();
        GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), airavataAPI, configurationProperties);


        // start constructing jobexecutioncontext
        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serviceName);

        // setting experiment/task/workflownode related information
        Experiment experiment = (Experiment) registry.get(RegistryModelType.EXPERIMENT, experimentID);
        jobExecutionContext.setExperiment(experiment);
        jobExecutionContext.setExperimentID(experimentID);
        jobExecutionContext.setWorkflowNodeDetails(experiment.getWorkflowNodeDetailsList().get(0));
        jobExecutionContext.setTaskData(taskData);

        // setting the registry
        jobExecutionContext.setRegistry(registry);

        ApplicationContext applicationContext = new ApplicationContext();
        applicationContext.setApplicationDeploymentDescription(applicationDescription);
        applicationContext.setHostDescription(hostDescription);
        applicationContext.setServiceDescription(serviceDescription);
        jobExecutionContext.setApplicationContext(applicationContext);

        List<DataObjectType> experimentInputs = taskData.getApplicationInputs();
        jobExecutionContext.setInMessageContext(new MessageContext(GFacUtils.getInMessageContext(experimentInputs,
                serviceDescription.getType().getInputParametersArray())));

        List<DataObjectType> outputData = taskData.getApplicationOutputs();
        jobExecutionContext.setOutMessageContext(new MessageContext(GFacUtils.getInMessageContext(outputData,
                serviceDescription.getType().getOutputParametersArray())));

        jobExecutionContext.setProperty(Constants.PROP_TOPIC, experimentID);
        jobExecutionContext.setGfac(this);
        return jobExecutionContext;
    }
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

     * @param experimentID
     * @return
     * @throws GFacException
     */
    public boolean submitJob(String experimentID, String taskID, String gatewayID) throws GFacException {
        JobExecutionContext jobExecutionContext = null;
        try {
            jobExecutionContext = createJEC(experimentID, taskID, gatewayID);
            return submitJob(jobExecutionContext);
        } catch (Exception e) {
            log.error("Error inovoking the job with experiment ID: " + experimentID);
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

        }
    }

    private JobExecutionContext createJEC(String experimentID, String taskID, String gatewayID) throws Exception {

        JobExecutionContext jobExecutionContext;

        /** FIXME:
         * A temporary wrapper to co-relate the app catalog and experiment thrift models to old gfac schema documents.
         * The serviceName in ExperimentData and service name in ServiceDescriptor has to be same.
         * 1. Get the Task from the task ID and construct the Job object and save it in to registry
         * 2. Add properties of description documents to jobExecutionContext which will be used inside the providers.
         */

        //Fetch the Task details for the requested experimentID from the registry. Extract required pointers from the Task object.
        TaskDetails taskData = (TaskDetails) registry.get(RegistryModelType.TASK_DETAIL, taskID);
        String applicationInterfaceId = taskData.getApplicationId();
        String applicationDeploymentId = taskData.getApplicationDeploymentId();
        if (null == applicationInterfaceId) {
            throw new GFacException("Error executing the job. The required Application Id is missing");
        }
        if (null == applicationDeploymentId) {
            throw new GFacException("Error executing the job. The required Application deployment Id is missing");
        }

        AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();

        //fetch the compute resource, application interface and deployment information from app catalog
        ApplicationInterfaceDescription applicationInterface = appCatalog.
                getApplicationInterface().getApplicationInterface(applicationInterfaceId);
        ApplicationDeploymentDescription applicationDeployment = appCatalog.
                getApplicationDeployment().getApplicationDeployement(applicationDeploymentId);
        ComputeResourceDescription computeResource = appCatalog.getComputeResource().
                getComputeResource(applicationDeployment.getComputeHostId());
        ComputeResourcePreference gatewayResourcePreferences = appCatalog.getGatewayProfile().
                getComputeResourcePreference(gatewayID, applicationDeployment.getComputeHostId());
        if (gatewayResourcePreferences == null) {
            List<String> gatewayProfileIds = appCatalog.getGatewayProfile()
                    .getGatewayProfileIds(gatewayID);
            for (String profileId : gatewayProfileIds) {
                gatewayID = profileId;
                gatewayResourcePreferences = appCatalog.getGatewayProfile().
                        getComputeResourcePreference(gatewayID, applicationDeployment.getComputeHostId());
                if (gatewayResourcePreferences != null) {
                    break;
                }
            }
        }
        //Create the legacy schema docs to fill-in
        ServiceDescription legacyServiceDescription = new ServiceDescription();
        ServiceDescriptionType legacyServiceDescType = legacyServiceDescription.getType();
        ApplicationDescription legacyAppDescription = null;
        HostDescription legacyHostDescription = null;

        ///////////////SERVICE DESCRIPTOR///////////////////////////////
        //Fetch the application inputs and outputs from the app interface and create the legacy service description.
        legacyServiceDescType.setName(applicationInterface.getApplicationName());
        legacyServiceDescType.setDescription(applicationInterface.getApplicationName());
        List<InputParameterType> legacyInputParameters = new ArrayList<InputParameterType>();
        List<OutputParameterType> legacyOutputParameters = new ArrayList<OutputParameterType>();
        List<InputDataObjectType> applicationInputs = applicationInterface.getApplicationInputs();
        for (InputDataObjectType dataObjectType : applicationInputs) {
            InputParameterType parameter = InputParameterType.Factory.newInstance();
            parameter.setParameterName(dataObjectType.getName());
            parameter.setParameterDescription(dataObjectType.getUserFriendlyDescription());
            ParameterType parameterType = parameter.addNewParameterType();
            switch (dataObjectType.getType()) {
                case FLOAT:
                    parameterType.setType(DataType.FLOAT);
                    break;
                case INTEGER:
                    parameterType.setType(DataType.INTEGER);
                    break;
                case STRING:
                    parameterType.setType(DataType.STRING);
                    break;
                case URI:
                    parameterType.setType(DataType.URI);
                    break;
            }
            parameterType.setName(parameterType.getType().toString());
            parameter.addParameterValue(dataObjectType.getValue());
            legacyInputParameters.add(parameter);
        }

        List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
        for (OutputDataObjectType dataObjectType : applicationOutputs) {
            OutputParameterType parameter = OutputParameterType.Factory.newInstance();
            parameter.setParameterName(dataObjectType.getName());
            parameter.setParameterDescription(dataObjectType.getName());
            ParameterType parameterType = parameter.addNewParameterType();
            switch (dataObjectType.getType()) {
                case FLOAT:
                    parameterType.setType(DataType.FLOAT);
                    break;
                case INTEGER:
                    parameterType.setType(DataType.INTEGER);
                    break;
                case STRING:
                    parameterType.setType(DataType.STRING);
                    break;
                case URI:
                    parameterType.setType(DataType.URI);
                    break;
            }
            parameterType.setName(parameterType.getType().toString());
            legacyOutputParameters.add(parameter);
        }

        legacyServiceDescType.setInputParametersArray(legacyInputParameters.toArray(new InputParameterType[]{}));
        legacyServiceDescType.setOutputParametersArray(legacyOutputParameters.toArray(new OutputParameterType[]{}));

        ////////////////////-----------  HOST DESCRIPTOR  -----------------//////////////////////
        //Fetch the host description details and fill-in legacy doc
        ResourceJobManager resourceJobManager = null;
        for (JobSubmissionInterface jobSubmissionInterface : computeResource.getJobSubmissionInterfaces()) {
            switch (jobSubmissionInterface.getJobSubmissionProtocol()) {
                case LOCAL:
                    legacyHostDescription = new HostDescription();
                    LOCALSubmission localSubmission =
                            appCatalog.getComputeResource().getLocalJobSubmission(jobSubmissionInterface.getJobSubmissionInterfaceId());
                    resourceJobManager = localSubmission.getResourceJobManager();
                    break;
                case SSH:
                    SSHJobSubmission sshJobSubmission =
                            appCatalog.getComputeResource().getSSHJobSubmission(jobSubmissionInterface.getJobSubmissionInterfaceId());
                    resourceJobManager = sshJobSubmission.getResourceJobManager();
                    switch (sshJobSubmission.getSecurityProtocol()) {
                        case GSI:
                            legacyHostDescription = new HostDescription(GsisshHostType.type);
                            ((GsisshHostType) legacyHostDescription.getType()).setJobManager
                                    (resourceJobManager.getResourceJobManagerType().name());
                            ((GsisshHostType) legacyHostDescription.getType()).setInstalledPath(resourceJobManager.getJobManagerBinPath());
                            // applicationDescription.setInstalledParentPath(resourceJobManager.getJobManagerBinPath());
                            ((GsisshHostType) legacyHostDescription.getType()).setPort(sshJobSubmission.getSshPort());
                            break;
                        case SSH_KEYS:
                            legacyHostDescription = new HostDescription(SSHHostType.type);
                            ((SSHHostType) legacyHostDescription.getType()).setHpcResource(true);
                            break;
                        default:
                            legacyHostDescription = new HostDescription(SSHHostType.type);
                            ((SSHHostType) legacyHostDescription.getType()).setHpcResource(true);
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
        HostDescriptionType legacyHostDescType = legacyHostDescription.getType();
        legacyHostDescType.setHostName(computeResource.getHostName());
        String ipAddress = computeResource.getHostName();
        if (computeResource.getIpAddresses() != null && computeResource.getIpAddresses().size() > 0) {
            ipAddress = computeResource.getIpAddresses().iterator().next();
        } else if (computeResource.getHostAliases() != null && computeResource.getHostAliases().size() > 0) {
            ipAddress = computeResource.getHostAliases().iterator().next();
        }
        legacyHostDescType.setHostAddress(ipAddress);

        /////////////////////---------------- APPLICATION DESCRIPTOR ---------------------/////////////////////////
        //Fetch deployment information and fill-in legacy doc
        if ((legacyHostDescType instanceof GsisshHostType) || (legacyHostDescType instanceof SSHHostType)) {
            legacyAppDescription = new ApplicationDescription(HpcApplicationDeploymentType.type);
            HpcApplicationDeploymentType legacyHPCAppDescType = (HpcApplicationDeploymentType) legacyAppDescription.getType();
            switch (applicationDeployment.getParallelism()) {
                case SERIAL:
                    legacyHPCAppDescType.setJobType(JobTypeType.SERIAL);
                    break;
                case MPI:
                    legacyHPCAppDescType.setJobType(JobTypeType.MPI);
                    break;
                case OPENMP:
                    legacyHPCAppDescType.setJobType(JobTypeType.OPEN_MP);
                    break;
                default:
                    break;
            }
            //Fetch scheduling information from experiment request
            ComputationalResourceScheduling taskSchedule = taskData.getTaskScheduling();
            QueueType queueType = legacyHPCAppDescType.addNewQueue();
            queueType.setQueueName(taskSchedule.getQueueName());
            legacyHPCAppDescType.setCpuCount(taskSchedule.getTotalCPUCount());
            legacyHPCAppDescType.setNodeCount(taskSchedule.getNodeCount());
            legacyHPCAppDescType.setMaxWallTime(taskSchedule.getWallTimeLimit());
            if (resourceJobManager != null) {
                legacyHPCAppDescType.setInstalledParentPath(resourceJobManager.getJobManagerBinPath());
                if (resourceJobManager.getJobManagerCommands() != null) {
                    legacyHPCAppDescType.setJobSubmitterCommand(resourceJobManager.getJobManagerCommands().get(JobManagerCommand.SUBMISSION));
                }
            }
            ProjectAccountType projectAccountType = legacyHPCAppDescType.addNewProjectAccount();
            if (gatewayResourcePreferences != null) {
                projectAccountType.setProjectAccountNumber(gatewayResourcePreferences.getAllocationProjectNumber());
            }
        } else {
            legacyAppDescription = new ApplicationDescription();
        }
        ApplicationDeploymentDescriptionType legacyAppDescType = legacyAppDescription.getType();
        legacyAppDescType.addNewApplicationName().setStringValue(applicationInterface.getApplicationName().replaceAll(" ", "_"));
        legacyAppDescType.setExecutableLocation(applicationDeployment.getExecutablePath());
        if (gatewayResourcePreferences != null) {
            legacyAppDescType.setScratchWorkingDirectory(gatewayResourcePreferences.getScratchLocation());
        } else {
            legacyAppDescType.setScratchWorkingDirectory("/tmp");
            log.warn("Missing gateway resource profile for gateway id '" + gatewayID + "'.");
        }

        URL resource = GFacImpl.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
        Properties configurationProperties = ServerSettings.getProperties();
        GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), airavataAPI, configurationProperties);

        // start constructing jobexecutioncontext
        jobExecutionContext = new JobExecutionContext(gFacConfiguration, applicationInterfaceId);

        // setting experiment/task/workflownode related information
        Experiment experiment = (Experiment) registry.get(RegistryModelType.EXPERIMENT, experimentID);
        jobExecutionContext.setExperiment(experiment);
        jobExecutionContext.setExperimentID(experimentID);
        jobExecutionContext.setWorkflowNodeDetails(experiment.getWorkflowNodeDetailsList().get(0));
        jobExecutionContext.setTaskData(taskData);
        jobExecutionContext.setGatewayID(gatewayID);

        // setting the registry
        jobExecutionContext.setRegistry(registry);

        ApplicationContext applicationContext = new ApplicationContext();
//        applicationContext.setApplicationDeploymentDescription(applicationDescription);
        applicationContext.setHostDescription(legacyHostDescription);
        applicationContext.setServiceDescription(legacyServiceDescription);
        applicationContext.setApplicationDeploymentDescription(legacyAppDescription);
        jobExecutionContext.setApplicationContext(applicationContext);

        List<DataObjectType> experimentInputs = taskData.getApplicationInputs();
        jobExecutionContext.setInMessageContext(new MessageContext(GFacUtils.getInMessageContext(experimentInputs,
                legacyServiceDescType.getInputParametersArray())));

        List<DataObjectType> outputData = taskData.getApplicationOutputs();
        jobExecutionContext.setOutMessageContext(new MessageContext(GFacUtils.getOutMessageContext(outputData,
                legacyServiceDescType.getOutputParametersArray())));

        jobExecutionContext.setProperty(Constants.PROP_TOPIC, experimentID);
        jobExecutionContext.setGfac(this);
        jobExecutionContext.setZk(zk);
        jobExecutionContext.setCredentialStoreToken(AiravataZKUtils.getExpTokenId(zk, experimentID, taskID));
        return jobExecutionContext;
    }
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

                .toArray(new OutputParameterType[outputList.size()]);

        serv.getType().setInputParametersArray(inputParamList);
        serv.getType().setOutputParametersArray(outputParamList);

        jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
        ApplicationContext applicationContext = new ApplicationContext();
        jobExecutionContext.setApplicationContext(applicationContext);
        applicationContext.setServiceDescription(serv);
        applicationContext.setApplicationDeploymentDescription(ec2Desc);
        applicationContext.setHostDescription(host);
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

    @Test
    public void testGFacConfigWithHost(){
        Assert.assertNotNull(gfac.getGfacConfigFile());
        Assert.assertEquals(1,gfac.getDaemonHandlers().size());
        try {
            JobExecutionContext jec = new JobExecutionContext(GFacConfiguration.create(gfac.getGfacConfigFile(), null, null), "testService");
            ApplicationContext applicationContext = new ApplicationContext();
            HostDescription host = new HostDescription(GsisshHostType.type);
            host.getType().setHostAddress("trestles.sdsc.edu");
            host.getType().setHostName("trestles");
            ((GsisshHostType) host.getType()).setPort(22);
            ((GsisshHostType) host.getType()).setInstalledPath("/opt/torque/bin/");
            applicationContext.setHostDescription(host);
            jec.setApplicationContext(applicationContext);
            Scheduler.schedule(jec);
            Assert.assertEquals(ExecutionMode.ASYNCHRONOUS, jec.getGFacConfiguration().getExecutionMode());
            Assert.assertEquals("org.apache.airavata.job.TestProvider", jec.getProvider().getClass().getName());
        } catch (ParserConfigurationException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        } catch (SAXException e) {
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

    @Test
        public void testAppSpecificConfig(){
            Assert.assertNotNull(gfac.getGfacConfigFile());
            Assert.assertEquals(1,gfac.getDaemonHandlers().size());
            try {
                JobExecutionContext jec = new JobExecutionContext(GFacConfiguration.create(gfac.getGfacConfigFile(), null, null), "UltraScan");
                ApplicationContext applicationContext = new ApplicationContext();
                HostDescription host = new HostDescription(GsisshHostType.type);
                host.getType().setHostAddress("trestles.sdsc.edu");
                host.getType().setHostName("trestles");
                ((GsisshHostType) host.getType()).setPort(22);
                ((GsisshHostType) host.getType()).setInstalledPath("/opt/torque/bin/");
                applicationContext.setHostDescription(host);
                jec.setApplicationContext(applicationContext);
                Scheduler.schedule(jec);
                Assert.assertEquals(3, jec.getGFacConfiguration().getInHandlers().size());
                Assert.assertEquals(1, jec.getGFacConfiguration().getInHandlers().get(0).getProperties().size());
                Assert.assertEquals(0, jec.getGFacConfiguration().getInHandlers().get(1).getProperties().size());
                Assert.assertEquals(1,jec.getGFacConfiguration().getInHandlers().get(2).getProperties().size());
                Assert.assertEquals(ExecutionMode.ASYNCHRONOUS, jec.getGFacConfiguration().getExecutionMode());// todo this logic might be wrong
                Assert.assertEquals("org.apache.airavata.job.TestProvider", jec.getProvider().getClass().getName());
            } catch (ParserConfigurationException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            } catch (IOException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            } catch (SAXException e) {
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

                .toArray(new OutputParameterType[outputList.size()]);

        serv.getType().setInputParametersArray(inputParamList);
        serv.getType().setOutputParametersArray(outputParamList);

        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
        jobExecutionContext.setApplicationContext(applicationContext);
        /*
        * Host
        */
        applicationContext.setServiceDescription(serv);
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

                .toArray(new OutputParameterType[outputList.size()]);

        serv.getType().setInputParametersArray(inputParamList);
        serv.getType().setOutputParametersArray(outputParamList);

        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
        // Adding security context
        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(app));
        ApplicationContext applicationContext = new ApplicationContext();
        jobExecutionContext.setApplicationContext(applicationContext);
        applicationContext.setServiceDescription(serv);
View Full Code Here

Examples of org.apache.airavata.gfac.core.context.JobExecutionContext

                .toArray(new OutputParameterType[outputList.size()]);

        serv.getType().setInputParametersArray(inputParamList);
        serv.getType().setOutputParametersArray(outputParamList);

        jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
        jobExecutionContext.setApplicationContext(applicationContext);

        // Add security context
        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext());
        /*
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.