Skip to content

FedX in RDF4J Server

Andreas Schwarte edited this page Apr 8, 2019 · 1 revision

FedX can be configured as a Repository in the RDF4J Workbench, e.g. to use the inherent infrastructure for publishing the federation as a single SPARQL endpoint.

Steps

  • Follow the documentation on http://docs.rdf4j.org/server-workbench-console/ to setup and deploy the RDF4J workbench
  • Start the RDF4J workbench once and make sure it is running. Then shutdown the webserver
  • Deploy the FedX binary (i.e. fedx-6.0.0.jar) in the rdf4j-server webapp (e.g. in a standard Tomcat installation to /webapps/rdf4j-server/WEB-INF/lib/fedx-6.0.0.jar)
  • Optionally configure the rdf4j-server web application to inject the RDF4J repository resolver into FedX (see next section for details)
  • Create a FedX repository
  • Restart the RDF4J workbench and check the state of the FedX federation

Notes

*Logging output can be found in _logs/main.log _(in the RDF4J application directory) as well as in the tomcat logs (e.g. catalina.out and catalina.log)

Injecting the RDF4J repository manager into FedX

In order to access a repository managed within the RDF4J Server itself (e.g. a local native store), FedX needs to be made aware of how to resolve the repository. This can be achieved by injecting the RDF4J repository manager into FedX as described in the following.

  • Locate the rdf4j-server webapp configuration (e.g. <TOMCAT-HOME>/webapps/rdf4j-server/WEB-INF/rdf4j-http-server-servlet.xml)
  • Add the following snippet below the definition of the rdf4jRepositoryManager bean to configure the FedX repository resolver
<!-- Inject the local repository manager as RepositoryResolver into FedX -->
<bean id="fedxRepositoryResolver"
	class="com.fluidops.fedx.repository.FedXRepositoryResolverBean"
	scope="singleton" init-method="init" destroy-method="destroy">
	<property name="repositoryResolver" ref="rdf4jRepositoryManager" />
</bean>

With this configuration it is possible to reference any existing repository managed by the RDF4J Server as ResolvableEndpoint in the data configuration. See below for an example.

Sample Repository configuration

<!-- Inject the local repository manager as RepositoryResolver into FedX -->
<bean id="fedxRepositoryResolver"
	class="com.fluidops.fedx.repository.FedXRepositoryResolverBean"
	scope="singleton" init-method="init" destroy-method="destroy">
	<property name="repositoryResolver" ref="rdf4jRepositoryManager" />
</bean>

Repositories in the RDF4J workbench are configured using config.ttl file in the repositories folder of the application directory.

Each repository is represented by a folder (i.e. the data directory) and a _config.ttl _file. For FedX we require two additional files, the fedx configuration file and the data configuration file (representing the federation members).

In order to configure FedX create the configuration the samples below. If the configuration was successful, you can access the SPARQL endpoint at http://localhost:8080/rdf4j-workbench/repositories/%myFederation%/summary. The SPARQL endpoint is accessible at http://localhost:8080/rdf4j-server/repositories/%myFederation%.

Directory structure

/repositories
  + myFederation
    - config.ttl
    - fedxConfig.prop
    - dataConfig.ttl

Note that myFederation is the repository identifier in the RDF4J workbench. This must the same as the repositoryId in config.ttl.

config.ttl

#
# RDF4J configuration template for a FedX Repository
#
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rep: <http://www.openrdf.org/config/repository#> .
@prefix fedx: <http://www.fluidops.com/config/fedx#> .

[] a rep:Repository ;
   rep:repositoryImpl [
      rep:repositoryType "fedx:FedXRepository" ;
      fedx:fedxConfig "fedxConfig.prop" ;
      fedx:dataConfig "dataConfig.ttl" ;
   ];
   rep:repositoryID "myFederation" ;
   rdfs:label "FedX Federation" .

Note that locations are relative to the FedX data directory.

fedxConfig.prop

Specifies the configuration of FedX, see the documentation on configuration for details.

# FedX Configuration
#
# Have a look at the documentation to get information on
# possible configuration settings

#debugQueryPlan = true

dataConfig.ttl

This file specifies the federation members, see the documentation on data configurations for details.

@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
@prefix fedx: <http://www.fluidops.com/config/fedx#> .

<http://myNtiveStore> a sd:Service ;
	fedx:store "ResolvableRepository" ;
	fedx:repositoryName "myNativeStore" .
	
<http://DBpedia> a sd:Service ;
	fedx:store "SPARQLEndpoint";
	fedx:SPARQLEndpoint "http://dbpedia.org/sparql";
	fedx:supportsASKQueries "false" .