public ComponentInstanceGroup<T> hosting(InternalComponentInstance component) { final ComponentInstanceGroup<T> selected = new ComponentInstanceGroup<T>(); for (T instance: this) { if (instance.isHosting(component)) { selected.add(instance); } } return selected; }
public ComponentInstanceGroup<T> ofType(String typeName) { final ComponentInstanceGroup<T> selected = new ComponentInstanceGroup<T>(); for (T instance: this) { if (instance.getType().isNamed(typeName)) { selected.add(instance); } } return selected; }
@Override public boolean add(T element) { element.getOwner().set(Deployment.this); if (firstNamed(element.getName()) != null) { //final String error = String.format("Component instance name must be unique! There is already a component instance named '%s'.", element.getName()); //throw new IllegalStateException(error); return false; } return super.add(element); }
public void externalComponentInstanceToPOJO(net.cloudml.core.ExternalComponentInstance kExternalComponentInstance) { checkForNull(kExternalComponentInstance, "Cannot convert null!"); if (kExternalComponentInstance instanceof net.cloudml.core.ExternalComponentInstance) { assert externalComponents.containsKey(kExternalComponentInstance.getType().getName()); ExternalComponentInstance ni = new ExternalComponentInstance(kExternalComponentInstance.getName(), externalComponents.get(kExternalComponentInstance.getType().getName())); //ni.setPublicAddress(kExternalComponentInstance.getPublicAddress()); convertProperties(kExternalComponentInstance, ni); initProvidedExecutionPlatformInstances(kExternalComponentInstance, ni); convertAndAddProvidedPortInstances(kExternalComponentInstance.getProvidedPortInstances(), ni); externalComponentInstances.put(ni.getName(), ni); model.getComponentInstances().add(ni); } else { throw new IllegalArgumentException("Unknown subtype of ExternalComponentInstance '" + kExternalComponentInstance.getClass().getName()); } }
public boolean replace(T element){ if (firstNamed(element.getName()) != null) { super.remove(element); } element.getOwner().set(Deployment.this); return super.add(element); }
@Override public void integrateIn(Deployment container) { final ExternalComponentInstance<? extends ExternalComponent> result = findType(container).instantiates(getName()); setupProperties(result); setupResources(result); container.getComponentInstances().add(result); }
@Override public void integrateIn(Deployment container) { final VMInstance result = findType(container).instantiates(getName()); setupProperties(result); setupResources(result); container.getComponentInstances().add(result); }
public void vmInstanceToPOJO(net.cloudml.core.VMInstance kVmInstance) { net.cloudml.core.VMInstance kVM = (net.cloudml.core.VMInstance) kVmInstance; assert vms.containsKey(kVM.getType().getName()); VMInstance ni = new VMInstance(kVM.getName(), vms.get(kVM.getType().getName())); ni.setPublicAddress(kVM.getPublicAddress()); ni.setHostname(kVM.getHostname()); convertProperties(kVM, ni); initProvidedExecutionPlatformInstances(kVmInstance, ni); vmInstances.put(ni.getName(), ni); model.getComponentInstances().add(ni); }
@Override public void integrateIn(Deployment container) { final InternalComponentInstance result = findType(container).instantiate(getName()); setupProperties(result); setupResources(result); container.getComponentInstances().add(result); container.deploy(result, findHost(container)); }
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); }
InternalComponentInstance ai = ic.instantiate(nodeType + cnt); dm.getComponentInstances().add(ai); if (a.getName().equals(nodeType) && a instanceof ExternalComponent) { VMInstance ai = ((VM) a).instantiates(nodeType + cnt); dm.getComponentInstances().add(ai); Vertex v = new Vertex(nodeType + cnt, "node", ai); graph.addVertex(v);
private void startExecutes(InternalComponentInstance x){ VMInstance ownerVM = x.externalHost().asVM(); //need some tests but if you need to build PaaS then it means that you want to deploy on IaaS VM n = ownerVM.getType(); Connector jc = ConnectorFactory.createIaaSConnector(n.getProvider()); ComponentInstance host = x.getHost(); if (!alreadyStarted.contains(host)) { if (host.isInternal()) { startExecutes(host.asInternal()); for (Resource r : host.getType().getResources()) { String startCommand = CloudMLQueryUtil.cloudmlStringRecover(r.getStartCommand(), r, x); start(jc, n, ownerVM, startCommand); } coordinator.updateStatusInternalComponent(host.getName(), State.RUNNING.toString(), CloudAppDeployer.class.getName()); alreadyStarted.add(host); } } jc.closeConnection(); }
alreadyStarted.add(x); jc.closeConnection();
alreadyDeployed.add(instance);