Package org.apache.airavata.gfac.core.context

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


        URL resource = this.getClass().getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
        File configFile = new File(resource.getPath());
        GFacConfiguration gFacConfiguration = GFacConfiguration.create(configFile, null, null);
        //have to set InFlwo Handlers and outFlowHandlers
        ApplicationContext applicationContext = new ApplicationContext();
        HostDescription host = new HostDescription();
        host.getType().setHostName("localhost");
        host.getType().setHostAddress("localhost");
        applicationContext.setHostDescription(host);
        /*
           * App
           */
        ApplicationDescription appDesc = new ApplicationDescription();
        ApplicationDeploymentDescriptionType app = appDesc.getType();
        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
        name.setStringValue("EchoLocal");
        app.setApplicationName(name);

        /*
           * Use bat file if it is compiled on Windows
           */
        if (SystemUtils.IS_OS_WINDOWS) {
            URL url = this.getClass().getClassLoader().getResource("echo.bat");
            app.setExecutableLocation(url.getFile());
        } else {
            //for unix and Mac
            app.setExecutableLocation("/bin/echo");
        }

        /*
           * Default tmp location
           */
        String tempDir = System.getProperty("java.io.tmpdir");
        if (tempDir == null) {
            tempDir = "/tmp";
        }

        app.setScratchWorkingDirectory(tempDir);
        app.setStaticWorkingDirectory(tempDir);
        app.setInputDataDirectory(tempDir + File.separator + "input");
        app.setOutputDataDirectory(tempDir + File.separator + "output");
        app.setStandardOutput(tempDir + File.separator + "echo.stdout");
        app.setStandardError(tempDir + File.separator + "echo.stderr");

        applicationContext.setApplicationDeploymentDescription(appDesc);

        /*
           * Service
           */
        ServiceDescription serv = new ServiceDescription();
        serv.getType().setName("SimpleEcho");

        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
        InputParameterType input = InputParameterType.Factory.newInstance();
        input.setParameterName("echo_input");
        input.setParameterType(StringParameterType.Factory.newInstance());
        inputList.add(input);
        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
                .size()]);

        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
        OutputParameterType output = OutputParameterType.Factory.newInstance();
        output.setParameterName("echo_output");
        output.setParameterType(StringParameterType.Factory.newInstance());
        outputList.add(output);
        OutputParameterType[] outputParamList = outputList
                .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);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);
View Full Code Here


        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())));
View Full Code Here

        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())));
View Full Code Here

        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);

        AmazonSecurityContext amazonSecurityContext =
                new AmazonSecurityContext(userName, accessKey, secretKey, instanceId);
        jobExecutionContext.addSecurityContext(AmazonSecurityContext.AMAZON_SECURITY_CONTEXT, amazonSecurityContext);
View Full Code Here

    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) {
View Full Code Here

        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());
View Full Code Here

        URL resource = this.getClass().getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
        File configFile = new File(resource.getPath());
        GFacConfiguration gFacConfiguration = GFacConfiguration.create(configFile, null, null);
        //have to set InFlwo Handlers and outFlowHandlers
        ApplicationContext applicationContext = new ApplicationContext();
        HostDescription host = new HostDescription();
        host.getType().setHostName("localhost");
        host.getType().setHostAddress("localhost");
        applicationContext.setHostDescription(host);
        /*
           * App
           */
        ApplicationDescription appDesc = new ApplicationDescription();
        ApplicationDeploymentDescriptionType app = appDesc.getType();
        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
        name.setStringValue("EchoLocal");
        app.setApplicationName(name);

        /*
           * Use bat file if it is compiled on Windows
           */
        if (SystemUtils.IS_OS_WINDOWS) {
            URL url = this.getClass().getClassLoader().getResource("echo.bat");
            app.setExecutableLocation(url.getFile());
        } else {
            //for unix and Mac
            app.setExecutableLocation("/bin/echo");
        }

        /*
           * Default tmp location
           */
        String tempDir = System.getProperty("java.io.tmpdir");
        if (tempDir == null) {
            tempDir = "/tmp";
        }

        app.setScratchWorkingDirectory(tempDir);
        app.setStaticWorkingDirectory(tempDir);
        app.setInputDataDirectory(tempDir + File.separator + "input");
        app.setOutputDataDirectory(tempDir + File.separator + "output");
        app.setStandardOutput(tempDir + File.separator + "echo.stdout");
        app.setStandardError(tempDir + File.separator + "echo.stderr");

        applicationContext.setApplicationDeploymentDescription(appDesc);

        /*
           * Service
           */
        ServiceDescription serv = new ServiceDescription();
        serv.getType().setName("SimpleEcho");

        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
        InputParameterType input = InputParameterType.Factory.newInstance();
        input.setParameterName("echo_input");
        input.setParameterType(StringParameterType.Factory.newInstance());
        inputList.add(input);
        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
                .size()]);

        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
        OutputParameterType output = OutputParameterType.Factory.newInstance();
        output.setParameterName("echo_output");
        output.setParameterType(StringParameterType.Factory.newInstance());
        outputList.add(output);
        OutputParameterType[] outputParamList = outputList
                .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);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);
View Full Code Here

        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);
        applicationContext.setApplicationDeploymentDescription(appDesc);
        applicationContext.setHostDescription(host);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);
View Full Code Here

      URL resource = SSHProviderTestWithSSHAuth.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
        GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),null,null);
//        gFacConfiguration.s
        //have to set InFlwo Handlers and outFlowHandlers
        ApplicationContext applicationContext = new ApplicationContext();
        HostDescription host = new HostDescription(SSHHostType.type);
        host.getType().setHostName("bigred");
        host.getType().setHostAddress("bigred2.uits.iu.edu");
        applicationContext.setHostDescription(host);
        /*
           * App
           */
        ApplicationDescription appDesc = new ApplicationDescription();
        ApplicationDeploymentDescriptionType app = appDesc.getType();
        ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
        name.setStringValue("EchoSSH");
        app.setApplicationName(name);

        /*
           * Use bat file if it is compiled on Windows
           */
        if (SystemUtils.IS_OS_WINDOWS) {
            URL url = this.getClass().getClassLoader().getResource("echo.bat");
            app.setExecutableLocation(url.getFile());
        } else {
            //for unix and Mac
            app.setExecutableLocation("/bin/echo");
        }

        /*
         * Job location
        */
        String tempDir = "/tmp";
        String date = (new Date()).toString();
        date = date.replaceAll(" ", "_");
        date = date.replaceAll(":", "_");

        tempDir = tempDir + File.separator
                + "EchoSSH" + "_" + date + "_" + UUID.randomUUID();

        app.setScratchWorkingDirectory(tempDir);
        app.setStaticWorkingDirectory(tempDir);
        app.setInputDataDirectory(tempDir + File.separator + "input");
        app.setOutputDataDirectory(tempDir + File.separator + "output");
        app.setStandardOutput(tempDir + File.separator + "echo.stdout");
        app.setStandardError(tempDir + File.separator + "echo.stderr");

        applicationContext.setApplicationDeploymentDescription(appDesc);

        /*
           * Service
           */
        ServiceDescription serv = new ServiceDescription();
        serv.getType().setName("EchoSSH");

        List<InputParameterType> inputList = new ArrayList<InputParameterType>();
        InputParameterType input = InputParameterType.Factory.newInstance();
        input.setParameterName("echo_input");
        input.setParameterType(StringParameterType.Factory.newInstance());
        inputList.add(input);
        InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
                .size()]);

        List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
        OutputParameterType output = OutputParameterType.Factory.newInstance();
        output.setParameterName("echo_output");
        output.setParameterType(StringParameterType.Factory.newInstance());
        outputList.add(output);
        OutputParameterType[] outputParamList = outputList
                .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());
        /*
        * Host
        */
        applicationContext.setServiceDescription(serv);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
    ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);
View Full Code Here

        serv.getType().setOutputParametersArray(outputParamList);

        jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
        // Adding security context
        jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, getSecurityContext(app));
        ApplicationContext applicationContext = new ApplicationContext();
        jobExecutionContext.setApplicationContext(applicationContext);
        applicationContext.setServiceDescription(serv);
        applicationContext.setApplicationDeploymentDescription(appDesc);
        applicationContext.setHostDescription(host);

        MessageContext inMessage = new MessageContext();
        ActualParameter echo_input = new ActualParameter();
        ((StringParameterType) echo_input.getType()).setValue("echo_output=hello");
        inMessage.addParameter("echo_input", echo_input);
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.core.context.ApplicationContext

Copyright © 2018 www.massapicom. 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.