From 2d55f4cb8bbeb92b86a6cfca8c7488615f7d0718 Mon Sep 17 00:00:00 2001 From: Stefan Kaufmann Date: Tue, 11 Apr 2023 14:38:20 +0200 Subject: [PATCH 1/4] log exception for named access on regex groups --- .../java/de/itdesigners/winslow/asblr/LogParserRegisterer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/application/src/main/java/de/itdesigners/winslow/asblr/LogParserRegisterer.java b/application/src/main/java/de/itdesigners/winslow/asblr/LogParserRegisterer.java index bbecb4757..12cd5f3dd 100644 --- a/application/src/main/java/de/itdesigners/winslow/asblr/LogParserRegisterer.java +++ b/application/src/main/java/de/itdesigners/winslow/asblr/LogParserRegisterer.java @@ -253,6 +253,7 @@ private Formatter(@Nonnull String format, @Nonnull Function Date: Wed, 3 May 2023 17:25:03 +0200 Subject: [PATCH 2/4] Reserve required resources while participating in an election --- .../java/de/itdesigners/winslow/Election.java | 19 ++++++++++++++++++- .../LockBusElectionManagerAdapter.java | 12 ++++++++++++ .../de/itdesigners/winslow/Orchestrator.java | 5 +++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/de/itdesigners/winslow/Election.java b/application/src/main/java/de/itdesigners/winslow/Election.java index de921c17d..7b1457408 100644 --- a/application/src/main/java/de/itdesigners/winslow/Election.java +++ b/application/src/main/java/de/itdesigners/winslow/Election.java @@ -3,7 +3,10 @@ import de.itdesigners.winslow.fs.LockBus; import javax.annotation.Nonnull; -import java.util.*; +import java.util.ArrayList; +import java.util.Map; +import java.util.Optional; +import java.util.TreeMap; public class Election { @@ -14,6 +17,8 @@ public class Election { private final Map participations = new TreeMap<>(); + private @Nonnull ResourceAllocationMonitor.ResourceSet requiredResources = new ResourceAllocationMonitor.ResourceSet<>(); + public Election(@Nonnull String issuer, @Nonnull String projectId, long time, long duration) { this.issuer = issuer; this.projectId = projectId; @@ -39,6 +44,10 @@ public synchronized void onNewParticipant(@Nonnull String issuer, @Nonnull Parti this.participations.put(issuer, participation); } + public synchronized boolean hasParticipated(@Nonnull String issuer) { + return this.participations.containsKey(issuer); + } + @Nonnull public synchronized Optional getMostFittingParticipant() { var list = new ArrayList<>(this.participations.entrySet()); @@ -60,6 +69,14 @@ public synchronized Optional getMostFittingParticipant() { } } + public synchronized void setRequiredResources(@Nonnull ResourceAllocationMonitor.ResourceSet requiredResources) { + this.requiredResources = requiredResources; + } + + @Nonnull + public synchronized ResourceAllocationMonitor.ResourceSet getRequiredResources() { + return requiredResources; + } public static class Participation { final float affinity; diff --git a/application/src/main/java/de/itdesigners/winslow/LockBusElectionManagerAdapter.java b/application/src/main/java/de/itdesigners/winslow/LockBusElectionManagerAdapter.java index 311570b11..dc7906878 100644 --- a/application/src/main/java/de/itdesigners/winslow/LockBusElectionManagerAdapter.java +++ b/application/src/main/java/de/itdesigners/winslow/LockBusElectionManagerAdapter.java @@ -99,6 +99,11 @@ private void handleElectionStarted(@Nonnull Election election) { try { electionManager.participate(election, participation); + election.setRequiredResources(requiredResources); + orchestrator.getResourceAllocationMonitor().reserve( + election.getProjectId(), + requiredResources + ); } catch (IOException | LockException e) { LOG.log( Level.SEVERE, @@ -110,6 +115,13 @@ private void handleElectionStarted(@Nonnull Election election) { } private void handleElectionClosed(@Nonnull Election election) { + if (election.hasParticipated(nodeName)) { + orchestrator.getResourceAllocationMonitor().free( + election.getProjectId(), + election.getRequiredResources() + ); + } + election.getMostFittingParticipant().ifPresentOrElse(participant -> { if (nodeName.equals(participant)) { var thread = new Thread(() -> { diff --git a/application/src/main/java/de/itdesigners/winslow/Orchestrator.java b/application/src/main/java/de/itdesigners/winslow/Orchestrator.java index 79ee15f90..aa14b79c7 100644 --- a/application/src/main/java/de/itdesigners/winslow/Orchestrator.java +++ b/application/src/main/java/de/itdesigners/winslow/Orchestrator.java @@ -161,6 +161,11 @@ public ResourceManager getResourceManager() { return environment.getResourceManager(); } + @Nonnull + public ResourceAllocationMonitor getResourceAllocationMonitor() { + return monitor; + } + public void addStageExecutionTag(@Nonnull String tag) { this.stageExecutionTags.add(tag); } From 25e6787776f97a85c0b5b88383e2127b0264b54b Mon Sep 17 00:00:00 2001 From: Stefan Kaufmann Date: Tue, 16 Jan 2024 13:11:32 +0100 Subject: [PATCH 3/4] change docker image name to legacy --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ffa311dd..ef98d8c7c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,9 +54,9 @@ deploy: script: # - ./build-docker-image.sh - ls -lah . - - docker build . -t $DOCKER_REGISTRY_WINSLOW/winslow/component-server + - docker build . -t $DOCKER_REGISTRY_WINSLOW/winslow-legacy/component-server - docker login -u $DOCKER_REGISTRY_WINSLOW_USERNAME -p $DOCKER_REGISTRY_WINSLOW_PASSWORD $DOCKER_REGISTRY_WINSLOW - - docker push $DOCKER_REGISTRY_WINSLOW/winslow/component-server + - docker push $DOCKER_REGISTRY_WINSLOW/winslow-legacy/component-server dependencies: - build From 901ed46e94d1a477d7fba00fa5d76b0de62cbb60 Mon Sep 17 00:00:00 2001 From: Stefan Kaufmann Date: Tue, 16 Jan 2024 13:35:57 +0100 Subject: [PATCH 4/4] revert from legacy, to prevent false docker pushes --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef98d8c7c..1ffa311dd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,9 +54,9 @@ deploy: script: # - ./build-docker-image.sh - ls -lah . - - docker build . -t $DOCKER_REGISTRY_WINSLOW/winslow-legacy/component-server + - docker build . -t $DOCKER_REGISTRY_WINSLOW/winslow/component-server - docker login -u $DOCKER_REGISTRY_WINSLOW_USERNAME -p $DOCKER_REGISTRY_WINSLOW_PASSWORD $DOCKER_REGISTRY_WINSLOW - - docker push $DOCKER_REGISTRY_WINSLOW/winslow-legacy/component-server + - docker push $DOCKER_REGISTRY_WINSLOW/winslow/component-server dependencies: - build