/*
* App
*/
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("EchoLocal");
app.setExecutableLocation("/bin/echo");
app.setScratchWorkingDirectory(properties.getProperty("scratch.working.directory"));
app.setCpuCount(1);
ProjectAccountType projectAccountType = ((GramApplicationDeploymentType) appDesc.getType()).addNewProjectAccount();
projectAccountType.setProjectAccountNumber(properties.getProperty("allocation.charge.number"));
QueueType queueType = app.addNewQueue();
queueType.setQueueName(properties.getProperty("defualt.queue"));
app.setMaxMemory(100);
/*
* Service
*/
ServiceDescription serv = new ServiceDescription();
serv.getType().setName("SimpleEcho");
InputParameterType input = InputParameterType.Factory.newInstance();
ParameterType parameterType = input.addNewParameterType();
parameterType.setName("echo_input");
List<InputParameterType> inputList = new ArrayList<InputParameterType>();
inputList.add(input);
InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
.size()]);
OutputParameterType output = OutputParameterType.Factory.newInstance();
ParameterType parameterType1 = output.addNewParameterType();
parameterType1.setName("echo_output");
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
*/
jcrRegistry.getApplicationDescriptors(serv.getType().getName());
if(jcrRegistry.isHostDescriptorExists(host.getType().getHostName())) {
jcrRegistry.updateHostDescriptor(host);
} else {
jcrRegistry.addHostDescriptor(host);
}
if (jcrRegistry.isApplicationDescriptorExists(serv.getType().getName(),host.getType().getHostName(),appDesc.getType().getApplicationName().getStringValue())){
jcrRegistry.updateApplicationDescriptor(serv.getType().getName(), host.getType().getHostName(), appDesc);
} else {
jcrRegistry.addApplicationDescriptor(serv.getType().getName(), host.getType().getHostName(), appDesc);
}