public WarXmlConfigValet(RelationshipInstance relationshipInstance, Resource configResource){ this.relationshipInstance = relationshipInstance; this.warCompInst = relationshipInstance.getRequiredEnd().getOwner().get(); this.configResource = configResource; }
public InternalComponentInstance getClientComponent() { return (InternalComponentInstance) getRequiredEnd().getOwner().get(); }
@Override public boolean equals(Object other) { if (other instanceof RelationshipInstance) { RelationshipInstance otherBinding = (RelationshipInstance) other; return ( ((requiredEnd == null && otherBinding.getRequiredEnd() == null) || requiredEnd.equals(otherBinding.getRequiredEnd())) && ((providedEnd == null && otherBinding.getProvidedEnd() == null) || providedEnd.equals(otherBinding.getProvidedEnd())) ); } else { return false; } } }
public List<RequiredPortInstance> findClients() { final RelationshipInstanceGroup relationships = getDeployment().getRelationshipInstances().whereEitherEndIs(this); if (relationships.isEmpty()) { final String message = String.format("provided port '%s' is not yet bound to any client", getQualifiedName()); throw new IllegalArgumentException(message); } final List<RequiredPortInstance> clients = new ArrayList<RequiredPortInstance>(); for (RelationshipInstance relationship : relationships) { clients.add(relationship.getRequiredEnd()); } return clients; }
public boolean eitherEndIs(PortInstance<? extends Port> port) { return getProvidedEnd().equals(port) || getRequiredEnd().equals(port); }
private void unconfigureRelationship(RelationshipInstance b) { if (!b.getRequiredEnd().getType().isLocal()) { RequiredPortInstance client = b.getRequiredEnd(); ProvidedPortInstance server = b.getProvidedEnd(); Resource clientResource = b.getType().getClientResource(); Resource serverResource = b.getType().getServerResource(); //client resources unconfigureWithIP(clientResource, client); //server resources unconfigureWithIP(serverResource, server); } }
public void relationshipInstanceToKmf(RelationshipInstance ri) { checkNull(ri, "Cannot convert null"); net.cloudml.core.RelationshipInstance kb = factory.createRelationshipInstance(); kb.setName(ri.getName()); checkValidPortInstance(ri.getRequiredEnd()); kb.setRequiredPortInstance(requiredPortInstances.get(escapePortInstanceName(ri.getRequiredEnd()))); checkValidPortInstance(ri.getProvidedEnd()); kb.setProvidedPortInstance(providedPortInstances.get(escapePortInstanceName(ri.getProvidedEnd()))); kb.setType(relationships.get(ri.getType().getName())); kDeploy.addRelationshipInstances(kb); }
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; }
/** * 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; } }
.named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName()) .named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(ri.getServerComponent().getName(), ri.getProvidedEnd().getType().getName()) .named(name) .from(ri.getClientComponent().getName(), ri.getRequiredEnd().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName())
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); } }
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){ RequiredPortInstance clientInternal = bi.getRequiredEnd(); ProvidedPortInstance server = bi.getProvidedEnd(); ExternalComponentInstance<ExternalComponent> exclienti = ((ExternalComponentInstance) clienti); ipAddress = exclienti.getPublicAddress(); port = String.valueOf(bi.getRequiredEnd().getType().getPortNumber()); port = String.valueOf(bi.getRequiredEnd().getType().getPortNumber()); coordinator.updateStatus(serveri.getName(), ComponentInstance.State.RUNNING, CloudAppDeployer.class.getName()); else if (bi.getRequiredEnd().getType().isRemote()) { RequiredPortInstance client = bi.getRequiredEnd(); ProvidedPortInstance server = bi.getProvidedEnd();
if (bi.getRequiredEnd().getType().isMandatory() && x.getRequiredPorts().contains(bi.getRequiredEnd())) { final ComponentInstance<? extends Component> serverComponent = bi.getServerComponent(); if( getDestination(serverComponent).isVM()){