public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName, String applicationName) throws RegistryException { Session session = null; List<ApplicationDeploymentDescription> result = new ArrayList<ApplicationDeploymentDescription>(); try { session = getSession(); Node deploymentNode = getDeploymentNode(session); Node serviceNode = deploymentNode.getNode(serviceName); Node hostNode = serviceNode.getNode(hostName); NodeIterator nodes = hostNode.getNodes(); for (; nodes.hasNext();) { Node app = nodes.nextNode(); Property prop = app.getProperty(XML_PROPERTY_NAME); ApplicationDeploymentDescription appDesc = ApplicationDeploymentDescription.fromXML(prop.getString()); if (appDesc.getType().getApplicationName().getStringValue().matches(applicationName)) { result.add(appDesc); } } } catch (PathNotFoundException e) { return result; } catch (Exception e) { throw new DeploymentDescriptionRetrieveException(e); } finally { closeSession(session); } return result; }
public void deleteDeploymentDescription(String serviceName, String hostName, String applicationName) throws RegistryException { Session session = null; try { session = getSession(); Node deploymentNode = getDeploymentNode(session); Node serviceNode = deploymentNode.getNode(serviceName); Node hostNode = serviceNode.getNode(hostName); NodeIterator nodes = hostNode.getNodes(); boolean found = false; for (; nodes.hasNext();) { Node app = nodes.nextNode(); Property prop = app.getProperty(XML_PROPERTY_NAME); ApplicationDeploymentDescription appDesc = ApplicationDeploymentDescription.fromXML(prop.getString()); if (appDesc.getType().getApplicationName().getStringValue().matches(applicationName)) { app.remove(); found = true; } } if (found) { session.save(); triggerObservers(this); } } catch (Exception e) { throw new DeploymentDescriptionRetrieveException(e); } finally { closeSession(session); } }
public String saveDeploymentDescription(String serviceId, String hostId, ApplicationDeploymentDescription app) { Session session = null; String result = null; try { session = getSession(); Node deployNode = getDeploymentNode(session); Node serviceNode = getOrAddNode(deployNode, serviceId); Node hostNode = getOrAddNode(serviceNode, hostId); Node appName = getOrAddNode(hostNode, app.getType().getApplicationName().getStringValue()); appName.setProperty(XML_PROPERTY_NAME, app.toXML()); session.save(); result = appName.getIdentifier(); triggerObservers(this); } catch (Exception e) { System.out.println(e); e.printStackTrace(); // TODO propagate } finally { closeSession(session); } return result; }
+ appDesc.getApplicationName().getStringValue() + "_" + date + "_" + UUID.randomUUID(); + appDesc.getApplicationName().getStringValue() + ".stdout"); + appDesc.getApplicationName().getStringValue() + ".stderr");
public static ApplicationDescriptor createApplicationDescriptor (ApplicationDescription applicationDescription){ ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(); applicationDescriptor.setName(applicationDescription.getType().getApplicationName().getStringValue()); applicationDescriptor.setExecutablePath(applicationDescription.getType().getExecutableLocation()); applicationDescriptor.setWorkingDir(applicationDescription.getType().getScratchWorkingDirectory());