import org.apache.airavata.common.registry.api.exception.RegistryException; import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription; import org.apache.airavata.commons.gfac.type.HostDescription; import org.apache.airavata.commons.gfac.type.ServiceDescription; import org.apache.airavata.migrator.registry.MigrationUtil; import org.apache.airavata.registry.api.AiravataRegistry; import org.apache.airavata.schemas.gfac.*; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class DescriptorRegistrationSample { public static void main(String[] args) { Map<String, String> config = new HashMap<String, String>(); config.put(org.apache.airavata.client.airavata.AiravataClient.MSGBOX,"http://localhost:8090/axis2/services/MsgBoxService"); config.put(org.apache.airavata.client.airavata.AiravataClient.BROKER, "http://localhost:8090/axis2/services/EventingService"); config.put(org.apache.airavata.client.airavata.AiravataClient.WORKFLOWSERVICEURL, "http://localhost:8090/axis2/services/WorkflowInterpretor?wsdl"); config.put(org.apache.airavata.client.airavata.AiravataClient.JCR, "http://localhost:8090/jackrabbit-webapp-2.4.0/rmi"); config.put(org.apache.airavata.client.airavata.AiravataClient.JCR_USERNAME, "admin"); config.put(org.apache.airavata.client.airavata.AiravataClient.JCR_PASSWORD, "admin"); config.put(org.apache.airavata.client.airavata.AiravataClient.GFAC, "http://localhost:8090/axis2/services/GFacService"); config.put(org.apache.airavata.client.airavata.AiravataClient.WITHLISTENER, "false"); config.put(org.apache.airavata.client.airavata.AiravataClient.TRUSTED_CERT_LOCATION, "/Users/Downloads/certificates"); org.apache.airavata.client.airavata.AiravataClient airavataClient = null; try { airavataClient = new org.apache.airavata.client.airavata.AiravataClient(config); } catch (MalformedURLException e) { e.printStackTrace(); } // Create Host Description HostDescription host = new HostDescription(); host.getType().changeType(GlobusHostType.type); host.getType().setHostName("gram"); host.getType().setHostAddress("gatekeeper2.ranger.tacc.teragrid.org"); ((GlobusHostType) host.getType()). setGridFTPEndPointArray(new String[]{"gsiftp://gridftp.ranger.tacc.teragrid.org:2811/"}); ((GlobusHostType) host.getType()). setGlobusGateKeeperEndPointArray(new String[]{"gatekeeper.ranger.tacc.teragrid.org:2119/jobmanager-sge"}); // Create Application Description ApplicationDeploymentDescription appDesc = new ApplicationDeploymentDescription(GramApplicationDeploymentType.type); GramApplicationDeploymentType app = (GramApplicationDeploymentType) appDesc.getType(); app.setCpuCount(1); app.setNodeCount(1); ApplicationDeploymentDescriptionType.ApplicationName name = appDesc.getType().addNewApplicationName(); name.setStringValue("EchoMPILocal"); app.setExecutableLocation("/home/path_to_executable"); app.setScratchWorkingDirectory("/home/path_to_temporary_directory"); app.setCpuCount(16); app.setJobType(MigrationUtil.getJobTypeEnum("MPI")); //app.setMinMemory(); ProjectAccountType projectAccountType = ((GramApplicationDeploymentType) appDesc.getType()).addNewProjectAccount(); projectAccountType.setProjectAccountNumber("XXXXXXXX"); // Create Service Description ServiceDescription serv = new ServiceDescription(); serv.getType().setName("MockPwscfMPIService"); InputParameterType input = InputParameterType.Factory.newInstance(); input.setParameterName("echo_input_name"); ParameterType parameterType = input.addNewParameterType(); parameterType.setType(DataType.Enum.forString("String")); parameterType.setName("String"); List<InputParameterType> inputList = new ArrayList<InputParameterType>(); inputList.add(input); InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList .size()]); OutputParameterType output = OutputParameterType.Factory.newInstance(); output.setParameterName("echo_mpi_output"); ParameterType parameterType1 = output.addNewParameterType(); parameterType1.setType(DataType.Enum.forString("String")); parameterType1.setName("String"); List<OutputParameterType> outputList = new ArrayList<OutputParameterType>(); outputList.add(output); OutputParameterType[] outputParamList = outputList .toArray(new OutputParameterType[outputList.size()]); serv.getType().setInputParametersArray(inputParamList); serv.getType().setOutputParametersArray(outputParamList); // Save to Registry if (airavataClient!=null) { System.out.println("Saving to Registry"); AiravataRegistry jcrRegistry = airavataClient.getRegistry(); try { jcrRegistry.saveHostDescription(host); jcrRegistry.saveServiceDescription(serv); jcrRegistry.saveDeploymentDescription(serv.getType().getName(), host.getType().getHostName(), appDesc); jcrRegistry.deployServiceOnHost(serv.getType().getName(), host.getType().getHostName()); } catch (RegistryException e) { e.printStackTrace(); } } System.out.println("DONE"); } }
Wednesday, July 4, 2012
Registering Application Descriptors using Airavata Client API
Following post demonstrates how to programmetically register;
1. Host
2. Application
3. Service descriptors using Apache Airavata Client API
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment