cleanup and amend docker resource limits

This commit is contained in:
Michael Hoennig 2024-08-10 10:01:16 +02:00
parent c136064ff7
commit 286dc4b1a9
3 changed files with 10 additions and 6 deletions

View File

@ -20,8 +20,8 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: '4'
memory: 4G
reservations:
cpus: '2' cpus: '2'
memory: 8G
reservations:
cpus: '1'
memory: 2G memory: 2G

View File

@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.mapper.PatchableMapWrapper;
public interface PropertiesProvider { public interface PropertiesProvider {
boolean isLoaded(); boolean isLoaded();
PatchableMapWrapper directProps(); PatchableMapWrapper<Object> directProps();
Object getContextValue(final String propName); Object getContextValue(final String propName);
default <T> T getDirectValue(final String propName, final Class<T> clazz) { default <T> T getDirectValue(final String propName, final Class<T> clazz) {

View File

@ -100,7 +100,6 @@ public abstract class ValidatableProperty<P extends ValidatableProperty<?, ?>, T
public P writeOnly() { public P writeOnly() {
this.writeOnly = true; this.writeOnly = true;
optional(); // FIXME: sounds wrong
return self(); return self();
} }
@ -260,11 +259,16 @@ public abstract class ValidatableProperty<P extends ValidatableProperty<?, ?>, T
} }
public void verifyConsistency(final Map.Entry<? extends Enum<?>, ?> typeDef) { public void verifyConsistency(final Map.Entry<? extends Enum<?>, ?> typeDef) {
if (required == null && requiresAtLeastOneOf == null && requiresAtMaxOneOf == null && !readOnly && defaultValue == null) { if (isSpecPotentiallyComplete()) {
throw new IllegalStateException(typeDef.getKey() + "[" + propertyName + "] not fully initialized, please call either .readOnly(), .required(), .optional(), .withDefault(...), .requiresAtLeastOneOf(...) or .requiresAtMaxOneOf(...)" ); throw new IllegalStateException(typeDef.getKey() + "[" + propertyName + "] not fully initialized, please call either .readOnly(), .required(), .optional(), .withDefault(...), .requiresAtLeastOneOf(...) or .requiresAtMaxOneOf(...)" );
} }
} }
private boolean isSpecPotentiallyComplete() {
return required == null && requiresAtLeastOneOf == null && requiresAtMaxOneOf == null && !readOnly && !writeOnly
&& defaultValue == null;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public T getValue(final Map<String, Object> propValues) { public T getValue(final Map<String, Object> propValues) {
return (T) Optional.ofNullable(propValues.get(propertyName)).orElse(defaultValue); return (T) Optional.ofNullable(propValues.get(propertyName)).orElse(defaultValue);