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
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,34 @@ public class SmartConnectorConfig {
* Key to configure if a KER should use the EDC functionality or not.
*/
public static final String CONF_KEY_KE_RUNTIME_USE_EDC = "ke.runtime.use.edc";

/**
* Key to configure where a KER can reach the protocol API of its own control plane if using EDC.
* Key to configure where a KER can reach the protocol API of its own control
* plane if using EDC.
*/
public static final String CONF_KEY_KE_EDC_PROTOCOL_URL = "ke.edc.protocol.url";

/**
* Key to configure where a KER can reach the management API of its own control plane if using EDC.
* Key to configure where a KER can reach the management API of its own control
* plane if using EDC.
*/
public static final String CONF_KEY_KE_EDC_MANAGEMENT_URL = "ke.edc.management.url";

/**
* Key to configure where a KER can reach its data plane control API if using EDC.
* Key to configure where a KER can reach its data plane control API if using
* EDC.
*/
public static final String CONF_KEY_KE_EDC_DATAPLANE_CONTROL_URL = "ke.edc.dataplane.control.url";

/**
* Key to configure where a KER can reach its data plane public API if using EDC.
* Key to configure where a KER can reach its data plane public API if using
* EDC.
*/
public static final String CONF_KEY_KE_EDC_DATAPLANE_PUBLIC_URL = "ke.edc.dataplane.public.url";

/**
* Key to configure the URL where a KER can do token validation through the control plane if using EDC.
* Key to configure the URL where a KER can do token validation through the
* control plane if using EDC.
*/
public static final String CONF_KEY_KE_EDC_TOKEN_VALIDATION_ENDPOINT = "ke.edc.token.validation.endpoint";

Expand Down Expand Up @@ -120,6 +125,26 @@ public class SmartConnectorConfig {
*/
public static final String CONF_KEY_KE_DOMAIN_KNOWLEDGE_PATH = "ke.domain.knowledge.path";

/**
* Configure the maximum number of entries in the node cache that is being used
* to speed up converting from graph patterns and bindingsets to RDF. See:
* {@code eu.knowledge.engine.smartconnector.impl.Util.nodeCache}
*
*/
public static final String CONF_KEY_KE_CACHE_NODE_SIZE = "ke.cache.node.size";

/**
* Configure the number of minutes of being idle (not accessed) after which a
* cache entry can be evicted from cache.
*/
public static final String CONF_KEY_KE_CACHE_NODE_EXPIRYMINUTES = "ke.cache.node.expiryminutes";

/**
* The main thread pool of the Knowledge Engine Runtime that is used to, among
* other things, deliver messages.
*/
public static final String CONF_KEY_KE_THREADPOOL_SIZE = "ke.threadpool.size";

/**
* Convert the configuration reasoner levels to matching strategies used in the
* reasoner code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.jena.sparql.sse.SSE;
import org.apache.jena.sparql.syntax.ElementPathBlock;
import org.apache.jena.sparql.util.FmtUtils;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.ExpiryPolicyBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
Expand All @@ -33,6 +35,7 @@
import eu.knowledge.engine.smartconnector.api.Binding;
import eu.knowledge.engine.smartconnector.api.BindingSet;
import eu.knowledge.engine.smartconnector.api.GraphPattern;
import eu.knowledge.engine.smartconnector.api.SmartConnectorConfig;

public class Util {
private static final Logger LOG = LoggerFactory.getLogger(Util.class);
Expand All @@ -41,9 +44,15 @@ public class Util {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();

long cacheSize = Long.parseLong(
ConfigProvider.getConfig().getConfigValue(SmartConnectorConfig.CONF_KEY_KE_CACHE_NODE_SIZE).getValue());

long timeInMinutes = Long.parseLong(ConfigProvider.getConfig()
.getConfigValue(SmartConnectorConfig.CONF_KEY_KE_CACHE_NODE_EXPIRYMINUTES).getValue());

CacheConfigurationBuilder<String, Node> ehConfig = CacheConfigurationBuilder
.newCacheConfigurationBuilder(String.class, Node.class, ResourcePoolsBuilder.heap(500_000))
.withExpiry(ExpiryPolicyBuilder.timeToIdleExpiration(java.time.Duration.ofMinutes(10)));
.newCacheConfigurationBuilder(String.class, Node.class, ResourcePoolsBuilder.heap(cacheSize))
.withExpiry(ExpiryPolicyBuilder.timeToIdleExpiration(java.time.Duration.ofMinutes(timeInMinutes)));

Configuration<String, Node> config = Eh107Configuration.fromEhcacheCacheConfiguration(ehConfig);
nodeCache = cacheManager.createCache("nodeCache", config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public class KeRuntime {

// we want to make sure that this threadpool does not keep the JVM alive. So we
// set the daemon to true.
executorService = Executors.newScheduledThreadPool(12, new ThreadFactory() {
int nrOfThreads = Integer.parseInt(
ConfigProvider.getConfig().getConfigValue(SmartConnectorConfig.CONF_KEY_KE_THREADPOOL_SIZE).getValue());
executorService = Executors.newScheduledThreadPool(nrOfThreads, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = Executors.defaultThreadFactory().newThread(r);
Expand Down Expand Up @@ -130,11 +132,11 @@ public static MessageDispatcher getMessageDispatcher() {
.getConfigValue(SmartConnectorConfig.CONF_KEY_KE_RUNTIME_EXPOSED_URL);
URI myExposedUrl = new URI(exposedUrl.getValue());

ConfigValue useEdc = config
.getConfigValue(SmartConnectorConfig.CONF_KEY_KE_RUNTIME_USE_EDC);
ConfigValue useEdc = config.getConfigValue(SmartConnectorConfig.CONF_KEY_KE_RUNTIME_USE_EDC);
var myUseEdc = Boolean.parseBoolean(useEdc.getValue());

messageDispatcher = new MessageDispatcher(myPort, myExposedUrl, new URI(kdUrl.getValue()), myUseEdc);
messageDispatcher = new MessageDispatcher(myPort, myExposedUrl, new URI(kdUrl.getValue()),
myUseEdc);
}
} catch (NumberFormatException | URISyntaxException e) {
LOG.error("Could not parse configuration properties, cannot start Knowledge Engine", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ sc.validate.outgoing.bindings.wrt.incoming.bindings = true
ke.runtime.hostname = localhost
ke.reasoner.level = 2
ke.runtime.use.edc = false
ke.cache.node.size = 500000
ke.cache.node.expiryminutes = 10
ke.threadpool.size = 12

ke.edc.protocol.url =
ke.edc.management.url =
Expand Down