@Test public void testMeetsQuantitativeRequirements() { ProvisionRequest request = createProvisionRequest(); assertTrue(instantiatorResource.meetsQuantitativeRequirements(request)); }
boolean meetsQuantitativeRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); boolean provisionable = true; String[] systemThresholdIDs = sla.getSystemRequirements().getSystemThresholdIDs(); if (systemThresholdIDs.length == 0) return (true); MeasuredResource[] measured = resourceCapability.getMeasuredResources(); if (measured == null || measured.length < systemThresholdIDs.length) { StringBuilder message = new StringBuilder(); message.append(getName()).append(" "); if (measured==null) { message.append("has a [null] MeasuredCapability instance, ServiceBean ["); message.append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test ").append(systemThresholdIDs.length); } else { message.append("only has [").append(measured.length).append("] MeasuredCapability instances, "); message.append("ServiceBean [").append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test [").append(systemThresholdIDs.length).append("]"); } provisionRequest.addFailureReason(message.toString()); logger.debug(message.toString()); return false; } for (String systemThresholdID : systemThresholdIDs) { boolean supported = false; ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID); if (systemThresholdID.equals(SystemRequirements.SYSTEM)) { double systemUtilization = systemThreshold.getHighThreshold(); if (systemUtilization < resourceCapability.getUtilization()) { String failureReason = String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f", getName(), systemUtilization, resourceCapability.getUtilization()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); return (false); } else { supported = true; logger.debug("[System] utilization requirement met. Desired {}, Actual {}", systemUtilization, resourceCapability.getUtilization()); } } for (MeasuredResource mRes : measured) { if (mRes.getIdentifier().equals(systemThresholdID)) { if (mRes.evaluate(systemThreshold)) { supported = true; logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); break; } else { String failureReason = String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); } } } if (!supported) { provisionable = false; break; } } return provisionable; }
InstantiatorResource { boolean meetsQuantitativeRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); boolean provisionable = true; String[] systemThresholdIDs = sla.getSystemRequirements().getSystemThresholdIDs(); if (systemThresholdIDs.length == 0) return (true); MeasuredResource[] measured = resourceCapability.getMeasuredResources(); if (measured == null || measured.length < systemThresholdIDs.length) { StringBuilder message = new StringBuilder(); message.append(getName()).append(" "); if (measured==null) { message.append("has a [null] MeasuredCapability instance, ServiceBean ["); message.append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test ").append(systemThresholdIDs.length); } else { message.append("only has [").append(measured.length).append("] MeasuredCapability instances, "); message.append("ServiceBean [").append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test [").append(systemThresholdIDs.length).append("]"); } provisionRequest.addFailureReason(message.toString()); logger.debug(message.toString()); return false; } for (String systemThresholdID : systemThresholdIDs) { boolean supported = false; ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID); if (systemThresholdID.equals(SystemRequirements.SYSTEM)) { double systemUtilization = systemThreshold.getHighThreshold(); if (systemUtilization < resourceCapability.getUtilization()) { String failureReason = String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f", getName(), systemUtilization, resourceCapability.getUtilization()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); return (false); } else { supported = true; logger.debug("[System] utilization requirement met. Desired {}, Actual {}", systemUtilization, resourceCapability.getUtilization()); } } for (MeasuredResource mRes : measured) { if (mRes.getIdentifier().equals(systemThresholdID)) { if (mRes.evaluate(systemThreshold)) { supported = true; logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); break; } else { String failureReason = String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); } } } if (!supported) { provisionable = false; break; } } return provisionable; } }
InstantiatorResource { boolean meetsQuantitativeRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); boolean provisionable = true; String[] systemThresholdIDs = sla.getSystemRequirements().getSystemThresholdIDs(); if (systemThresholdIDs.length == 0) return (true); MeasuredResource[] measured = resourceCapability.getMeasuredResources(); if (measured == null || measured.length < systemThresholdIDs.length) { StringBuilder message = new StringBuilder(); message.append(getName()).append(" "); if (measured==null) { message.append("has a [null] MeasuredCapability instance, ServiceBean ["); message.append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test ").append(systemThresholdIDs.length); } else { message.append("only has [").append(measured.length).append("] MeasuredCapability instances, "); message.append("ServiceBean [").append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test [").append(systemThresholdIDs.length).append("]"); } provisionRequest.addFailureReason(message.toString()); logger.debug(message.toString()); return false; } for (String systemThresholdID : systemThresholdIDs) { boolean supported = false; ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID); if (systemThresholdID.equals(SystemRequirements.SYSTEM)) { double systemUtilization = systemThreshold.getHighThreshold(); if (systemUtilization < resourceCapability.getUtilization()) { String failureReason = String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f", getName(), systemUtilization, resourceCapability.getUtilization()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); return (false); } else { supported = true; logger.debug("[System] utilization requirement met. Desired {}, Actual {}", systemUtilization, resourceCapability.getUtilization()); } } for (MeasuredResource mRes : measured) { if (mRes.getIdentifier().equals(systemThresholdID)) { if (mRes.evaluate(systemThreshold)) { supported = true; logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); break; } else { String failureReason = String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); } } } if (!supported) { provisionable = false; break; } } return provisionable; } InstantiatorResource(MarshalledObject<ServiceBeanInstantiator> wrappedServiceBeanInstantiator,
                                ServiceBeanInstantiator instantiator,
                                String instantiatorName,
                                Uuid instantiatorUuid,
                                MarshalledObject<?> handback,
                                ResourceCapability resourceCapability,
                                int serviceLimit); }
InstantiatorResource { boolean meetsQuantitativeRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); boolean provisionable = true; String[] systemThresholdIDs = sla.getSystemRequirements().getSystemThresholdIDs(); if (systemThresholdIDs.length == 0) return (true); MeasuredResource[] measured = resourceCapability.getMeasuredResources(); if (measured == null || measured.length < systemThresholdIDs.length) { StringBuilder message = new StringBuilder(); message.append(getName()).append(" "); if (measured==null) { message.append("has a [null] MeasuredCapability instance, ServiceBean ["); message.append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test ").append(systemThresholdIDs.length); } else { message.append("only has [").append(measured.length).append("] MeasuredCapability instances, "); message.append("ServiceBean [").append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test [").append(systemThresholdIDs.length).append("]"); } provisionRequest.addFailureReason(message.toString()); logger.debug(message.toString()); return false; } for (String systemThresholdID : systemThresholdIDs) { boolean supported = false; ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID); if (systemThresholdID.equals(SystemRequirements.SYSTEM)) { double systemUtilization = systemThreshold.getHighThreshold(); if (systemUtilization < resourceCapability.getUtilization()) { String failureReason = String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f", getName(), systemUtilization, resourceCapability.getUtilization()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); return (false); } else { supported = true; logger.debug("[System] utilization requirement met. Desired {}, Actual {}", systemUtilization, resourceCapability.getUtilization()); } } for (MeasuredResource mRes : measured) { if (mRes.getIdentifier().equals(systemThresholdID)) { if (mRes.evaluate(systemThreshold)) { supported = true; logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); break; } else { String failureReason = String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); } } } if (!supported) { provisionable = false; break; } } return provisionable; } InstantiatorResource(MarshalledObject<ServiceBeanInstantiator> wrappedServiceBeanInstantiator,
                                ServiceBeanInstantiator instantiator,
                                String instantiatorName,
                                Uuid instantiatorUuid,
                                MarshalledObject<?> handback,
                                ResourceCapability resourceCapability,
                                int serviceLimit); void addDeployedService(DeployedService newDeployedService); String getName(); Uuid getInstantiatorUuid(); int getServiceElementCount(ServiceElement sElem); int getServiceElementCount(); ServiceBeanInstantiator getInstantiator(); int getServiceCount(); MarshalledObject<?> getHandback(); ResourceCapability getResourceCapability(); int getServiceLimit(); void incrementProvisionCounter(ServiceElement sElem); synchronized void decrementProvisionCounter(ServiceElement sElem); int getInProcessCounter(); int getInProcessCounter(ServiceElement sElem); String getHostAddress(); void addUninstantiable(ServiceElement serviceElement); boolean isUninstantiable(ServiceElement serviceElement); void removeUninstantiable(ServiceElement serviceElement); void setDynamicEnabledOn(); boolean getDynamicEnabled(); boolean canProvision(final ProvisionRequest provisionRequest); @Override boolean equals(Object o); @Override int hashCode(); }
InstantiatorResource { boolean meetsQuantitativeRequirements(final ProvisionRequest provisionRequest) { ServiceElement sElem = provisionRequest.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); boolean provisionable = true; String[] systemThresholdIDs = sla.getSystemRequirements().getSystemThresholdIDs(); if (systemThresholdIDs.length == 0) return (true); MeasuredResource[] measured = resourceCapability.getMeasuredResources(); if (measured == null || measured.length < systemThresholdIDs.length) { StringBuilder message = new StringBuilder(); message.append(getName()).append(" "); if (measured==null) { message.append("has a [null] MeasuredCapability instance, ServiceBean ["); message.append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test ").append(systemThresholdIDs.length); } else { message.append("only has [").append(measured.length).append("] MeasuredCapability instances, "); message.append("ServiceBean [").append(LoggingUtil.getLoggingName(sElem)).append("] "); message.append("has a requirement to test [").append(systemThresholdIDs.length).append("]"); } provisionRequest.addFailureReason(message.toString()); logger.debug(message.toString()); return false; } for (String systemThresholdID : systemThresholdIDs) { boolean supported = false; ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID); if (systemThresholdID.equals(SystemRequirements.SYSTEM)) { double systemUtilization = systemThreshold.getHighThreshold(); if (systemUtilization < resourceCapability.getUtilization()) { String failureReason = String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f", getName(), systemUtilization, resourceCapability.getUtilization()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); return (false); } else { supported = true; logger.debug("[System] utilization requirement met. Desired {}, Actual {}", systemUtilization, resourceCapability.getUtilization()); } } for (MeasuredResource mRes : measured) { if (mRes.getIdentifier().equals(systemThresholdID)) { if (mRes.evaluate(systemThreshold)) { supported = true; logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); break; } else { String failureReason = String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f", getName(), systemThresholdID, systemThreshold.getLowThreshold(), systemThreshold.getHighThreshold(), mRes.getValue()); provisionRequest.addFailureReason(failureReason); logger.debug(failureReason); } } } if (!supported) { provisionable = false; break; } } return provisionable; } InstantiatorResource(MarshalledObject<ServiceBeanInstantiator> wrappedServiceBeanInstantiator,
                                ServiceBeanInstantiator instantiator,
                                String instantiatorName,
                                Uuid instantiatorUuid,
                                MarshalledObject<?> handback,
                                ResourceCapability resourceCapability,
                                int serviceLimit); void addDeployedService(DeployedService newDeployedService); String getName(); Uuid getInstantiatorUuid(); int getServiceElementCount(ServiceElement sElem); int getServiceElementCount(); ServiceBeanInstantiator getInstantiator(); int getServiceCount(); MarshalledObject<?> getHandback(); ResourceCapability getResourceCapability(); int getServiceLimit(); void incrementProvisionCounter(ServiceElement sElem); synchronized void decrementProvisionCounter(ServiceElement sElem); int getInProcessCounter(); int getInProcessCounter(ServiceElement sElem); String getHostAddress(); void addUninstantiable(ServiceElement serviceElement); boolean isUninstantiable(ServiceElement serviceElement); void removeUninstantiable(ServiceElement serviceElement); void setDynamicEnabledOn(); boolean getDynamicEnabled(); boolean canProvision(final ProvisionRequest provisionRequest); @Override boolean equals(Object o); @Override int hashCode();  }