@SuppressWarnings("unchecked") public final InternalComponentInstance asInternal() { if (isExternal()) { throw new IllegalStateException("Unable to convert an external component instance into an internal one"); } return (InternalComponentInstance) this; }
public ExternalComponentInstanceGroup onlyExternals() { final ExternalComponentInstanceGroup externalInstances = new ExternalComponentInstanceGroup(); for (final T instance: this) { if (instance.isExternal()) { externalInstances.add(instance.asExternal()); } } return externalInstances; }
/** * Extract the tag that can be identified on the given component instance. * * @param componentInstance the component whose tags are needed * @param tagged the already initialised maps of tags, to be filled in */ private void extractTags(ComponentInstance componentInstance, Map<String, List<String>> tagged) { assert componentInstance != null: "Unable to extract tags from 'null'"; assert !tagged.isEmpty(): "The map of tag must have been initialized"; if (componentInstance.isExternal()) { tagged.get(EXTERNAL.getLabel()).add(componentInstance.getName()); if (componentInstance.asExternal().isVM()) { tagged.get(VM.getLabel()).add(componentInstance.getName()); } } if (componentInstance.isInternal()) { tagged.get(INTERNAL.getLabel()).add(componentInstance.getName()); } if (isService(componentInstance)) { tagged.get(SERVICE.getLabel()).add(componentInstance.getName()); } else { tagged.get(NOT_SERVICE.getLabel()).add(componentInstance.getName()); } }
public VMInstanceGroup onlyVMs() { final VMInstanceGroup selection = new VMInstanceGroup(); for (final T instance: this) { if (instance.isExternal()) { final ExternalComponentInstance<? extends ExternalComponent> external = instance.asExternal(); if (external.isVM()) { selection.add(external.asVM()); } } } return selection; }
private void allHosted(ComponentInstance ci, Deployment target){ InternalComponentInstanceGroup icig= currentModel.getComponentInstances().onlyInternals().hostedOn(ci); if(icig !=null){ hostedGroup.addAll(icig); for(ComponentInstance c : icig){ InternalComponentInstance ici; if(ci.isExternal()) ici=getLibrary().replicateComponentInstance(target, c, host).asInternal(); else ici=getLibrary().replicateComponentInstance(target, c, mapping.get(ci)).asInternal(); mapping.put(c.asInternal(), ici); allHosted(c, target); } } }
public String toString(){ String result=" Component instances:\n"; for(ComponentInstance c: components){ if(c.isExternal()){ if(c.asExternal().isVM()){ result+=" VM-> "+c.asExternal().asVM().getId()+"::"+c.getName()+"\n"; }else{ result+=" External component-> "+c.getQualifiedName()+"\n"; } }else{ result+=" Instance component-> "+c.getQualifiedName()+"\n"; } } return result; } }
ComponentInstance serveri = bi.getProvidedEnd().getOwner().get(); ComponentInstance clienti = bi.getRequiredEnd().getOwner().get(); if (serveri.isExternal() && "database".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For DB for (Resource res : bi.getType().getResources()) { ConfigValet valet = ConfigValet.createValet(bi, res); if(pltfi.isExternal()){ ExternalComponent pltf = (ExternalComponent) pltfi.getType(); if(!pltf.isVM()){ else if (serveri.isExternal() && "loadbalancer".equals(((ExternalComponentInstance<ExternalComponent>) serveri).getType().getServiceType())) { //For Loadbalancer String endpoint = serveri.getType().asExternal().getEndPoint(); if(endpoint==null){ if(clienti.isExternal()){ ExternalComponentInstance<ExternalComponent> exclienti = ((ExternalComponentInstance) clienti); ipAddress = exclienti.getPublicAddress();
@Override public ComponentInstance applyTo(Deployment target) { ComponentInstance result=null; if(instance.isInternal()){ final String instanceName = getLibrary().createUniqueComponentInstanceName(target, instance.asInternal().getType()); InternalComponentInstanceBuilder builder = anInternalComponentInstance() .named(instanceName) .ofType(instance.asInternal().getType().getName()) .hostedBy(host.getName()); builder.integrateIn(target); result = target.getComponentInstances().onlyInternals().firstNamed(instanceName); } if(instance.isExternal()){ result=getLibrary().provision(target, instance.getType()); } return result; }