LiUSemWeb / HeFQUIN

HeFQUIN is a query federation engine for heterogeneous federations of graph data sources, including federations of knowledge graphs.
https://liusemweb.github.io/HeFQUIN/
Apache License 2.0
19 stars 3 forks source link

Basic web service #338

Closed keski closed 3 months ago

keski commented 5 months ago

Provides a basic server implementation that keeps a HeFQUINEngine instance running in the background. The service provides a REST API based on the SPARQL HTTP protocol. Tests are included for POST and GET requests and common media types. Resolves issue #332.

hartig commented 5 months ago

The automatic (Github Actions based) check of building this PR using Maven has failed. Looking at the error messages, it seems that the Spring Boot classes are not in the build path.

hartig commented 5 months ago

After pulling the branch of this PR to my laptop, I just tried mvn package and it runs through without any problems. In fact, it even runs all our unit tests, plus the 15 new tests added as part of this PR.

So, the Github Action that runs the automatic check of the PR on Github doesn't seem to pick up the pom file within this PR. I will take a look.

Also, can you please remind me of how to run the service after the successful build.

hartig commented 5 months ago

@keski I now tried mvn clean package on my laptop and it worked as well (i.e., with running the unit tests).

hartig commented 5 months ago

@keski Compiling of the automatic build for this PR is still failing. To make sure that it really picks up the POM file in the PR, I changed the HeFQUIN version in that POM file. The build log shows the new version but it fails nonetheless. Can you please take a look at the log and check whether you see something strange.

keski commented 3 months ago

@hartig This branch has now been refactored completely. The new web service (servlet) is compiled as a war file during normal build and has been confirmed to work on Jetty and Tomcat. All tests are now working.

hartig commented 3 months ago

Great! I can confirm that it compiles (mvn package) on my computer.

Two questions:

  1. How do I start the service?
  2. Once it is started, I can (currently) access it only via curl (or some other direct HTTP interaction) but not in a Web browser, right?
keski commented 3 months ago
  1. How do I start the service?

The war file needs to be deployed in a servlet container, such as Jetty or Tomcat. For example, using docker we can run it using:

$ mvn clean package
$ docker run --rm \
  -p 8080:8080 \
  -v ./target/HeFQUIN-0.0.4-SNAPSHOT.war:/usr/local/tomcat/webapps/ROOT.war \
  tomcat:latest

(This is similar to the approach used in #339)

But providing a way to run it directly seems really useful... I've just pushed an update so that we can now use Jetty as an embedded server (deploying as war still works). Now the embedded server can also be run using:

$ java -cp target/HeFQUIN-0.0.4-SNAPSHOT.jar se.liu.ida.hefquin.service.HeFQUINServer

Once it is started, I can (currently) access it only via curl (or some other direct HTTP interaction) but not in a Web browser, right?

That is correct. At the start page (e.g., http://localhost:8080) there is a description of the API/protocol. It is of course possible to run GET queries directly in the browser but we currently don't provide an actual query editor.

hartig commented 3 months ago

Thanks for the clarification and for the update to use Jetty as an embedded server!

I confirm that running

java -cp target/HeFQUIN-0.0.4-SNAPSHOT.jar se.liu.ida.hefquin.service.HeFQUINServer

works and starts up the service.

Just one remaining observation: After starting the service and going to http://localhost:8080 in my browser, instead of seeing the index.html page with the API description, I see a page saying

{"error": "SPARQL query is missing or empty"}

Yet, that's a minor thing. If you have an immediate idea how to fix this issue, please implement it still in this PR. Otherwise, I am fine with merging the PR as is. Let me know.

keski commented 3 months ago

Oh, I see. I forgot to add a link the html file in HeFQUINServer.java. I've now updated it so that it instead uses the web.xml so that it behaves the same way as the deployed war.