@Override public boolean remove(Object o) { Boolean b=super.remove(o); if (b && o instanceof ComponentInstance) { final ComponentInstance<? extends Component> instance = (ComponentInstance<? extends Component>) o; instance.getOwner().discard(); } return b; } }
public boolean replace(T element){ if (firstNamed(element.getName()) != null) { super.remove(element); } element.getOwner().set(Deployment.this); return super.add(element); }
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); }
private static Model getModelUpdates(ComponentInstanceGroup instances, ProviderGroup providers) { Model model = new Model(); //go top down to remove the synched ones //prepare the VMs list VMInstanceGroup VMs = instances.onlyVMs(); for (VMInstance i : VMs) { String location = i.getType().getLocation(); if(!location.isEmpty()) { model.add(fromCloudmlToModaMP(location)); } model.add(fromCloudmlToModaMP(i)); instances.remove(i); } //prepare the InternalComponents list InternalComponentInstanceGroup internalComponents = instances.onlyInternals(); for (InternalComponentInstance i : internalComponents) { model.add(fromCloudmlToModaMP(i)); instances.remove(i); } //prepare for providers list if(providers!=null){ for (Provider i : providers) { model.add(fromCloudmlToModaMP(i)); instances.remove(i); } } return model; }
@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; }