@Override public void integrateIn(InternalComponent container) { final RequiredExecutionPlatform platform = new RequiredExecutionPlatform(getName()); prepare(platform); platform.getOwner().set(container); container.setRequiredExecutionPlatform(platform); }
private void setupDemands(final RequiredExecutionPlatform platform) { for(String key: demands.keySet()) { platform.getDemands().add(new Property(key, demands.get(key))); } }
@Override protected void handleLackOfCandidate(Deployment deployment, List<Component> candidates) { final String message = String.format( "Unable to find a node type relevant to install artefacts of type '%s'", component.getRequiredExecutionPlatform().getName()); throw new IllegalStateException(message); } }
@Override public RequiredExecutionPlatform build() { final RequiredExecutionPlatform platform = new RequiredExecutionPlatform(getName()); prepare(platform); return platform; }
public final void setRequiredExecutionPlatform(RequiredExecutionPlatform requiredExecutionPlatform) { rejectIfInvalid(requiredExecutionPlatform); requiredExecutionPlatform.getOwner().set(this); this.requiredExecutionPlatform = requiredExecutionPlatform; }
private RequiredExecutionPlatformInstance rejectIfInvalid(RequiredExecutionPlatformInstance platform) { if (platform == null) { final String error = String.format("Error in internal component instance '%s'! ('null' cannot be the required execution platform)", getQualifiedName()); throw new IllegalArgumentException(error); } if (!platform.getType().equals(this.getType().getRequiredExecutionPlatform())) { final String error = String.format("Error in internal component instance '%s'! Required execution platform has a wrong type (expected: '%s' but found '%s')", getQualifiedName(), getType().getRequiredExecutionPlatform().getQualifiedName(), platform.getType().getQualifiedName()); throw new IllegalArgumentException(error); } return platform; }
public InternalComponentInstance(String name, InternalComponent type) { super(name, type); requiredPortInstances = instantiateAllRequiredPorts(type); requiredExecutionPlatformInstance = type.getRequiredExecutionPlatform().instantiate(); requiredExecutionPlatformInstance.getOwner().set(this); this.status = State.UNINSTALLED; }
public void internalComponentToPOJO(net.cloudml.core.InternalComponent kInternalComponent) { checkForNull(kInternalComponent, "Cannot convert null!"); InternalComponent ic = new InternalComponent(kInternalComponent.getName(), new RequiredExecutionPlatform("to be replaced")); convertProperties(kInternalComponent, ic); convertResources(kInternalComponent, ic); convertPuppetResources(kInternalComponent,ic); internalComponents.put(ic.getName(), ic); initRequiredExecutionPlatform(kInternalComponent, ic); initProvidedExecutionPlatforms(kInternalComponent, ic); convertAndAddProvidedPortsToPOJO(kInternalComponent.getProvidedPorts(), ic); convertAndAddRequiredPortsToPOJO(kInternalComponent.getRequiredPorts(), ic); model.getComponents().add(ic); }
private void initRequiredExecutionPlatform(net.cloudml.core.InternalComponent kInternalComponent, InternalComponent ic) { if (kInternalComponent.getRequiredExecutionPlatform() != null) { //assert !vmInstances.isEmpty(); RequiredExecutionPlatform rep = new RequiredExecutionPlatform(kInternalComponent.getRequiredExecutionPlatform().getName()); rep.getOwner().set(ic); convertProperties(kInternalComponent.getRequiredExecutionPlatform(), rep); convertResources(kInternalComponent.getRequiredExecutionPlatform(), rep); convertDemands(kInternalComponent, rep); ic.setRequiredExecutionPlatform(rep); } }
public boolean canHost(InternalComponent component) { return offers.containsAll(component.getRequiredExecutionPlatform().getDemands()); }
@Override public RequiredExecutionPlatformInstance instantiate() { return new RequiredExecutionPlatformInstance(ModelUtils.generateUniqueName(getName()), this); } }
public boolean match(RequiredExecutionPlatform platform) { return getOffers().containsAll(platform.getDemands()); }
private void initRequiredExecutionPlatform(InternalComponent ic, net.cloudml.core.InternalComponent ka) { if (ic.getRequiredExecutionPlatform() != null) { net.cloudml.core.RequiredExecutionPlatform krep = factory.createRequiredExecutionPlatform(); krep.setName(ic.getRequiredExecutionPlatform().getName()); krep.setOwner(ka); convertDemands(ic, krep); convertProperties(ic.getRequiredExecutionPlatform(), krep, factory); convertResources(ic.getRequiredExecutionPlatform(), krep, factory); ka.setRequiredExecutionPlatform(krep); } }
private void unlessExpectationsAreMet(ProvidedExecutionPlatformInstance provided, RequiredExecutionPlatformInstance required) { for (Property demand : required.getType().getDemands()) { Property offer = provided.getType().getOffers().get(demand.getName()); if (offer == null) { throw new IllegalArgumentException("Missing expectations: " + demand.getName()); } if (!demand.getValue().equals(offer.getValue())) { throw new IllegalArgumentException("Unmet expectation '" + demand.getName() + "' (expected + '" + demand.getValue() + "' but found: '" + offer.getValue() + "')"); } } }
private void convertDemands(net.cloudml.core.InternalComponent kInternalComponent, RequiredExecutionPlatform rep) { for (net.cloudml.core.Property eachKDemand: kInternalComponent.getRequiredExecutionPlatform().getDemands()) { rep.getDemands().add(new Property(eachKDemand.getName(), eachKDemand.getValue())); } }
private void convertDemands(InternalComponent ic, net.cloudml.core.RequiredExecutionPlatform krep) { for(Property eachDemand: ic.getRequiredExecutionPlatform().getDemands()) { net.cloudml.core.Property kDemand = factory.createProperty(); kDemand.setName(eachDemand.getName()); kDemand.setValue(eachDemand.getValue()); krep.addDemands(kDemand); } }
@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); } } } }