@Test public void testDoesNotMeetArchitectureRequirements() { ProvisionRequest request = createProvisionRequest(); request.getServiceElement().setServiceLevelAgreements(createServiceLevelAgreements(false, true)); Collection<SystemComponent> notSupported = instantiatorResource.meetsQualitativeRequirements(request); assertTrue(notSupported.size() > 0); }
Collection<SystemComponent> meetsQualitativeRequirements(final ProvisionRequest request) { ServiceElement sElem = request.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); SystemComponent[] serviceRequirements = sla.getSystemRequirements().getSystemComponents(); List<SystemComponent> unsupportedRequirements = new ArrayList<>(); if (serviceRequirements.length == 0) return unsupportedRequirements; PlatformCapability[] platformCapabilities = resourceCapability.getPlatformCapabilities(); List<SystemComponent> operatingSystems = new ArrayList<>(); List<SystemComponent> architectures = new ArrayList<>(); List<SystemComponent> machineAddresses = new ArrayList<>(); List<SystemComponent> remaining = new ArrayList<>(); for (SystemComponent serviceRequirement : serviceRequirements) { if (isOperatingSystem(serviceRequirement)) { operatingSystems.add(serviceRequirement); } else if (isArchitecture(serviceRequirement)) { architectures.add(serviceRequirement); } else if (isMachineAddress(serviceRequirement)) { machineAddresses.add(serviceRequirement); } else { remaining.add(serviceRequirement); } } if (!architectures.isEmpty()) { ProcessorArchitecture architecture = getArchitecture(); Result result = check(architecture, architectures); if (!result.supported) { String failureReason = formatFailureReason(architectures, (String)architecture.getCapabilities().get(ProcessorArchitecture.ARCHITECTURE), "architecture", sElem, result.excluded.isEmpty(), ProcessorArchitecture.ARCHITECTURE); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(architectures); return unsupportedRequirements; } } if (!operatingSystems.isEmpty()) { OperatingSystem operatingSystem = getOperatingSystem(); Result result = check(operatingSystem, operatingSystems); if (!result.supported) { String failureReason = formatFailureReason(operatingSystems, operatingSystem.getCapabilities().get(OperatingSystem.NAME).toString(), "operating system", sElem, result.excluded.isEmpty(), OperatingSystem.NAME); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(operatingSystems); return unsupportedRequirements; } } if (!machineAddresses.isEmpty()) { TCPConnectivity tcpConnectivity = getTCPConnectivity(); Result result = check(tcpConnectivity, machineAddresses); if (!result.supported) { String formattedComponents = formatSystemComponents(machineAddresses, TCPConnectivity.HOST_NAME, TCPConnectivity.HOST_ADDRESS); String failureReason; if (result.excluded.isEmpty()) { failureReason = String.format("The machine addresses being requested [%s] do not match the " + "target resource's machine name/ip [%s/%s] for [%s]", formattedComponents, tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), LoggingUtil.getLoggingName(sElem)); } else { failureReason = String.format("The target resource's machine name/ip [%s/%s] is on the exclusion list of [%s] for [%s]", tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), formattedComponents, LoggingUtil.getLoggingName(sElem)); } if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(machineAddresses); return unsupportedRequirements; } } for (SystemComponent serviceRequirement : remaining) { boolean supported = false; for (PlatformCapability platformCapability : platformCapabilities) { if (platformCapability.supports(serviceRequirement)) { if (serviceRequirement.exclude()) { continue; } supported = true; break; } } if (!supported) { unsupportedRequirements.add(serviceRequirement); } } return unsupportedRequirements; }
InstantiatorResource { Collection<SystemComponent> meetsQualitativeRequirements(final ProvisionRequest request) { ServiceElement sElem = request.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); SystemComponent[] serviceRequirements = sla.getSystemRequirements().getSystemComponents(); List<SystemComponent> unsupportedRequirements = new ArrayList<>(); if (serviceRequirements.length == 0) return unsupportedRequirements; PlatformCapability[] platformCapabilities = resourceCapability.getPlatformCapabilities(); List<SystemComponent> operatingSystems = new ArrayList<>(); List<SystemComponent> architectures = new ArrayList<>(); List<SystemComponent> machineAddresses = new ArrayList<>(); List<SystemComponent> remaining = new ArrayList<>(); for (SystemComponent serviceRequirement : serviceRequirements) { if (isOperatingSystem(serviceRequirement)) { operatingSystems.add(serviceRequirement); } else if (isArchitecture(serviceRequirement)) { architectures.add(serviceRequirement); } else if (isMachineAddress(serviceRequirement)) { machineAddresses.add(serviceRequirement); } else { remaining.add(serviceRequirement); } } if (!architectures.isEmpty()) { ProcessorArchitecture architecture = getArchitecture(); Result result = check(architecture, architectures); if (!result.supported) { String failureReason = formatFailureReason(architectures, (String)architecture.getCapabilities().get(ProcessorArchitecture.ARCHITECTURE), "architecture", sElem, result.excluded.isEmpty(), ProcessorArchitecture.ARCHITECTURE); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(architectures); return unsupportedRequirements; } } if (!operatingSystems.isEmpty()) { OperatingSystem operatingSystem = getOperatingSystem(); Result result = check(operatingSystem, operatingSystems); if (!result.supported) { String failureReason = formatFailureReason(operatingSystems, operatingSystem.getCapabilities().get(OperatingSystem.NAME).toString(), "operating system", sElem, result.excluded.isEmpty(), OperatingSystem.NAME); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(operatingSystems); return unsupportedRequirements; } } if (!machineAddresses.isEmpty()) { TCPConnectivity tcpConnectivity = getTCPConnectivity(); Result result = check(tcpConnectivity, machineAddresses); if (!result.supported) { String formattedComponents = formatSystemComponents(machineAddresses, TCPConnectivity.HOST_NAME, TCPConnectivity.HOST_ADDRESS); String failureReason; if (result.excluded.isEmpty()) { failureReason = String.format("The machine addresses being requested [%s] do not match the " + "target resource's machine name/ip [%s/%s] for [%s]", formattedComponents, tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), LoggingUtil.getLoggingName(sElem)); } else { failureReason = String.format("The target resource's machine name/ip [%s/%s] is on the exclusion list of [%s] for [%s]", tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), formattedComponents, LoggingUtil.getLoggingName(sElem)); } if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(machineAddresses); return unsupportedRequirements; } } for (SystemComponent serviceRequirement : remaining) { boolean supported = false; for (PlatformCapability platformCapability : platformCapabilities) { if (platformCapability.supports(serviceRequirement)) { if (serviceRequirement.exclude()) { continue; } supported = true; break; } } if (!supported) { unsupportedRequirements.add(serviceRequirement); } } return unsupportedRequirements; } }
InstantiatorResource { Collection<SystemComponent> meetsQualitativeRequirements(final ProvisionRequest request) { ServiceElement sElem = request.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); SystemComponent[] serviceRequirements = sla.getSystemRequirements().getSystemComponents(); List<SystemComponent> unsupportedRequirements = new ArrayList<>(); if (serviceRequirements.length == 0) return unsupportedRequirements; PlatformCapability[] platformCapabilities = resourceCapability.getPlatformCapabilities(); List<SystemComponent> operatingSystems = new ArrayList<>(); List<SystemComponent> architectures = new ArrayList<>(); List<SystemComponent> machineAddresses = new ArrayList<>(); List<SystemComponent> remaining = new ArrayList<>(); for (SystemComponent serviceRequirement : serviceRequirements) { if (isOperatingSystem(serviceRequirement)) { operatingSystems.add(serviceRequirement); } else if (isArchitecture(serviceRequirement)) { architectures.add(serviceRequirement); } else if (isMachineAddress(serviceRequirement)) { machineAddresses.add(serviceRequirement); } else { remaining.add(serviceRequirement); } } if (!architectures.isEmpty()) { ProcessorArchitecture architecture = getArchitecture(); Result result = check(architecture, architectures); if (!result.supported) { String failureReason = formatFailureReason(architectures, (String)architecture.getCapabilities().get(ProcessorArchitecture.ARCHITECTURE), "architecture", sElem, result.excluded.isEmpty(), ProcessorArchitecture.ARCHITECTURE); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(architectures); return unsupportedRequirements; } } if (!operatingSystems.isEmpty()) { OperatingSystem operatingSystem = getOperatingSystem(); Result result = check(operatingSystem, operatingSystems); if (!result.supported) { String failureReason = formatFailureReason(operatingSystems, operatingSystem.getCapabilities().get(OperatingSystem.NAME).toString(), "operating system", sElem, result.excluded.isEmpty(), OperatingSystem.NAME); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(operatingSystems); return unsupportedRequirements; } } if (!machineAddresses.isEmpty()) { TCPConnectivity tcpConnectivity = getTCPConnectivity(); Result result = check(tcpConnectivity, machineAddresses); if (!result.supported) { String formattedComponents = formatSystemComponents(machineAddresses, TCPConnectivity.HOST_NAME, TCPConnectivity.HOST_ADDRESS); String failureReason; if (result.excluded.isEmpty()) { failureReason = String.format("The machine addresses being requested [%s] do not match the " + "target resource's machine name/ip [%s/%s] for [%s]", formattedComponents, tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), LoggingUtil.getLoggingName(sElem)); } else { failureReason = String.format("The target resource's machine name/ip [%s/%s] is on the exclusion list of [%s] for [%s]", tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), formattedComponents, LoggingUtil.getLoggingName(sElem)); } if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(machineAddresses); return unsupportedRequirements; } } for (SystemComponent serviceRequirement : remaining) { boolean supported = false; for (PlatformCapability platformCapability : platformCapabilities) { if (platformCapability.supports(serviceRequirement)) { if (serviceRequirement.exclude()) { continue; } supported = true; break; } } if (!supported) { unsupportedRequirements.add(serviceRequirement); } } return unsupportedRequirements; } InstantiatorResource(MarshalledObject<ServiceBeanInstantiator> wrappedServiceBeanInstantiator,
                                ServiceBeanInstantiator instantiator,
                                String instantiatorName,
                                Uuid instantiatorUuid,
                                MarshalledObject<?> handback,
                                ResourceCapability resourceCapability,
                                int serviceLimit); }
InstantiatorResource { Collection<SystemComponent> meetsQualitativeRequirements(final ProvisionRequest request) { ServiceElement sElem = request.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); SystemComponent[] serviceRequirements = sla.getSystemRequirements().getSystemComponents(); List<SystemComponent> unsupportedRequirements = new ArrayList<>(); if (serviceRequirements.length == 0) return unsupportedRequirements; PlatformCapability[] platformCapabilities = resourceCapability.getPlatformCapabilities(); List<SystemComponent> operatingSystems = new ArrayList<>(); List<SystemComponent> architectures = new ArrayList<>(); List<SystemComponent> machineAddresses = new ArrayList<>(); List<SystemComponent> remaining = new ArrayList<>(); for (SystemComponent serviceRequirement : serviceRequirements) { if (isOperatingSystem(serviceRequirement)) { operatingSystems.add(serviceRequirement); } else if (isArchitecture(serviceRequirement)) { architectures.add(serviceRequirement); } else if (isMachineAddress(serviceRequirement)) { machineAddresses.add(serviceRequirement); } else { remaining.add(serviceRequirement); } } if (!architectures.isEmpty()) { ProcessorArchitecture architecture = getArchitecture(); Result result = check(architecture, architectures); if (!result.supported) { String failureReason = formatFailureReason(architectures, (String)architecture.getCapabilities().get(ProcessorArchitecture.ARCHITECTURE), "architecture", sElem, result.excluded.isEmpty(), ProcessorArchitecture.ARCHITECTURE); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(architectures); return unsupportedRequirements; } } if (!operatingSystems.isEmpty()) { OperatingSystem operatingSystem = getOperatingSystem(); Result result = check(operatingSystem, operatingSystems); if (!result.supported) { String failureReason = formatFailureReason(operatingSystems, operatingSystem.getCapabilities().get(OperatingSystem.NAME).toString(), "operating system", sElem, result.excluded.isEmpty(), OperatingSystem.NAME); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(operatingSystems); return unsupportedRequirements; } } if (!machineAddresses.isEmpty()) { TCPConnectivity tcpConnectivity = getTCPConnectivity(); Result result = check(tcpConnectivity, machineAddresses); if (!result.supported) { String formattedComponents = formatSystemComponents(machineAddresses, TCPConnectivity.HOST_NAME, TCPConnectivity.HOST_ADDRESS); String failureReason; if (result.excluded.isEmpty()) { failureReason = String.format("The machine addresses being requested [%s] do not match the " + "target resource's machine name/ip [%s/%s] for [%s]", formattedComponents, tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), LoggingUtil.getLoggingName(sElem)); } else { failureReason = String.format("The target resource's machine name/ip [%s/%s] is on the exclusion list of [%s] for [%s]", tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), formattedComponents, LoggingUtil.getLoggingName(sElem)); } if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(machineAddresses); return unsupportedRequirements; } } for (SystemComponent serviceRequirement : remaining) { boolean supported = false; for (PlatformCapability platformCapability : platformCapabilities) { if (platformCapability.supports(serviceRequirement)) { if (serviceRequirement.exclude()) { continue; } supported = true; break; } } if (!supported) { unsupportedRequirements.add(serviceRequirement); } } return unsupportedRequirements; } 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 { Collection<SystemComponent> meetsQualitativeRequirements(final ProvisionRequest request) { ServiceElement sElem = request.getServiceElement(); ServiceLevelAgreements sla = sElem.getServiceLevelAgreements(); SystemComponent[] serviceRequirements = sla.getSystemRequirements().getSystemComponents(); List<SystemComponent> unsupportedRequirements = new ArrayList<>(); if (serviceRequirements.length == 0) return unsupportedRequirements; PlatformCapability[] platformCapabilities = resourceCapability.getPlatformCapabilities(); List<SystemComponent> operatingSystems = new ArrayList<>(); List<SystemComponent> architectures = new ArrayList<>(); List<SystemComponent> machineAddresses = new ArrayList<>(); List<SystemComponent> remaining = new ArrayList<>(); for (SystemComponent serviceRequirement : serviceRequirements) { if (isOperatingSystem(serviceRequirement)) { operatingSystems.add(serviceRequirement); } else if (isArchitecture(serviceRequirement)) { architectures.add(serviceRequirement); } else if (isMachineAddress(serviceRequirement)) { machineAddresses.add(serviceRequirement); } else { remaining.add(serviceRequirement); } } if (!architectures.isEmpty()) { ProcessorArchitecture architecture = getArchitecture(); Result result = check(architecture, architectures); if (!result.supported) { String failureReason = formatFailureReason(architectures, (String)architecture.getCapabilities().get(ProcessorArchitecture.ARCHITECTURE), "architecture", sElem, result.excluded.isEmpty(), ProcessorArchitecture.ARCHITECTURE); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(architectures); return unsupportedRequirements; } } if (!operatingSystems.isEmpty()) { OperatingSystem operatingSystem = getOperatingSystem(); Result result = check(operatingSystem, operatingSystems); if (!result.supported) { String failureReason = formatFailureReason(operatingSystems, operatingSystem.getCapabilities().get(OperatingSystem.NAME).toString(), "operating system", sElem, result.excluded.isEmpty(), OperatingSystem.NAME); if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(operatingSystems); return unsupportedRequirements; } } if (!machineAddresses.isEmpty()) { TCPConnectivity tcpConnectivity = getTCPConnectivity(); Result result = check(tcpConnectivity, machineAddresses); if (!result.supported) { String formattedComponents = formatSystemComponents(machineAddresses, TCPConnectivity.HOST_NAME, TCPConnectivity.HOST_ADDRESS); String failureReason; if (result.excluded.isEmpty()) { failureReason = String.format("The machine addresses being requested [%s] do not match the " + "target resource's machine name/ip [%s/%s] for [%s]", formattedComponents, tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), LoggingUtil.getLoggingName(sElem)); } else { failureReason = String.format("The target resource's machine name/ip [%s/%s] is on the exclusion list of [%s] for [%s]", tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_NAME), tcpConnectivity.getCapabilities().get(TCPConnectivity.HOST_ADDRESS), formattedComponents, LoggingUtil.getLoggingName(sElem)); } if (logger.isWarnEnabled()) { logger.warn(failureReason); } request.addFailureReason(failureReason); unsupportedRequirements.addAll(machineAddresses); return unsupportedRequirements; } } for (SystemComponent serviceRequirement : remaining) { boolean supported = false; for (PlatformCapability platformCapability : platformCapabilities) { if (platformCapability.supports(serviceRequirement)) { if (serviceRequirement.exclude()) { continue; } supported = true; break; } } if (!supported) { unsupportedRequirements.add(serviceRequirement); } } return unsupportedRequirements; } 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();  }