Package org.apache.airavata.commons.gfac.type

Examples of org.apache.airavata.commons.gfac.type.HostDescription


public class DescriptorUtil {

    public static HostDescription createHostDescription(String hostName, String hostAddress,
                                                        String hostEndpoint, String gatekeeperEndpoint, String providerType) {
        HostDescription host = new HostDescription();
        host.getType().setHostName(hostName);
        host.getType().setHostAddress(hostAddress);
        if(providerType.equalsIgnoreCase(HostTypes.GLOBUS_HOST_TYPE)){
           host.getType().changeType(GlobusHostType.type);
             ((GlobusHostType) host.getType()).
                     setGridFTPEndPointArray(new String[]{hostEndpoint});
             ((GlobusHostType) host.getType()).
                     setGlobusGateKeeperEndPointArray(new String[]{gatekeeperEndpoint});
        }else if (providerType.equalsIgnoreCase(HostTypes.SSH_HOST_TYPE)){
             host.getType().changeType(SSHHostType.type);
        }else if (providerType.equalsIgnoreCase(HostTypes.UNICORE_HOST_TYPE)){
           host.getType().changeType(GlobusHostType.type);
             ((UnicoreHostType) host.getType()).
                     setGridFTPEndPointArray(new String[]{hostEndpoint});
             ((UnicoreHostType) host.getType()).
                     setUnicoreBESEndPointArray(new String[]{gatekeeperEndpoint});
        }
        return host;
    }
View Full Code Here


        hostDescriptor.setHostType(hostType);
        return hostDescriptor;
    }

    public static HostDescription createHostDescription (HostDescriptor hostDescriptor){
        HostDescription hostDescription = new HostDescription(HostDescriptionType.type);
        hostDescription.getType().setHostAddress(hostDescriptor.getHostAddress());
        hostDescription.getType().setHostName(hostDescriptor.getHostname());

        if (hostDescriptor.getHostType() != null && !hostDescriptor.getHostType().isEmpty()) {
            if (hostDescriptor.getHostType().get(0).equals(HostTypes.GLOBUS_HOST_TYPE)) {
                hostDescription.getType().changeType(GlobusHostType.type);
                if (!hostDescriptor.getGateKeeperEndPoint().isEmpty() && hostDescriptor.getGateKeeperEndPoint() != null){
                    ((GlobusHostType) hostDescription.getType()).addGlobusGateKeeperEndPoint(hostDescriptor.getGateKeeperEndPoint().get(0));
                }
                if (!hostDescriptor.getGridFTPEndPoint().isEmpty() && hostDescriptor.getGridFTPEndPoint() != null){
                    ((GlobusHostType) hostDescription.getType()).addGridFTPEndPoint(hostDescriptor.getGridFTPEndPoint().get(0));
                }

            } else if (hostDescriptor.getHostType().get(0).equals(HostTypes.GSISSH_HOST_TYPE)) {
                hostDescription.getType().changeType(GsisshHostType.type);
                if (!hostDescriptor.getGridFTPEndPoint().isEmpty() && hostDescriptor.getGridFTPEndPoint() != null){
                    ((GsisshHostType) hostDescription).addGridFTPEndPoint(hostDescriptor.getGridFTPEndPoint().get(0));
                }

            } else if (hostDescriptor.getHostType().get(0).equals(HostTypes.EC2_HOST_TYPE)) {
                hostDescription.getType().changeType(Ec2HostType.type);
                if (!hostDescriptor.getImageID().isEmpty() && hostDescriptor.getImageID() != null ){
                    ((Ec2HostType) hostDescription).addImageID(hostDescriptor.getImageID().get(0));
                }
                if (!hostDescriptor.getInstanceID().isEmpty() && hostDescriptor.getInstanceID() != null){
                    ((Ec2HostType) hostDescription).addInstanceID(hostDescriptor.getInstanceID().get(0));
                }

            }else if (hostDescriptor.getHostType().get(0).equals(HostTypes.SSH_HOST_TYPE)) {
              hostDescription.getType().changeType(SSHHostType.type);
            } else if (hostDescriptor.getHostType().get(0).equals(HostTypes.UNICORE_HOST_TYPE)) {
                 hostDescription.getType().changeType(UnicoreHostType.type);
                 if (!hostDescriptor.getGateKeeperEndPoint().isEmpty() && hostDescriptor.getGateKeeperEndPoint() != null){
                     ((UnicoreHostType) hostDescription.getType()).addUnicoreBESEndPoint(hostDescriptor.getGateKeeperEndPoint().get(0));
                 }
                 if (!hostDescriptor.getGridFTPEndPoint().isEmpty() && hostDescriptor.getGridFTPEndPoint() != null){
                     ((UnicoreHostType) hostDescription.getType()).addGridFTPEndPoint(hostDescriptor.getGridFTPEndPoint().get(0));
                 }
            }
        }

        return hostDescription;
View Full Code Here

    @Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
    public void testEchoService() throws Exception {

        DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();

        HostDescription hostDescription = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost",
                "127.0.0.1");

        log("Adding host description ....");
        airavataAPI.getApplicationManager().addHostDescription(hostDescription);

        Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(
                hostDescription.getType().getHostName()));

        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
        inputParameters.add(descriptorBuilder.buildInputParameterType("echo_input", "echo input", DataType.STRING));

        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
        outputParameters.add(descriptorBuilder.buildOutputParameterType("echo_output", "Echo output", DataType.STRING));

        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("Echo", "Echo service",
                inputParameters, outputParameters);

        log("Adding service description ...");
        airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription.getType().getName()));

        // Deployment descriptor
        ApplicationDescription applicationDeploymentDescription = descriptorBuilder
                .buildApplicationDeploymentDescription("EchoApplication", "/bin/echo", "/tmp");

        log("Adding deployment description ...");
        airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription, hostDescription,
                applicationDeploymentDescription);

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription.getType().getApplicationName().getStringValue()));

        log("Saving workflow ...");
        Workflow workflow = new Workflow(getWorkflowComposeContent("src/test/resources/EchoWorkflow.xwf"));
        airavataAPI.getWorkflowManager().addWorkflow(workflow);
View Full Code Here

    @Test(groups = { "echoGroup" }/* , dependsOnMethods = { "testEchoService" } */)
    public void testUpdateEchoService() throws Exception {

        DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();

        HostDescription hostDescription = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost",
                "127.0.0.1");

        log("Trying to add host description ....");
        try {
            airavataAPI.getApplicationManager().addHostDescription(hostDescription);
            Assert.fail("Host Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating host description ....");
            airavataAPI.getApplicationManager().updateHostDescription(hostDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(
                hostDescription.getType().getHostName()));

        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
        inputParameters.add(descriptorBuilder.buildInputParameterType("echo_input", "echo input", DataType.STRING));

        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
        outputParameters.add(descriptorBuilder.buildOutputParameterType("echo_output", "Echo output", DataType.STRING));

        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("Echo", "Echo service",
                inputParameters, outputParameters);

        log("Adding service description ...");
        try {
            airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
            Assert.fail("Service Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating service description ....");
            airavataAPI.getApplicationManager().updateServiceDescription(serviceDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription.getType().getName()));

        // Deployment descriptor
        ApplicationDescription applicationDeploymentDescription = descriptorBuilder
                .buildApplicationDeploymentDescription("EchoApplication", "/bin/echo", "/tmp");

        log("Adding deployment description ...");
        try {
            airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription, hostDescription,
                    applicationDeploymentDescription);
            Assert.fail("Application Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating application description ....");
            airavataAPI.getApplicationManager().updateApplicationDescription(serviceDescription, hostDescription,
                    applicationDeploymentDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription.getType().getApplicationName().getStringValue()));

        log("Saving workflow ...");
        Workflow workflow = new Workflow(getWorkflowComposeContent("src/test/resources/EchoWorkflow.xwf"));

View Full Code Here

        return appDesc;
    }

    protected HostDescription getHostDesc() {
        HostDescription host = new HostDescription(UnicoreHostType.type);
        host.getType().setHostAddress(hostAddress);
        host.getType().setHostName(hostName);
        ((UnicoreHostType) host.getType()).setUnicoreBESEndPointArray(hostArray);
        ((UnicoreHostType) host.getType()).setGridFTPEndPointArray(new String[] { gridftpAddress });
        return host;
    }
View Full Code Here

    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
        if (hostName != null) {
            HostDescription hostDescription;
            try {
                hostDescription = registry.getApplicationManager().getHostDescription(hostName);
                if (hostDescription.getType() instanceof GlobusHostType) {
                    getShellApplicationDescription().getType().changeType(HpcApplicationDeploymentType.type);
                }else if (hostDescription.getType() instanceof GsisshHostType) {
                        getShellApplicationDescription().getType().changeType(HpcApplicationDeploymentType.type);
                }else if (hostDescription.getType() instanceof SSHHostType && ((SSHHostType)hostDescription.getType()).getHpcResource()) {
                    getShellApplicationDescription().getType().changeType(HpcApplicationDeploymentType.type);
                } else {
                    getShellApplicationDescription().getType().changeType(ApplicationDeploymentDescriptionType.type);
                }
                btnHostAdvanceOptions.setVisible(getShellApplicationDescription().getType() instanceof HpcApplicationDeploymentType);
                String hostAddress = hostDescription.getType().getHostAddress();
                boolean isLocal = isLocalAddress(hostAddress);
                btnExecBrowse.setVisible(isLocal);
                btnTmpDirBrowse.setVisible(isLocal);
            } catch (AiravataAPIInvocationException e) {
                e.printStackTrace();
View Full Code Here

    @Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
    public void testEchoService() throws Exception {

        DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();

        HostDescription hostDescription = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost",
                "127.0.0.1");

        log("Adding host description ....");
        airavataAPI.getApplicationManager().addHostDescription(hostDescription);

        Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(
                hostDescription.getType().getHostName()));

        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
        inputParameters.add(descriptorBuilder.buildInputParameterType("echo_input", "echo input", DataType.STRING));

        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
        outputParameters.add(descriptorBuilder.buildOutputParameterType("echo_output", "Echo output", DataType.STRING));

        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("Echo", "Echo service",
                inputParameters, outputParameters);

        log("Adding service description ...");
        airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription.getType().getName()));

        // Deployment descriptor
        ApplicationDescription applicationDeploymentDescription = descriptorBuilder
                .buildApplicationDeploymentDescription("EchoApplication", OsUtils.getEchoExecutable(), OsUtils.getTempFolderPath());

        log("Adding deployment description ...");
        airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription, hostDescription,
                applicationDeploymentDescription);

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription.getType().getApplicationName().getStringValue()));

        log("Saving workflow ...");
        Workflow workflow = new Workflow(getWorkflowComposeContent("src/test/resources/EchoWorkflow.xwf"));
        airavataAPI.getWorkflowManager().addWorkflow(workflow);
View Full Code Here

    @Test(groups = { "echoGroup" }/* , dependsOnMethods = { "testEchoService" } */)
    public void testUpdateEchoService() throws Exception {

        DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();

        HostDescription hostDescription = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost",
                "127.0.0.1");

        log("Trying to add host description ....");
        try {
            airavataAPI.getApplicationManager().addHostDescription(hostDescription);
            Assert.fail("Host Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating host description ....");
            airavataAPI.getApplicationManager().updateHostDescription(hostDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(
                hostDescription.getType().getHostName()));

        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
        inputParameters.add(descriptorBuilder.buildInputParameterType("echo_input", "echo input", DataType.STRING));

        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
        outputParameters.add(descriptorBuilder.buildOutputParameterType("echo_output", "Echo output", DataType.STRING));

        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("Echo", "Echo service",
                inputParameters, outputParameters);

        log("Adding service description ...");
        try {
            airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
            Assert.fail("Service Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating service description ....");
            airavataAPI.getApplicationManager().updateServiceDescription(serviceDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription.getType().getName()));

        // Deployment descriptor
        ApplicationDescription applicationDeploymentDescription = descriptorBuilder
                .buildApplicationDeploymentDescription("EchoApplication", OsUtils.getEchoExecutable(), OsUtils.getTempFolderPath());

        log("Adding deployment description ...");
        try {
            airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription, hostDescription,
                    applicationDeploymentDescription);
            Assert.fail("Application Descriptor should already exists and should go to update.");
        } catch (DescriptorAlreadyExistsException e) {

            log("Updating application description ....");
            airavataAPI.getApplicationManager().updateApplicationDescription(serviceDescription, hostDescription,
                    applicationDeploymentDescription);
        }

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription.getType().getApplicationName().getStringValue()));

        log("Saving workflow ...");
        Workflow workflow = new Workflow(getWorkflowComposeContent("src/test/resources/EchoWorkflow.xwf"));

View Full Code Here

        }
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        OMElement documentElement = builder.getDocumentElement();
        Iterator<?> server = documentElement.getChildrenWithName(new QName("server"));
        while (server.hasNext()) {
            HostDescription hostDescription = new HostDescription();
            OMElement next = (OMElement) server.next();
            if (next.getFirstChildWithName(new QName("gram.endpoint")) != null &&
                    "globus".equals(next.getFirstChildWithName(new QName("type")).getText())) {
                hostDescription.getType().changeType(GlobusHostType.type);
                ((GlobusHostType) hostDescription.getType()).addGlobusGateKeeperEndPoint(next.getFirstChildWithName(new QName("gram.endpoint")).getText());
                ((GlobusHostType) hostDescription.getType()).addGridFTPEndPoint(next.getFirstChildWithName(new QName("gridftp.endpoint")).getText());
            } else if("ssh".equals(next.getFirstChildWithName(new QName("type")).getText())) {
                hostDescription.getType().changeType(SSHHostType.type);
                if(next.getFirstChildWithName(new QName("hpc.resource")) != null){
                    if("true".equals(next.getFirstChildWithName(new QName("gram.endpoint")))){
                        ((SSHHostType) hostDescription.getType()).setHpcResource(true);
                    }
                }
                ((SSHHostType) hostDescription.getType()).setHpcResource(false);
            } else if("gsissh".equals(next.getFirstChildWithName(new QName("type")).getText())) {
                hostDescription.getType().changeType(GsisshHostType.type);
            }
            (hostDescription.getType()).setHostName(next.getFirstChildWithName(new QName("name")).getText());
            (hostDescription.getType()).setHostAddress(next.getFirstChildWithName(new QName("host")).getText());
            hostDescriptions.add(hostDescription);
        }
        return hostDescriptions;
    }
View Full Code Here

  }

  private void setupDescriptors() throws AiravataAPIInvocationException,
      DescriptorAlreadyExistsException, IOException {
    DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();
    HostDescription hostDescription = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost2",
                "127.0.0.1");

        log("Adding host description ....");
        airavataAPI.getApplicationManager().addHostDescription(hostDescription);
        Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(hostDescription.getType().getHostName()));
       
        List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
        inputParameters.add(descriptorBuilder.buildInputParameterType("data1", "data1", DataType.STRING));
        inputParameters.add(descriptorBuilder.buildInputParameterType("data2", "data2", DataType.STRING));

        List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
        outputParameters.add(descriptorBuilder.buildOutputParameterType("out", "out", DataType.STD_OUT));

        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("comma_app", "comma_app",
                inputParameters, outputParameters);
       
        ServiceDescription serviceDescription2 = descriptorBuilder.buildServiceDescription("echo_app", "echo_app",
                inputParameters, outputParameters);

        log("Adding service description ...");
        airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription.getType().getName()));
       
        airavataAPI.getApplicationManager().addServiceDescription(serviceDescription2);
        Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(
                serviceDescription2.getType().getName()));

        // Deployment descriptor
        File executable;
        if(OsUtils.isWindows()) {
          executable = getFile("src/test/resources/comma_data.bat");
        } else {
          executable = getFile("src/test/resources/comma_data.sh");
          Runtime.getRuntime().exec("chmod +x "+executable.getAbsolutePath());
        }
       
    ApplicationDescription applicationDeploymentDescription = descriptorBuilder
                .buildApplicationDeploymentDescription("comma_app_localhost", executable.getAbsolutePath(), OsUtils.getTempFolderPath());
    ApplicationDescription applicationDeploymentDescription2 = descriptorBuilder
                .buildApplicationDeploymentDescription("echo_app_localhost", OsUtils.getEchoExecutable(), OsUtils.getTempFolderPath());

        log("Adding deployment description ...");
        airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription, hostDescription,
                applicationDeploymentDescription);

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription.getType().getApplicationName().getStringValue()));
       
        airavataAPI.getApplicationManager().addApplicationDescription(serviceDescription2, hostDescription,
                applicationDeploymentDescription2);

        Assert.assertTrue(airavataAPI.getApplicationManager().isApplicationDescriptorExists(
                serviceDescription2.getType().getName(), hostDescription.getType().getHostName(),
                applicationDeploymentDescription2.getType().getApplicationName().getStringValue()));
  }
View Full Code Here

TOP

Related Classes of org.apache.airavata.commons.gfac.type.HostDescription

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.