@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; } }
public InternalComponentInstance getSubject() { return (InternalComponentInstance) getRequiredEnd().getOwner().get(); }
public boolean hasSubject(InternalComponentInstance component) { return getRequiredEnd().getOwner().get().getName().equals(component.getName()); }
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); }
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); }
@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); } } } }