Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=org.ceskaexpedice
version=1.3
version=1.4-dev
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,31 @@ private List<PluginInfo> scanPlugins() {

private void registerNode(List<PluginInfo> pluginsList) {
LOGGER.info(String.format("Register node [%s]", workerConfiguration.getWorkerId()));
Set<String> tags = new HashSet<>();
// Supported profiles from plugins
Set<String> supportedProfiles = new HashSet<>();
for (PluginInfo pluginInfo : pluginsList) {
for (PluginProfile pluginProfile: pluginInfo.getProfiles()){
tags.add(pluginProfile.getProfileId());
for (PluginProfile pluginProfile : pluginInfo.getProfiles()) {
supportedProfiles.add(pluginProfile.getProfileId());
}
}
// Configured subset
Set<String> configuredSubset = workerConfiguration.getProfilesSubset();
Set<String> tags;
if (configuredSubset.isEmpty()) {
// No filtering configured → use all supported
tags = supportedProfiles;
} else {
tags = new HashSet<>();
for (String profile : configuredSubset) {
if (supportedProfiles.contains(profile)) {
tags.add(profile);
} else {
LOGGER.warning(String.format(
"Profile [%s] configured in %s is not supported by this worker",
profile,
WorkerConfiguration.PROFILES_SUBSET_KEY
));
}
}
}
Node node = new Node();
Expand All @@ -82,7 +103,6 @@ private void registerNode(List<PluginInfo> pluginsList) {
node.setType(NodeType.WORKER);
node.setUrl(workerConfiguration.getWorkerBaseUrl());
node.setTags(tags);

managerClient.registerNode(node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import java.util.stream.Collectors;

import static org.ceskaexpedice.processplatform.worker.utils.Utils.parseSimpleJson;

Expand All @@ -41,6 +39,7 @@ public class WorkerConfiguration {
private static final String MANAGER_BASE_URL_KEY = "MANAGER_BASE_URL";
private static final String WORKER_BASE_URL_KEY = "WORKER_BASE_URL";
private static final String WORKER_ID_KEY = "WORKER_ID";
public static final String PROFILES_SUBSET_KEY = "PROFILES_SUBSET";

private final Properties props = new Properties();

Expand Down Expand Up @@ -141,6 +140,17 @@ public String getManagerBaseUrl() {
return "http://localhost:8080/";
}

public Set<String> getProfilesSubset() {
String subsetValue = get(WorkerConfiguration.PROFILES_SUBSET_KEY);
if (subsetValue == null || subsetValue.isBlank()) {
return Collections.emptySet();
}
return Arrays.stream(subsetValue.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toSet());
}

public void setManagerBaseUrl(String managerBaseUrl) {
set(MANAGER_BASE_URL_KEY, managerBaseUrl);
}
Expand Down
1 change: 1 addition & 0 deletions process-worker/src/main/resources/worker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ MANAGER_BASE_URL=-none-
WORKER_BASE_URL=-none-
WORKER_ID=-none-
WORKER_LOOP_SLEEP_SECS=10
#PROFILES_SUBSET=profile1,profile2