From 286dc4b1a903a1b9621a3f283efa6ff0eda4000f Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 10 Aug 2024 10:01:16 +0200 Subject: [PATCH] cleanup and amend docker resource limits --- etc/docker-compose.yml | 6 +++--- .../hsadminng/hs/validation/PropertiesProvider.java | 2 +- .../hsadminng/hs/validation/ValidatableProperty.java | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/etc/docker-compose.yml b/etc/docker-compose.yml index 601038dd..f35c4077 100644 --- a/etc/docker-compose.yml +++ b/etc/docker-compose.yml @@ -20,8 +20,8 @@ services: deploy: resources: limits: - cpus: '4' - memory: 4G - reservations: cpus: '2' + memory: 8G + reservations: + cpus: '1' memory: 2G diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/PropertiesProvider.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/PropertiesProvider.java index 57c71234..89c3f5cd 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/PropertiesProvider.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/PropertiesProvider.java @@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.mapper.PatchableMapWrapper; public interface PropertiesProvider { boolean isLoaded(); - PatchableMapWrapper directProps(); + PatchableMapWrapper directProps(); Object getContextValue(final String propName); default T getDirectValue(final String propName, final Class clazz) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java index 3f5011e9..696f645b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java @@ -100,7 +100,6 @@ public abstract class ValidatableProperty

, T public P writeOnly() { this.writeOnly = true; - optional(); // FIXME: sounds wrong return self(); } @@ -260,11 +259,16 @@ public abstract class ValidatableProperty

, T } public void verifyConsistency(final Map.Entry, ?> 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(...)" ); } } + private boolean isSpecPotentiallyComplete() { + return required == null && requiresAtLeastOneOf == null && requiresAtMaxOneOf == null && !readOnly && !writeOnly + && defaultValue == null; + } + @SuppressWarnings("unchecked") public T getValue(final Map propValues) { return (T) Optional.ofNullable(propValues.get(propertyName)).orElse(defaultValue);