@Override public void validate(Report report) { if (getOwner().isUndefined()) { report.addError("Client port instance has no owner"); } }
public WarXmlConfigValet(RelationshipInstance relationshipInstance, Resource configResource){ this.relationshipInstance = relationshipInstance; this.warCompInst = relationshipInstance.getRequiredEnd().getOwner().get(); this.configResource = configResource; }
public LocalRequiredPortInstanceGroup(Collection<RequiredPortInstance> content) { super(); for (RequiredPortInstance instance : content) { super.add(instance); instance.getOwner().set(InternalComponentInstance.this); } }
public InternalComponentInstance getClientComponent() { return (InternalComponentInstance) getRequiredEnd().getOwner().get(); }
public String selectClientPortInstance(RelationshipInstance bi) { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ComponentInstance ai : dm.getComponentInstances()) { if (ai instanceof InternalComponentInstance) { for (RequiredPortInstance ci : ((InternalComponentInstance) ai).getRequiredPorts()) { System.out.println(bi.getType().getRequiredEnd() + " #### " + ci.getType()); if (ci.getType().equals(bi.getType().getRequiredEnd())) { model.addElement(ci); } } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "RequiredPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setRequiredEnd((RequiredPortInstance) comboBox.getSelectedItem()); return ((RequiredPortInstance) comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
private LocalRequiredPortInstanceGroup instantiateAllRequiredPorts(InternalComponent type) { final RequiredPortInstanceGroup instances = new RequiredPortInstanceGroup(); for (RequiredPort port : type.getRequiredPorts()) { final RequiredPortInstance instance = port.instantiate(); instance.getOwner().set(this); instances.add(instance); } return new LocalRequiredPortInstanceGroup(instances); }
private void addRelationships() { addedRelationships = new ArrayList<RelationshipInstance>(targetDM.getRelationshipInstances()); addedRelationships.removeAll(matchingRelationships.values()); for (RelationshipInstance ni : addedRelationships) { int i = currentDM.getComponentInstances().toList().indexOf(ni.getRequiredEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); if (a.isInternal()) { int j = ((InternalComponentInstance) a).getRequiredPorts().toList().indexOf(ni.getRequiredEnd()); ni.setRequiredEnd(((InternalComponentInstance) a).getRequiredPorts().toList().get(j)); } } i = currentDM.getComponentInstances().toList().indexOf(ni.getProvidedEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); int j = a.getProvidedPorts().toList().indexOf(ni.getProvidedEnd()); List<ProvidedPortInstance> l = a.getProvidedPorts().toList(); ni.setProvidedEnd(l.get(j)); } } }
private Boolean isPaaS2PaaS(RelationshipInstance bi){ if(bi.getRequiredEnd().getOwner().get().isInternal()){ if(bi.getProvidedEnd().getOwner().get().isInternal()){ if(!bi.getRequiredEnd().getOwner().get().asInternal().externalHost().isVM() && !bi.getProvidedEnd().getOwner().get().asInternal().externalHost().isVM()){ return true; } } } return false; }
public void internalComponentInstanceToPOJO(net.cloudml.core.InternalComponentInstance kInternalComponentInstance) { checkForNull(kInternalComponentInstance, "Cannot convert null!"); InternalComponentInstance ai = new InternalComponentInstance(kInternalComponentInstance.getName(), internalComponents.get(kInternalComponentInstance.getType().getName())); convertProperties(kInternalComponentInstance, ai); internalComponentInstances.put(ai.getName(), ai); initRequiredExecutionPlatformInstance(kInternalComponentInstance, ai); initProvidedExecutionPlatformInstances(kInternalComponentInstance, ai); //TODO: destination convertAndAddProvidedPortInstances(kInternalComponentInstance.getProvidedPortInstances(), ai); RequiredPortInstanceGroup rpig=new RequiredPortInstanceGroup(); for (net.cloudml.core.RequiredPortInstance kapi: kInternalComponentInstance.getRequiredPortInstances()) { RequiredPortInstance api = new RequiredPortInstance(kapi.getName(), requiredPorts.get(ai.getType().getName() + "_" + kapi.getType().getName())); api.getOwner().set(ai); convertProperties(kapi, api); //ai.getRequiredPorts().add(api); rpig.add(api); requiredPortInstances.put(api.getName(), api); } ai.setRequiredPorts(rpig); model.getComponentInstances().add(ai); }
@Override public Void applyTo(Deployment deployment) { if (!clientPort.isBound()) { final Relationship bindingType = getLibrary().findRelationshipFor(deployment, clientPort); final String name = getLibrary().createUniqueRelationshipInstanceName(deployment, bindingType); final ProvidedPortInstance serverPort = getLibrary().findProvidedPortFor(deployment, bindingType); if(bindingType == null){ throw new IllegalStateException("No type of relationship found for the client port: "+clientPort.getQualifiedName()); } if(serverPort == null){ throw new IllegalStateException("No Server port for the client port: "+clientPort.getQualifiedName()); } aRelationshipInstance() .named(name) .from(clientPort.getOwner().getName(), clientPort.getType().getName()) .to(serverPort.getOwner().getName(), serverPort.getType().getName()) .ofType(bindingType.getName()) .integrateIn(deployment); } return NOTHING; }
ComponentInstance clienti = bi.getRequiredEnd().getOwner().get(); if (serveri.isExternal() && "database".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For DB for (Resource res : bi.getType().getResources()) { PaaSConnector connector = ConnectorFactory.createPaaSConnector(p); String alias = res.getProperties().valueOf("db-binding-alias"); connector.bindDbToApp(bi.getRequiredEnd().getOwner().getName(), bi.getProvidedEnd().getOwner().getName(), alias); coordinator.updateStatus(bi.getProvidedEnd().getOwner().get().getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName()); }catch(Exception ex){ VMInstance ownerVMClient = (VMInstance) getDestination(clientInternal.getOwner().get()); VM VMClient = ownerVMClient.getType(); jcClient = ConnectorFactory.createIaaSConnector(VMClient.getProvider()); String ipAddress = getDestination(clientInternal.getOwner().get()).getPublicAddress(); if(clientResource == null) return; // ignore configuration if there is no resource at all
/** * Find the destination of an ComponentInstance * * @param a an instance of component * @return a VMInstance */ private ExternalComponentInstance findDestinationWhenNoRequiredExecutionPlatformSpecified(InternalComponentInstance a) { if (getDestination(a) != null) { return getDestination(a); } else { for (RelationshipInstance b : currentModel.getRelationshipInstances()) { if (a.getRequiredPorts().contains(b.getRequiredEnd()) && b.getRequiredEnd().getType().isLocal()) { return getDestination(b.getProvidedEnd().getOwner().get()); } if (a.getProvidedPorts().contains(b.getProvidedEnd()) && b.getProvidedEnd().getType().isLocal()) { return getDestination(b.getRequiredEnd().getOwner().get()); } } return null; } }
public void drawEdgesFromDeploymentModel(Deployment dm, ArrayList<Vertex> v) { for (ComponentInstance x : dm.getComponentInstances()) { if (x instanceof InternalComponentInstance) { InternalComponentInstance ix = (InternalComponentInstance) x; if (ix.getRequiredExecutionPlatform() != null) { Vertex v1 = findVertex(ix.getName(), v); Vertex v2 = findVertex(ix.getRequiredExecutionPlatform().getName(), v); Edge e = new Edge("dest" + ix.getName(), "destination"); createEdge(e, v1, v2); } }//TODO else } for (RelationshipInstance bi : dm.getRelationshipInstances()) { Vertex v1 = findVertex(bi.getRequiredEnd().getOwner().getName(), v); Vertex v2 = findVertex(bi.getProvidedEnd().getOwner().getName(), v); Edge e; if (!bi.getRequiredEnd().getType().isMandatory()) { e = new Edge(bi.getName(), "optional", bi); } else { e = new Edge(bi.getName(), "mandatory", bi); } createEdge(e, v1, v2); } }