use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class StackRequestToStackConverter method getDefaultTags.
private Map<String, String> getDefaultTags(StackRequest source) {
Map<String, String> result = new HashMap<>();
try {
AccountPreferences pref = accountPreferencesService.getByAccount(source.getAccount());
if (pref != null && pref.getDefaultTags() != null && StringUtils.isNoneBlank(pref.getDefaultTags().getValue())) {
result = pref.getDefaultTags().get(Map.class);
}
result.putAll(defaultCostTaggingService.prepareDefaultTags(source.getAccount(), source.getOwnerEmail(), result, source.getCloudPlatform()));
} catch (IOException e) {
LOGGER.debug("Exception during reading default tags.", e);
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class AccountPreferencesValidator method validate.
private void validate(Iterable<InstanceGroup> instanceGroups, Integer nodeCount, String account, String owner) throws AccountPreferencesValidationException {
AccountPreferences preferences = accountPreferencesService.getByAccount(account);
validateNumberOfNodesPerCluster(nodeCount, preferences);
validateNumberOfClusters(account, preferences);
validateAllowedInstanceTypes(instanceGroups, preferences);
validateNumberOfClustersPerUser(owner, preferences);
validateUserTimeToLive(owner, preferences);
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class ScheduledAccountPreferencesValidator method validate.
@Scheduled(cron = EVERY_HOUR_0MIN_0SEC)
public void validate() {
LOGGER.info("Validate account preferences for all 'running' stack.");
Map<String, AccountPreferences> accountPreferences = new HashMap<>();
List<Stack> allAlive = stackService.getAllAlive();
for (Stack stack : allAlive) {
AccountPreferences preferences = getAccountPreferences(stack.getAccount(), accountPreferences);
try {
preferencesValidator.validateClusterTimeToLive(stack.getCreated(), preferences.getClusterTimeToLive());
preferencesValidator.validateUserTimeToLive(stack.getOwner(), preferences);
} catch (AccountPreferencesValidationException ignored) {
terminateStack(stack);
}
}
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class ScheduledAccountPreferencesValidator method getAccountPreferences.
private AccountPreferences getAccountPreferences(String account, Map<String, AccountPreferences> accountPreferences) {
if (accountPreferences.containsKey(account)) {
return accountPreferences.get(account);
} else {
AccountPreferences preferences = accountPreferencesService.getByAccount(account);
accountPreferences.put(account, preferences);
return preferences;
}
}
Aggregations