/** * Search for a binding type whose name matches a given id * * @param id of a binding type * @return the binding type with the given id or null */ private Binding findBindingTypeById(final String id) { for (Binding t : deploy.getBindingTypes().values()) { if (t.getName().equals(id)) { return t; } } return null; } }
kb.setName(b.getName()); kb.setClient(clientPorts.get(b.getClient().getName())); kb.setServer(serverPorts.get(b.getServer().getName())); if (b.getClientResource() != null) { net.cloudml.core.Resource cr = factory.createResource(); cr.setName(b.getClientResource().getName()); if (b.getClientResource().getDeployingResourceCommand() != null) { cr.setDeployingCommand(b.getClientResource().getDeployingResourceCommand()); if (b.getClientResource().getRetrievingResourceCommand() != null) { cr.setRetrievingCommand(b.getClientResource().getRetrievingResourceCommand()); if (b.getClientResource().getConfigurationResourceCommand() != null) { cr.setConfigurationCommand(b.getClientResource().getConfigurationResourceCommand()); if (b.getClientResource().getStartResourceCommand() != null) { cr.setStartCommand(b.getClientResource().getStartResourceCommand()); if (b.getClientResource().getStopResourceCommand() != null) { cr.setStopCommand(b.getClientResource().getStopResourceCommand()); if (b.getServerResource() != null) { net.cloudml.core.Resource cr = factory.createResource(); cr.setName(b.getServerResource().getName()); if (b.getServerResource().getDeployingResourceCommand() != null) { cr.setDeployingCommand(b.getServerResource().getDeployingResourceCommand()); if (b.getServerResource().getRetrievingResourceCommand() != null) {
if(b.getName().equals(nodeType)){ BindingInstance bi=b.instanciates(nodeType+cnt); dm.getBindingInstances().add(bi); Edge edge; if(b.getClient().getIsOptional()) edge=new Edge(nodeType+cnt, "optional"); else edge=new Edge(nodeType+cnt, "mandatory");
Binding b = new Binding(clientPorts.get(kb.getClient().getName()), serverPorts.get(kb.getServer().getName())); b.setName(kb.getName()); if (kb.getClientResource() != null) { Resource cr = new Resource(kb.getClientResource().getName()); cr.setStopCommand(kb.getClientResource().getStopCommand()); b.setClientResource(cr); cr.setStopCommand(kb.getServerResource().getStopCommand()); b.setServerResource(cr); model.getBindingTypes().put(b.getName(), b); bindings.put(b.getName(), b);
private void unconfigureBinding(BindingInstance b) { if(b.getClient().getType().getIsRemote()){ ClientPortInstance client=b.getClient(); ServerPortInstance server=b.getServer(); Resource clientResource=b.getType().getClientResource(); Resource serverResource=b.getType().getServerResource(); //client resources unconfigureWithIP(clientResource,client); //server resources unconfigureWithIP(serverResource,server); } }
public String selectServerPortInstance(BindingInstance bi){ JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for(ArtefactInstance ai:dm.getArtefactInstances()){ for(ServerPortInstance ci:ai.getProvided()){ if(ci.getType().equals(bi.getType().getServer())){ model.addElement(ci); } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "ServerPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setServer((ServerPortInstance)comboBox.getSelectedItem()); return ((ServerPortInstance)comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
public String selectClientPortInstance(BindingInstance bi){ JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for(ArtefactInstance ai:dm.getArtefactInstances()){ System.out.println(ai.getRequired()); for(ClientPortInstance ci:ai.getRequired()){ System.out.println(bi.getType().getClient() + " #### "+ ci.getType()); if(ci.getType().equals(bi.getType().getClient())){ model.addElement(ci); } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "ClientPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setClient((ClientPortInstance)comboBox.getSelectedItem()); return ((ClientPortInstance)comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
/** * Configure Artefacts according to the bindings * @param dm a deployment model * @throws MalformedURLException */ private void configureWithBindings(List<BindingInstance> bindings) { //Configure on the basis of the bindings //parameters transmitted to the configuration scripts are "ip ipDestination portDestination" for(BindingInstance bi : bindings){ if(bi.getClient().getType().getIsRemote()){ ClientPortInstance client=bi.getClient(); ServerPortInstance server=bi.getServer(); Resource clientResource=bi.getType().getClientResource(); Resource serverResource=bi.getType().getServerResource(); String destinationIpAddress=server.getOwner().getDestination().getPublicAddress(); int destinationPortNumber=server.getType().getPortNumber(); String ipAddress=client.getOwner().getDestination().getPublicAddress(); //client resources configureWithIP(clientResource,client,destinationIpAddress,ipAddress,destinationPortNumber); //server resources configureWithIP(serverResource,server,destinationIpAddress,ipAddress,destinationPortNumber); } } }
public DefaultListModel fillList(){ DefaultListModel lm=new DefaultListModel(); for(Node n:dmodel.getNodeTypes().values()){ lm.addElement(n.getName()); } for(Artefact n:dmodel.getArtefactTypes().values()){ lm.addElement(n.getName()); } for(Binding b:dmodel.getBindingTypes().values()){ lm.addElement(b.getName()); } return lm; }