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 RequiredPortInstance findClientPort(Deployment container) { final InternalComponentInstance client = findClient(container); final RequiredPort portType = client.getType().getRequiredPorts().firstNamed(clientPort); if(portType == null){ final String error = String.format("Unable to find the required port type '%s'", clientPort); throw new IllegalStateException(error); } final RequiredPortInstance port = client.getRequiredPorts().ofType(portType); if (port == null) { final String error = String.format("Unable to find the required port instance '%s' in '%s'", clientPort, client); throw new IllegalStateException(error); } return port; }
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)); } } }
public LocalRequiredPortInstanceGroup(Collection<RequiredPortInstance> content) { super(); for (RequiredPortInstance instance : content) { super.add(instance); instance.getOwner().set(InternalComponentInstance.this); } }
/** * 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 internalComponentInstanceToKmf(InternalComponentInstance ici) { checkNull(ici, "Cannot convert null"); net.cloudml.core.InternalComponentInstance kai = factory.createInternalComponentInstance(); kai.setName(ici.getName()); kai.setType(internalComponents.get(ici.getType().getName())); convertProperties(ici, kai, factory); this.internalComponentInstances.put(kai.getName(), kai); initRequiredExecutionPlatformInstance(ici, kai); initProvidedExecutionPlatformInstances(ici, kai); convertAndAddRequiredPortInstances(ici.getRequiredPorts().toList(), kai); convertAndAddProvidedPortInstances(ici.getProvidedPorts().toList(), kai); kDeploy.addInternalComponentInstances(kai); }
if (bi.getRequiredEnd().getType().isMandatory() && x.getRequiredPorts().contains(bi.getRequiredEnd())) { final ComponentInstance<? extends Component> serverComponent = bi.getServerComponent(); if( getDestination(serverComponent).isVM()){
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); }
.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())