From bce1f47b26bebb5cbb4a87c108f47eba8a13f151 Mon Sep 17 00:00:00 2001 From: Barry Nouwt Date: Tue, 10 Nov 2026 16:47:57 +0100 Subject: [PATCH] Make KD update interval configurable. --- .../smartconnector/api/SmartConnectorConfig.java | 6 ++++++ .../messaging/RemoteKerConnectionManager.java | 16 +++++++++------- .../META-INF/microprofile-config.properties | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/SmartConnectorConfig.java b/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/SmartConnectorConfig.java index 5f066917f..064c35ad6 100644 --- a/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/SmartConnectorConfig.java +++ b/smart-connector-api/src/main/java/eu/knowledge/engine/smartconnector/api/SmartConnectorConfig.java @@ -23,6 +23,12 @@ public class SmartConnectorConfig { */ public static final String CONF_KEY_KD_URL = "kd.url"; + /** + * Key to configure the update interval of the Knowledge Directory which + * determines how often this KER queries the KD to discover other KERs. + */ + public static final String CONF_KEY_KD_UPDATE_INTERVAL = "kd.update.interval"; + /** * Key to configure the time in seconds the SCs in this KER wait for a HTTP * connection response from another KER. Only used in distributed mode. diff --git a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java index 3a51f9173..d1f17da40 100644 --- a/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java +++ b/smart-connector/src/main/java/eu/knowledge/engine/smartconnector/runtime/messaging/RemoteKerConnectionManager.java @@ -12,10 +12,12 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import org.eclipse.microprofile.config.ConfigProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import eu.knowledge.engine.smartconnector.api.SmartConnector; +import eu.knowledge.engine.smartconnector.api.SmartConnectorConfig; import eu.knowledge.engine.smartconnector.edc.EdcConnectorService; import eu.knowledge.engine.smartconnector.edc.ParticipantProperties; import eu.knowledge.engine.smartconnector.edc.TransferProcess; @@ -38,7 +40,6 @@ public class RemoteKerConnectionManager extends SmartConnectorManagementApiServi private static final Logger LOG = LoggerFactory.getLogger(RemoteKerConnectionManager.class); - private static final int KNOWLEDGE_DIRECTORY_UPDATE_INTERVAL = 60; private static final int KNOWLEDGE_DIRECTORY_UPDATE_COOLDOWN = 2; private final RemoteMessageReceiver messageReceiver; private final Map remoteKerConnections = new ConcurrentHashMap<>(); @@ -68,7 +69,7 @@ public void start() { } catch (Throwable t) { LOG.error("", t); } - }, 5, KNOWLEDGE_DIRECTORY_UPDATE_INTERVAL, TimeUnit.SECONDS); + }, 5, this.getKnowledgeDirectoryUpdateInterval(), TimeUnit.SECONDS); // configure our EDC Connector with the TKE asset if (useEdc) { @@ -130,11 +131,8 @@ private synchronized void queryKnowledgeDirectory() { RemoteKerConnection messageSender; if (useEdc) { - ParticipantProperties participant = new ParticipantProperties( - knowledgeEngineRuntime.getId(), - knowledgeEngineRuntime.getEdcConnectorUrl(), - knowledgeEngineRuntime.getExposedUrl() - ); + ParticipantProperties participant = new ParticipantProperties(knowledgeEngineRuntime.getId(), + knowledgeEngineRuntime.getEdcConnectorUrl(), knowledgeEngineRuntime.getExposedUrl()); TransferProcess transferProcess = this.edcService.createTransferProcess(participant); messageSender = new RemoteKerConnection(messageDispatcher, knowledgeEngineRuntime, transferProcess); @@ -276,6 +274,10 @@ public RemoteMessageReceiver getMessageReceiver() { return messageReceiver; } + private int getKnowledgeDirectoryUpdateInterval() { + return ConfigProvider.getConfig().getValue(SmartConnectorConfig.CONF_KEY_KD_UPDATE_INTERVAL, Integer.class); + } + public List getRemoteSmartConnectorIds() { List list = new ArrayList<>(); for (RemoteKerConnection remoteKerConnection : remoteKerConnections.values()) { diff --git a/smart-connector/src/main/resources/META-INF/microprofile-config.properties b/smart-connector/src/main/resources/META-INF/microprofile-config.properties index 9273a62bd..1e02758af 100644 --- a/smart-connector/src/main/resources/META-INF/microprofile-config.properties +++ b/smart-connector/src/main/resources/META-INF/microprofile-config.properties @@ -4,6 +4,7 @@ ke.runtime.exposed.url = http://${ke.runtime.hostname}:${ke.runtime.port} ke.kb.wait.timeout = 10 ke.http.timeout = 5 kd.url = http://localhost:8080 +kd.update.interval = 60 sc.validate.outgoing.bindings.wrt.incoming.bindings = true ke.runtime.hostname = localhost ke.reasoner.level = 2