@Override public boolean equals(Object other){ if(this == other) return true; if(other == null || !(other instanceof ExecuteInstance)) return false; ExecuteInstance otherEI = (ExecuteInstance) other; boolean reqMatch = false; if(this.getRequiredEnd() == null && otherEI.getRequiredEnd()==null) reqMatch = true; else if(this.getRequiredEnd()!=null && otherEI.getRequiredEnd()!=null) reqMatch = this.getRequiredEnd().equals(otherEI.getRequiredEnd()); boolean prvMatch = false; if(this.getProvidedEnd() == null && otherEI.getProvidedEnd() == null) prvMatch = true; else if(this.getProvidedEnd()!=null && otherEI.getProvidedEnd()!=null) prvMatch = this.getProvidedEnd().equals(otherEI.getProvidedEnd()); return reqMatch && prvMatch; } }
@Override public void onExecuteInstanceEntry(ExecuteInstance subject) { ensureBufferIsReady(); dotText.append("\t") .append(symbols.get(subject.getSubject())) .append(" -> ") .append(symbols.get(subject.getHost())) .append(" [") .append(executeOnFormatting(subject)) .append(" ];\n"); }
public ComponentInstance<? extends Component> hostOf(InternalComponentInstance component) { for (ExecuteInstance execution: this) { if (execution.hasSubject(component)) { return execution.getHost(); } } return null; }
public ExecuteInstance(String name, RequiredExecutionPlatformInstance requiredEnd, ProvidedExecutionPlatformInstance providedEnd) { super(name); this.owner = new OptionalOwner<Deployment>(); unlessExpectationsAreMet(providedEnd, requiredEnd); setProvidedEnd(providedEnd); setRequiredEnd(requiredEnd); }
private void addExecutes(){ addedExecutes = new ArrayList<ExecuteInstance>(targetDM.getExecuteInstances()); addedExecutes.removeAll(matchingExecutes.values()); for (ExecuteInstance ei : addedExecutes) { int i = currentDM.getComponentInstances().toList().indexOf(ei.getRequiredEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); ei.setRequiredEnd(((InternalComponentInstance) a).getRequiredExecutionPlatform()); } i = currentDM.getComponentInstances().toList().indexOf(ei.getProvidedEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); int j = a.getProvidedExecutionPlatforms().toList().indexOf(ei.getProvidedEnd()); List<ProvidedExecutionPlatformInstance> l = a.getProvidedExecutionPlatforms().toList(); ei.setProvidedEnd(l.get(j)); } } }
public void executeToKmf(ExecuteInstance ei) { checkNull(ei, "Cannot convert null!"); net.cloudml.core.ExecuteInstance kExecute = factory.createExecuteInstance(); convertProperties(ei, kExecute, factory); convertResources(ei, kExecute, factory); kExecute.setName(ei.getName()); assert (ei.getProvidedEnd() != null); net.cloudml.core.ProvidedExecutionPlatformInstance o=providedExecutionPlatformInstances.get(calculateExecutionPlatformIdentifier(ei.getProvidedEnd())); assert (o != null); kExecute.setProvidedExecutionPlatformInstance(providedExecutionPlatformInstances.get(calculateExecutionPlatformIdentifier(ei.getProvidedEnd()))); kExecute.setRequiredExecutionPlatformInstance(requiredExecutionPlatformInstances.get(calculateExecutionPlatformIdentifier(ei.getRequiredEnd()))); kDeploy.addExecutesInstances(kExecute); }
public ComponentInstance<? extends Component> getHost() { return getProvidedEnd().getOwner().get(); }
public InternalComponentInstance getSubject() { return (InternalComponentInstance) getRequiredEnd().getOwner().get(); }
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; }
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); } }
@Override public void dispatchTo(Visitor visitor, Deployment deployment) { for (Provider provider : deployment.getProviders()) { provider.accept(visitor); } for (Component component : deployment.getComponents()) { component.accept(visitor); } for (ComponentInstance<? extends Component> instance : deployment.getComponentInstances()) { instance.accept(visitor); } for (Relationship relationship : deployment.getRelationships()) { relationship.accept(visitor); } for (RelationshipInstance instance : deployment.getRelationshipInstances()) { instance.accept(visitor); } for(ExecuteInstance execute: deployment.getExecuteInstances()) { execute.accept(visitor); } for (Cloud cloud : deployment.getClouds()) { cloud.accept(visitor); } }
public boolean isHostedBy(ComponentInstance<? extends Component> host) { return getProvidedEnd().getOwner().get().equals(host); }
public boolean hasSubject(InternalComponentInstance component) { return getRequiredEnd().getOwner().get().getName().equals(component.getName()); }
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); }
public boolean isBetween(String demanderName, String demandName, String providerName, String providedName) { return this.getRequiredEnd().getOwner().get().isNamed(demanderName) && this.getRequiredEnd().isNamed(demandName) && this.getProvidedEnd().getOwner().get().isNamed(providerName) && this.getProvidedEnd().isNamed(providedName); }
@Override public void validate(Report report) { final PropertyGroup demands = getRequiredEnd().getType().getDemands(); for (Property demand : demands) { final PropertyGroup offers = getProvidedEnd().getType().getOffers(); if (!offers.isDefined(demand.getName())) { final String error = String.format("Mismatch between demands and offers! Demanded: %s, but %s is not offered", demand, demand.getName()); report.addError(error); } else { if (!offers.contains(demand)) { final Property offer = offers.get(demand.getName()); final String error = String.format("Mismatch between demands and offers!! Demanded: %s, but offered %s", demand, offer); report.addError(error); } } } }