use of io.fabric8.api.FabricRequirements in project fabric8 by jboss-fuse.
the class MQManager method getActiveOrRequiredBrokerProfileMap.
private List<Profile> getActiveOrRequiredBrokerProfileMap(Version version, FabricRequirements requirements) {
IllegalArgumentAssertion.assertNotNull(fabricService, "fabricService");
List<Profile> answer = new ArrayList<Profile>();
if (version != null) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
List<Profile> profiles = version.getProfiles();
for (Profile profile : profiles) {
String versionId = profile.getVersion();
String profileId = profile.getId();
if (!IGNORED_PROFILES.contains(profileId)) {
Profile overlay = profileService.getOverlayProfile(profile);
Map<String, Map<String, String>> configurations = overlay.getConfigurations();
Set<Map.Entry<String, Map<String, String>>> entries = configurations.entrySet();
for (Map.Entry<String, Map<String, String>> entry : entries) {
String key = entry.getKey();
if (isBrokerConfigPid(key)) {
answer.add(overlay);
}
}
}
}
}
return answer;
}
use of io.fabric8.api.FabricRequirements in project fabric8 by jboss-fuse.
the class RequirementsListSupport method doExecute.
@Override
protected Object doExecute() throws Exception {
PrintStream out = System.out;
FabricRequirements requirements = getFabricService().getRequirements();
printRequirements(out, requirements);
return null;
}
use of io.fabric8.api.FabricRequirements in project fabric8 by jboss-fuse.
the class FabricResource method setRequirements.
@POST
@Path("requirements")
public void setRequirements(FabricRequirements requirements) throws IOException {
Objects.notNull(requirements, "requirements");
FabricService service = getFabricService();
Objects.notNull(service, "FabricService");
service.setRequirements(requirements);
}
use of io.fabric8.api.FabricRequirements in project fabric8 by jboss-fuse.
the class RequireProfileSetAction method updateRequirements.
@Override
protected boolean updateRequirements(FabricRequirements requirements) {
if (v != null) {
setVersion(v);
} else {
setVersion(getFabricService().getDefaultVersionId());
}
ProfileRequirements requirement = new ProfileRequirements(profile);
if (minimumInstances != null) {
requirement.setMinimumInstances(minimumInstances);
}
if (maximumInstances != null) {
requirement.setMaximumInstances(maximumInstances);
}
if (dependentProfiles != null) {
requirement.setDependentProfiles(dependentProfiles);
}
requirements.addOrUpdateProfileRequirements(requirement);
return true;
}
use of io.fabric8.api.FabricRequirements in project fabric8 by jboss-fuse.
the class FabricServiceImpl method validateRequirements.
/**
* Validates the requirements to ensure the profiles exist etc. and
* removes those for a profile that does not exist.
*/
public static void validateRequirements(FabricService fabricService, FabricRequirements requirements) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
String versionId = requirements.getVersion();
Version version;
if (!Strings.isNullOrEmpty(versionId)) {
version = profileService.getRequiredVersion(versionId);
} else {
version = fabricService.getDefaultVersion();
}
Set<String> profileIds = new HashSet<>(Profiles.profileIds(version.getProfiles()));
List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
List<String> profilesToBeRemoved = new ArrayList<>();
for (ProfileRequirements profileRequirement : profileRequirements) {
try {
validateProfileRequirements(fabricService, requirements, profileRequirement, profileIds);
} catch (IllegalArgumentException e) {
LOGGER.info("Removing {}; {}", profileRequirement, e.getMessage());
profilesToBeRemoved.add(profileRequirement.getProfile());
}
}
for (String profile : profilesToBeRemoved) {
requirements.removeProfileRequirements(profile);
}
}
Aggregations