@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Instance " + getName() + " : " + getType().getName() +" id:"+this.hashCode()); for(PortInstance p : this.getProvidedPorts()) builder.append("-Provided port:"+p.getName()); for(PortInstance p : this.getRequiredPorts()) builder.append("-Required port:"+p.getName()); return builder.toString(); }
public boolean hasSubject(InternalComponentInstance component) { return getRequiredEnd().getOwner().get().getName().equals(component.getName()); }
/** * Terminates a set of VMs * * @param vms A list of vmInstances * @throws MalformedURLException */ private void terminateExternalServices(Map<ExternalComponentInstance<? extends ExternalComponent>,List<InternalComponentInstance>> vms) { for (ExternalComponentInstance n : vms.keySet()) { if (n instanceof VMInstance) { terminateVM((VMInstance) n); } else{ PaaSConnector pc = ConnectorFactory.createPaaSConnector(n.getType().asExternal().getProvider()); for(InternalComponentInstance c: vms.get(n)){ journal.log(Level.INFO, ">> Terminating app "+c.asInternal().getName()); pc.deleteApp(c.asInternal().getName()); } journal.log(Level.INFO, ">> Terminated!"); } } }
@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; }
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 InternalComponent fromCloudmlToModaMP(InternalComponentInstance toTranslate){ InternalComponent toReturn = new InternalComponent(); String id = toTranslate.getName(); toReturn.setId(id); toReturn.setType(String.valueOf(toTranslate.getType().getName())); toReturn.addRequiredComponent(toTranslate.externalHost().getName()); return toReturn; } //Translate a cloud provider from cloudML to Monitoring Platform QoS-model
@Override public boolean equals(Object other) { if (other instanceof InternalComponentInstance) { InternalComponentInstance otherCompInst = (InternalComponentInstance) other; Boolean match = getName().equals(otherCompInst.getName()); match &= getType().equals(otherCompInst.getType()); if (externalHost() != null) { match &= externalHost().equals(otherCompInst.externalHost()); }else{ match &= (otherCompInst.externalHost() == null); } if (requiredExecutionPlatformInstance != null) { return match && requiredExecutionPlatformInstance.getName().equals(otherCompInst.getRequiredExecutionPlatform().getName()); } else { return match && (otherCompInst.getRequiredExecutionPlatform() == null); } } else { return false; } }
int code = request.deleteInstances(removedICs.get(i).getName()); if(code == MonitoringAPI.CLIENT_ERROR_NOT_FOUND) { modelMatching = false;
value=c.getName();
value=c.getName();
public void internalComponentInstanceToKmf(InternalComponentInstance ici) { checkNull(ici, "Cannot convert null"); net.cloudml.core.InternalComponentInstance kai = factory.createInternalComponentInstance(); kai.setName(ici.getName()); kai.setType(internalComponents.get(ici.getType().getName())); convertProperties(ici, kai, factory); this.internalComponentInstances.put(kai.getName(), kai); initRequiredExecutionPlatformInstance(ici, kai); initProvidedExecutionPlatformInstances(ici, kai); convertAndAddRequiredPortInstances(ici.getRequiredPorts().toList(), kai); convertAndAddProvidedPortInstances(ici.getProvidedPorts().toList(), kai); kDeploy.addInternalComponentInstances(kai); }
rib.put(name,aRelationshipInstance() .named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName()) .ofType(ri.getType().getName())); rib.put(name, aRelationshipInstance() .named(name) .from(mapping.get(ri.getClientComponent()).getName(), mapping.get(ri.getClientComponent()).asInternal().getRequiredPorts().ofType(ri.getRequiredEnd().getType()).getType().getName()) .to(ri.getServerComponent().getName(), rib.put(name, aRelationshipInstance() .named(name) .from(ri.getClientComponent().getName(), ri.getRequiredEnd().getName()) .to(mapping.get(ri.getServerComponent()).getName(), mapping.get(ri.getServerComponent()).getProvidedPorts().ofType(ri.getProvidedEnd().getType()).getType().getName()) .ofType(ri.getType().getName()));
/** * Stop a specific component instance * * @param a An InternalComponent Instance * @throws MalformedURLException */ private void stopInternalComponent(InternalComponentInstance a) { VMInstance ownerVM = (VMInstance) findDestinationWhenNoRequiredExecutionPlatformSpecified(a); //TODO: to be generalized if (ownerVM != null) { VM n = ownerVM.getType(); Connector jc = ConnectorFactory.createIaaSConnector(n.getProvider()); for (Resource r : a.getType().getResources()) { String stopCommand = r.getStopCommand(); //jc.execCommand(ownerVM.getId(), stopCommand, "ubuntu", n.getPrivateKey()); executeCommand(ownerVM, jc, stopCommand); } jc.closeConnection(); coordinator.updateStatusInternalComponent(a.getName(), State.UNINSTALLED.toString(), CloudAppDeployer.class.getName()); //a.setStatus(State.CONFIGURED); } }
/** * For each component, execute the puppet manifest associated * @param components */ private void configureWithPuppet(ComponentInstanceGroup<InternalComponentInstance> components){ unlessNotNull("Cannot configure null!", components); Connector jc; for (InternalComponentInstance ic : components) { if(ic.externalHost().isVM()){ for(Resource r: ic.getType().getResources()){ if(r instanceof PuppetResource){ PuppetResource pr=(PuppetResource)r; if(!pr.getConfigurationFile().isEmpty()){ journal.log(Level.INFO, ">> Using Puppet to configure the following component: "+ic.getName()); VMInstance n= ic.getHost().asExternal().asVM(); Provider p = n.getType().getProvider(); managePuppet(pr,n, pr.getName(),pr.getConfigurationFile()); } } } } } }
protected void startImpactedComponents(Set<ComponentInstance> listOfAllComponentImpacted, Map<InternalComponentInstance, InternalComponentInstance> duplicatedGraph){ for(ComponentInstance ici: listOfAllComponentImpacted){ if(ici.isInternal()){ Provider p=ici.asInternal().externalHost().asVM().getType().getProvider(); Connector c2=ConnectorFactory.createIaaSConnector(p); for(Resource r: ici.getType().getResources()){ dep.start(c2,ci.getType(),ici.asInternal().externalHost().asVM(),r.getStartCommand()); } c2.closeConnection(); } coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName()); } for(InternalComponentInstance ici: duplicatedGraph.values()){ coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName()); } }
configure(jc, n, ownerVM, configurationCommand, r.getRequireCredentials()); coordinator.updateStatusInternalComponent(x.getName(), State.CONFIGURED.toString(), CloudAppDeployer.class.getName()); start(jc, n, ownerVM, startCommand); coordinator.updateStatusInternalComponent(x.getName(), State.RUNNING.toString(), CloudAppDeployer.class.getName());
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); }
coordinator.updateStatusInternalComponent(instance.getName(), State.INSTALLED.toString(), CloudAppDeployer.class.getName()); minRam = Integer.parseInt(instance.getType().getProperties().valueOf("minRAM")); String url=connector.createEnvironmentWithWar( instance.getName(), instance.getName(), host.getName(), stack, Map<String, String> params = new HashMap<String, String>(); params.put("containerSize", size); connector.configAppParameters(instance.getName(), params); coordinator.updateStatusInternalComponent(ici.getName(), InternalComponentInstance.State.RUNNING.toString(), CloudAppDeployer.class.getName());
public void drawEdgesFromDeploymentModel(Deployment dm, ArrayList<Vertex> v) { for (ComponentInstance x : dm.getComponentInstances()) { if (x instanceof InternalComponentInstance) { InternalComponentInstance ix = (InternalComponentInstance) x; if (ix.getRequiredExecutionPlatform() != null) { Vertex v1 = findVertex(ix.getName(), v); Vertex v2 = findVertex(ix.getRequiredExecutionPlatform().getName(), v); Edge e = new Edge("dest" + ix.getName(), "destination"); createEdge(e, v1, v2); } }//TODO else } for (RelationshipInstance bi : dm.getRelationshipInstances()) { Vertex v1 = findVertex(bi.getRequiredEnd().getOwner().getName(), v); Vertex v2 = findVertex(bi.getProvidedEnd().getOwner().getName(), v); Edge e; if (!bi.getRequiredEnd().getType().isMandatory()) { e = new Edge(bi.getName(), "optional", bi); } else { e = new Edge(bi.getName(), "mandatory", bi); } createEdge(e, v1, v2); } }