Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, RemoteKerConnection> remoteKerConnections = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<URI> getRemoteSmartConnectorIds() {
List<URI> list = new ArrayList<>();
for (RemoteKerConnection remoteKerConnection : remoteKerConnections.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading