private InternalComponentInstance findClient(Deployment container) throws IllegalStateException { final InternalComponentInstance clientComponent = container.getComponentInstances().onlyInternals().firstNamed(client); if (clientComponent == null) { final String error = String.format("Unable to find the internal component instance '%s'", client); throw new IllegalStateException(error); } return clientComponent; } }
public InternalComponentInstanceGroup hostedOn(ComponentInstance<? extends Component> host) { InternalComponentInstanceGroup selection = new InternalComponentInstanceGroup(); for (InternalComponentInstance instance: this) { if (instance.isHostedBy(host)) { selection.add(instance); } } 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); } } }
private void visitPuppetResources(ComponentInstance ci){ InternalComponentInstanceGroup icig= currentModel.getComponentInstances().onlyInternals().hostedOn(ci); if(icig !=null){ for(ComponentInstance c : icig){ InternalComponentInstance ici; PuppetResource pr=findPuppetResource(c); if(pr != null) manifest+=pr.getManifestEntry()+System.lineSeparator(); visitPuppetResources(c); } } }
public net.cloudml.core.CloudMLModel toKMF(Deployment deploy) { kDeploy.setName(deploy.getName()); convertProperties(deploy,kDeploy,factory); providersToKmf(deploy.getProviders().toList()); externalComponentToKmf(deploy.getComponents().onlyExternals().toList()); internalComponentsToKmf(deploy.getComponents().onlyInternals().toList()); externalComponentInstanceToKmf(deploy.getComponentInstances().onlyExternals().toList()); internalComponentInstancesToKmf(deploy.getComponentInstances().onlyInternals().toList()); executesToKmf(deploy.getExecuteInstances().toList()); relationshipsToKmf(deploy.getRelationships()); relationshipInstancesToKmf(deploy.getRelationshipInstances().toList()); return kDeploy; }
public InternalComponentInstanceGroup clientComponents() { if (getOwner().isUndefined()) { return new InternalComponentInstanceGroup(); } return getDeployment().getRelationshipInstances().clientsOf(this); }
public boolean isHosting(InternalComponentInstance component) { return hostedComponents().contains(component); }
public void internalComponentInstancesToPOJO(List<net.cloudml.core.InternalComponentInstance> componentInstances) { int counter = 0; for (net.cloudml.core.InternalComponentInstance ici: componentInstances) { internalComponentInstanceToPOJO((net.cloudml.core.InternalComponentInstance) ici); counter++; } assert counter == model.getComponentInstances().onlyInternals().size(); assert counter == internalComponentInstances.size(); }
private void migrateAllHostedComponents(Deployment deployment) { final InternalComponentInstanceGroup hosted = deployment.getComponentInstances().onlyInternals().hostedOn(artefactInstance); for (InternalComponentInstance hostedComponent: hosted) { getLibrary().migrate(deployment, hostedComponent); } }
public InternalComponentInstanceGroup hostedComponents() { if (getOwner().isUndefined()) { return new InternalComponentInstanceGroup(); } return getDeployment().getExecuteInstances().componentsHostedBy(this); }
public InternalComponentInstanceGroup componentsHostedBy(ComponentInstance<? extends Component> host) { final InternalComponentInstanceGroup selection = new InternalComponentInstanceGroup(); for (ExecuteInstance execution: this) { if (execution.isHostedBy(host)) { selection.add(execution.getSubject()); } } return selection; }
@Override public void handle(ViewComponentInstance command) { if (isDeploymentLoaded()) { final ComponentInstance instance = deploy.getComponentInstances().onlyInternals().firstNamed(command.getComponentId()); if (instance == null) { final String text = String.format("No artefact instance with ID \"%s\"", command.getComponentId()); final Message message = new Message(command, Category.ERROR, text); dispatch(message); } else { final ComponentInstanceData data = new ComponentInstanceData(command, instance); dispatch(data); } } else { reportNoDeploymentLoaded(command); } }
@Override public Void applyTo(Deployment deployment) { final InternalComponentInstanceGroup hosted = deployment.getComponentInstances().onlyInternals().hostedOn(instance); for(InternalComponentInstance hostedComponent: hosted) { getLibrary().migrate(deployment, hostedComponent); } getLibrary().stop(deployment, instance); deployment.getComponentInstances().remove(instance); return NOTHING; }
public InternalComponentInstanceGroup onlyInternals() { final InternalComponentInstanceGroup internalInstances = new InternalComponentInstanceGroup(); for (final T instance: this) { if (instance.isInternal()) { internalInstances.add(instance.asInternal()); } } return internalInstances; }
@Override public InternalComponentInstance applyTo(Deployment target) { final String instanceName = getLibrary().createUniqueComponentInstanceName(target, type); InternalComponentInstanceBuilder builder = anInternalComponentInstance() .named(instanceName) .ofType(type.getName()) .hostedBy(host.getName()); builder.integrateIn(target); InternalComponentInstance instance = target.getComponentInstances().onlyInternals().firstNamed(instanceName); resolveDependencies(target, instance); return instance; }
public InternalComponentInstanceGroup clientsOf(ComponentInstance<? extends Component> server) { final InternalComponentInstanceGroup selection = new InternalComponentInstanceGroup(); for (RelationshipInstance relationship: this) { if (relationship.isProvidedBy(server)) { selection.add(relationship.getClientComponent()); } } return selection; } }
@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; }