public ComponentInstance<? extends Component> getHost() { if (getOwner().isUndefined()) { return null; } return getDeployment().getExecuteInstances().hostOf(this); }
@Override public InternalComponentInstance applyTo(Deployment deployment) { final ComponentInstance<? extends Component> newHost = getLibrary().findAlternativeDestinationFor(deployment, instance); final ExecuteInstance execution = deployment.getExecuteInstances().withSubject(instance); assert execution != null: String.format("There should be an execute instance whose required end points to '%s'", instance.getName()); deployment.getExecuteInstances().remove(execution); deployment.deploy(instance, newHost); return instance; }
/** * Update the currentModel with the targetModel and preserve all the CPSM * metadata * * @param diff a model comparator */ public void updateCurrentModel(CloudMLModelComparator diff) { if (diff != null) { currentModel.getComponents().addAll(targetModel.getComponents()); currentModel.getRelationships().addAll(targetModel.getRelationships()); currentModel.getComponentInstances().removeAll(diff.getRemovedComponents()); currentModel.getRelationshipInstances().removeAll(diff.getRemovedRelationships()); currentModel.getComponentInstances().removeAll(diff.getRemovedECs().keySet()); currentModel.getExecuteInstances().removeAll(diff.getRemovedExecutes()); alreadyDeployed.removeAll(diff.getRemovedComponents()); alreadyStarted.removeAll(diff.getRemovedComponents()); currentModel.getComponentInstances().replaceAll(diff.getAddedComponents()); currentModel.getRelationshipInstances().replaceAll(diff.getAddedRelationships()); currentModel.getComponentInstances().replaceAll(diff.getAddedECs()); currentModel.getExecuteInstances().replaceAll(diff.getAddedExecutes()); } else { throw new IllegalArgumentException("Cannot update current model without comparator!"); } }
@Override public boolean add(ExecuteInstance e) { e.getOwner().set(Deployment.this); return super.add(e); }
public Deployment merge(String path){ InputStream instream = null; try { instream = new FileInputStream(path); } catch (FileNotFoundException e) { e.printStackTrace(); } Deployment target = (Deployment) new JsonCodec().load(instream); if (isDeploymentLoaded()) { deploy.getComponents().replaceAll(target.getComponents()); deploy.getRelationships().replaceAll(target.getRelationships()); //TODO: Check if names are unique deploy.getComponentInstances().replaceAll(target.getComponentInstances()); deploy.getExecuteInstances().replaceAll(target.getExecuteInstances()); deploy.getProviders().replaceAll(target.getProviders()); deploy.getRelationshipInstances().replaceAll(target.getRelationshipInstances()); }else{ deploy=target; } initCoordinator(); return deploy; }
@Override public boolean remove(Object o) { if (o instanceof ExecuteInstance) { ((ExecuteInstance) o).getOwner().discard(); } return super.remove(o); } }
public InternalComponentInstanceGroup hostedComponents() { if (getOwner().isUndefined()) { return new InternalComponentInstanceGroup(); } return getDeployment().getExecuteInstances().componentsHostedBy(this); }
public Deployment clone(){ Deployment tmp=new Deployment(); tmp.getComponents().addAll(this.getComponents()); tmp.getComponentInstances().addAll(this.getComponentInstances()); tmp.getExecuteInstances().addAll(this.getExecuteInstances()); tmp.getProviders().addAll(this.getProviders()); tmp.getRelationshipInstances().addAll(this.getRelationshipInstances()); tmp.getClouds().addAll(this.getClouds()); tmp.getRelationships().addAll(this.getRelationships()); tmp.setName(this.getName()); return tmp; }
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; }
private void saveMetadata(Deployment deploy2) { if (isDeploymentLoaded()) { diff = new CloudMLModelComparator(deploy, deploy2); diff.compareCloudMLModel(); deploy.setName(deploy2.getName()); deploy.getComponents().addAll(deploy2.getComponents()); deploy.getRelationships().addAll(deploy2.getRelationships()); deploy.getRelationshipInstances().removeAll(diff.getRemovedRelationships()); deploy.getExecuteInstances().removeAll(diff.getRemovedExecutes()); deploy.getComponentInstances().removeAll(diff.getRemovedECs().keySet()); deploy.getComponentInstances().removeAll(diff.getRemovedComponents()); deploy.getRelationshipInstances().replaceAll(diff.getAddedRelationships()); deploy.getComponentInstances().replaceAll(diff.getAddedECs()); deploy.getExecuteInstances().replaceAll(diff.getAddedExecutes()); deploy.getComponentInstances().replaceAll(diff.getAddedComponents()); } else { deploy = deploy2; } }
public void executeInstanceToPOJO(net.cloudml.core.ExecuteInstance kei) { if (kei != null) { ExecuteInstance ei = new ExecuteInstance(kei.getName(), requiredExecutionPlatformInstances.get(kei.getRequiredExecutionPlatformInstance().getName()), providedExecutionPlatformInstances.get(kei.getProvidedExecutionPlatformInstance().getName())); model.getExecuteInstances().add(ei); } }
public void deploy(InternalComponentInstance component, ComponentInstance<? extends Component> host) { final ProvidedExecutionPlatformInstance platform = host.getProvidedExecutionPlatforms().firstMatchFor(component); if (platform == null) { final String error = String.format( "Unable to deploy! '%s' does not provide any execution platform that suits '%s' (candidates are: %s)", host.getQualifiedName(), component.getRequiredExecutionPlatform().getQualifiedName(), host.getProvidedExecutionPlatforms().onlyNames().toString()); throw new IllegalArgumentException(error); } final ExecuteInstance execute = new ExecuteInstance(ModelUtils.generateUniqueName("runOn"),component, platform); executeInstances.add(execute); }
private void shutdownInternalComponentInstance(Deployment target) { getLibrary().stop(target, artefactInstance); final ExecuteInstance execution = target.getExecuteInstances().withSubject(artefactInstance); assert execution != null: String.format("There should be an execute instance whose required end points to '%s'", artefactInstance.getName()); target.getExecuteInstances().remove(execution); target.getComponentInstances().remove(artefactInstance); }