Skip to content

Commit a5ea62e

Browse files
refactor(triplestore): remove embedded-jena-tdb related code (#2043)
* remove embedded-jena-tdb related code * remove TriplestoreTypes * remove triplestore param from sparql queries in admin * remove triplestore param from sparql queries in v1 * remove triplestore param from sparql queries in v2 * remove more triplestore params * minor improvements * fix: cache calls twirl template instead of resolving it, when trying to build cache from triplestore * fix: more wrong twirl template calls * docs: remove Jena TDB from docs Co-authored-by: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com>
1 parent bdc4f39 commit a5ea62e

180 files changed

Lines changed: 622 additions & 1766 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/05-internals/design/principles/design-overview.md‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,14 @@ SPARQL queries are generated from templates, using the
279279
[Twirl](https://github.com/playframework/twirl) template engine. For
280280
example, if we're querying a resource, the template will contain a
281281
placeholder for the resource's IRI. The templates can be found under
282-
`src/main/twirl/queries/sparql`. In many cases, different SPARQL must
283-
be generated for different triplestores; the Twirl template function
284-
then takes the name of the triplestore as a parameter, and may delegate
285-
to triplestore-specific templates.
282+
`src/main/twirl/queries/sparql`.
286283

287-
Responders are not expected to know which triplestore is being used or how it
288-
is accessed. To perform a SPARQL SELECT query, a responder sends a `SparqlSelectRequest`
284+
To perform a SPARQL SELECT query, a responder sends a `SparqlSelectRequest`
289285
message to the `storeManager` actor, like this:
290286

291287
```scala
292288
for {
293289
isEntityUsedSparql <- Future(queries.sparql.v2.txt.isEntityUsed(
294-
triplestore = settings.triplestoreType,
295290
entityIri = entityIri,
296291
ignoreKnoraConstraints = ignoreKnoraConstraints,
297292
ignoreRdfSubjectAndObject = ignoreRdfSubjectAndObject

‎docs/05-internals/design/principles/store-module.md‎

Lines changed: 9 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
## Overview
99

10+
**GraphDB and embedded Jena TDB triplestores support is deprecated** since
11+
[v20.1.1](https://github.com/dasch-swiss/dsp-api/releases/tag/v20.1.1) of DSP-API.
12+
1013
The store module houses the different types of data stores supported by
1114
Knora. At the moment, only triplestores and IIIF servers (Sipi) are supported.
1215
The triplestore support is implemented in the
@@ -20,170 +23,16 @@ which is started when Knora starts. The `StoreManager` then starts the
2023
`TriplestoreManager` and `IIIFManager`, which each in turn starts their
2124
correct actor implementation.
2225

23-
## HTTP-based Triplestores
24-
25-
HTTP-based triplestore support is implemented in the
26-
`org.knora.webapi.triplestore.http` package.
27-
28-
An HTTP-based triplestore is one that is accessed remotely over the HTTP
29-
protocol. `HttpTriplestoreConnector` supports the open source triplestore
30-
- [Apache Jena Fuseki](https://jena.apache.org).
31-
32-
### Apache Jena Fuseki
33-
34-
## Embedded Triplestores
35-
36-
Embedded triplestores are implemented in the
37-
`org.knora.webapi.triplestore.embedded` package.
38-
39-
An embedded triplestore is one that runs in the same JVM as the Knora
40-
API server.
41-
42-
### Apache Jena TDB
43-
44-
The support for embedded Jena TDB is currently dropped. The
45-
documentation and the code will remain in the repository. You can use it
46-
at your own risk.
47-
48-
The support for the embedded Jena-TDB triplestore is implemented in
49-
`org.knora.webapi.triplestore.embedded.JenaTDBActor`.
50-
51-
The relevant Jena libraries that are used are the following:
52-
53-
- Jena API - The library used to work programmatically with RDF data
54-
- Jena TDB - Their implementation of a triple store
55-
56-
#### Concurrency
57-
58-
Jena provides concurrency on different levels.
59-
60-
On the Jena TDB level there is the `Dataset` object, representing the
61-
triple store. On every access, a transaction (read or write) can be
62-
started.
63-
64-
On the Jena API level there is a `Model` object, which is equivalent to
65-
an RDF `Graph`. Here we can lock the model, so that MRSW (Multiple
66-
Reader Single Writer) access is allowed.
67-
68-
- <https://jena.apache.org/documentation/tdb/tdb_transactions.html>
69-
- <https://jena.apache.org/documentation/notes/concurrency-howto.html>
26+
## Triplestores
7027

71-
#### Implementation
28+
Currently, the only supported triplestore is [Apache Jena Fuseki](https://jena.apache.org), a HTTP-based triplestore.
7229

73-
We employ transactions on the `Dataset` level. This means that every
74-
thread that accesses the triplestore, starts a read or write enabled
75-
transaction.
30+
HTTP-based triplestore support is implemented in the `org.knora.webapi.triplestore.http` package.
7631

77-
The transaction mechanism in TDB is based on write-ahead-logging. All
78-
changes made inside a write-transaction are written to journals, then
79-
propagated to the main database at a suitable moment. This design allows
80-
for read-transactions to proceed without locking or other overhead over
81-
the base database.
82-
83-
Transactional TDB supports one active write transaction, and multiple
84-
read transactions at the same time. Read-transactions started before a
85-
write-transaction commits see the database in a state without any
86-
changes visible. Any transaction starting after a write-transaction
87-
commits sees the database with the changes visible, whether fully
88-
propagates back to the database or not. There can be active read
89-
transactions seeing the state of the database before the updates, and
90-
read transactions seeing the state of the database after the updates
91-
running at the same time.
92-
93-
#### Configuration
94-
95-
In `application.conf` set to use the embedded triplestore:
96-
97-
```
98-
triplestore {
99-
dbtype = "embedded-jena-tdb"
100-
101-
embedded-jena-tdb {
102-
persisted = true // "false" -> memory, "true" -> disk
103-
loadExistingData = false // "false" -> use data if exists, "false" -> create a fresh store
104-
storage-path = "_TMP" // ignored if "memory"
105-
}
106-
107-
reload-on-start = false // ignored if "memory" as it will always reload
108-
109-
rdf-data = [
110-
{
111-
path = "knora-ontologies/knora-base.ttl"
112-
name = "http://www.knora.org/ontology/knora-base"
113-
}
114-
{
115-
path = "knora-ontologies/salsah-gui.ttl"
116-
name = "http://www.knora.org/ontology/salsah-gui"
117-
}
118-
{
119-
path = "test_data/ontologies/incunabula-onto.ttl"
120-
name = "http://www.knora.org/ontology/0803/incunabula"
121-
}
122-
{
123-
path = "test_data/demo_data/incunabula-demo-data.ttl"
124-
name = "http://www.knora.org/data/incunabula"
125-
}
126-
{
127-
path = "test_data/ontologies/images-onto.ttl"
128-
name = "http://www.knora.org/ontology/0804/dokubib"
129-
}
130-
{
131-
path = "test_data/demo_data/images-demo-data.ttl"
132-
name = "http://www.knora.org/data/dokubib"
133-
}
134-
]
135-
}
136-
```
137-
138-
Here the storage is set to `persistent`, meaning that a Jena TDB store
139-
will be created under the defined `tdb-storage-path`. The
140-
`reload-on-start` flag, if set to `true` would reload the triplestore
141-
with the data referenced in `rdf-data`.
142-
143-
#### TDB Disk Persisted Store
144-
145-
Make sure to set `reload-on-start` to `true` if run for the first time.
146-
This will create a TDB store and load the data.
147-
148-
If only *read access* is performed, then Knora can be run once with
149-
reloading enabled. After that, reloading can be turned off, and the
150-
persisted TDB store can be reused, as any data found under the
151-
`tdb-storage-path` will be reused.
152-
153-
If the TDB storage files get corrupted, then just delete the folder and
154-
reload the data anew.
155-
156-
#### Actor Messages
157-
158-
- `ResetTripleStoreContent(rdfDataObjects: List[RdfDataObject])`
159-
- `ResetTripleStoreContentACK()`
160-
161-
The embedded Jena TDB can receive reset messages, and will ACK when
162-
reloading of the data is finished. `RdfDataObject` is a simple case
163-
class, containing the path and name (the same as `rdf-data` in the
164-
config file)
165-
166-
As an example, to use it inside a test you could write something like:
167-
168-
```scala
169-
val rdfDataObjects = List (
170-
RdfDataObject(path = "knora-ontologies/knora-base.ttl",
171-
name = "http://www.knora.org/ontology/knora-base"),
172-
RdfDataObject(path = "knora-ontologies/salsah-gui.ttl",
173-
name = "http://www.knora.org/ontology/salsah-gui"),
174-
RdfDataObject(path = "test_data/ontologies/incunabula-onto.ttl",
175-
name = "http://www.knora.org/ontology/0803/incunabula"),
176-
RdfDataObject(path = "test_data/all_data/incunabula-data.ttl",
177-
name = "http://www.knora.org/data/incunabula")
178-
)
32+
An HTTP-based triplestore is one that is accessed remotely over the HTTP
33+
protocol. `HttpTriplestoreConnector` supports the open source triplestore [Apache Jena Fuseki](https://jena.apache.org).
17934

180-
"Reload data " in {
181-
storeManager ! ResetTripleStoreContent(rdfDataObjects)
182-
expectMsg(300.seconds, ResetTripleStoreContentACK())
183-
}
184-
```
18535

18636
## IIIF Servers
18737

188-
Currently, only support for SIPI is implemented in
189-
`org.knora.webapi.store.iiifSipiConnector`.
38+
Currently, only support for SIPI is implemented in `org.knora.webapi.store.iiifSipiConnector`.

‎docs/05-internals/development/overview.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ installation of Knora. The different parts are:
2424
A number of triplestore implementations are available, including [free
2525
software](http://www.gnu.org/philosophy/free-sw.en.html) as well as
2626
proprietary options. DSP-API is designed to work with any
27-
standards-compliant triplestore. It is primarily tested with [Apache Jena](https://jena.apache.org/).
27+
standards-compliant triplestore. It is primarily tested with [Apache Jena Fuseki](https://jena.apache.org/).
2828

2929
## Sipi
3030

‎webapi/src/main/resources/application.conf‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ app {
510510
triplestore {
511511
dbtype = "fuseki"
512512
dbtype = ${?KNORA_WEBAPI_TRIPLESTORE_DBTYPE}
513-
// dbtype = "embedded-jena-tdb"
514513
// dbtype = "fake-triplestore"
515514

516515
use-https = false
@@ -540,17 +539,6 @@ app {
540539
password = ${?KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD}
541540
}
542541

543-
embedded-jena-tdb {
544-
persisted = true // "false" -> memory, "true" -> disk
545-
loadExistingData = false // "false" -> use data if exists, "false" -> create a fresh store
546-
storage-path = "_TMP" // ignored if "memory"
547-
}
548-
549-
fake-jena-tdb {
550-
fake-persisted-storage = true
551-
fake-triplestore-data-dir = "src/main/resources/query-log"
552-
}
553-
554542
reload-on-start = false // ignored if "memory" as it will always reload
555543

556544
# This data is automatically loaded during resetting of the triple store content initiated

‎webapi/src/main/scala/org/knora/webapi/responders/Responder.scala‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@
66
package org.knora.webapi
77
package responders
88

9-
import exceptions.{BadRequestException, DuplicateValueException, UnexpectedMessageException}
10-
import messages.store.triplestoremessages.SparqlSelectRequest
11-
import messages.util.ResponderData
12-
import messages.util.rdf.SparqlSelectResult
13-
import messages.{SmartIri, StringFormatter}
14-
import settings.{KnoraDispatchers, KnoraSettings, KnoraSettingsImpl}
15-
import akka.actor.{ActorRef, ActorSystem}
9+
import akka.actor.ActorRef
10+
import akka.actor.ActorSystem
1611
import akka.event.LoggingAdapter
1712
import akka.http.scaladsl.util.FastFuture
1813
import akka.pattern._
1914
import akka.util.Timeout
20-
import com.typesafe.scalalogging.{LazyLogging, Logger}
15+
import com.typesafe.scalalogging.LazyLogging
16+
import com.typesafe.scalalogging.Logger
2117
import org.knora.webapi.store.cacheservice.settings.CacheServiceSettings
2218

23-
import scala.concurrent.{ExecutionContext, Future}
19+
import scala.concurrent.ExecutionContext
20+
import scala.concurrent.Future
2421
import scala.language.postfixOps
2522

23+
import exceptions.{BadRequestException, DuplicateValueException, UnexpectedMessageException}
24+
import messages.store.triplestoremessages.SparqlSelectRequest
25+
import messages.util.ResponderData
26+
import messages.util.rdf.SparqlSelectResult
27+
import messages.{SmartIri, StringFormatter}
28+
import settings.{KnoraDispatchers, KnoraSettings, KnoraSettingsImpl}
29+
2630
/**
2731
* Responder helper methods.
2832
*/
@@ -118,7 +122,6 @@ abstract class Responder(responderData: ResponderData) extends LazyLogging {
118122
isEntityUsedSparql <- Future(
119123
org.knora.webapi.messages.twirl.queries.sparql.v2.txt
120124
.isEntityUsed(
121-
triplestore = settings.triplestoreType,
122125
entityIri = entityIri,
123126
ignoreKnoraConstraints = ignoreKnoraConstraints,
124127
ignoreRdfSubjectAndObject = ignoreRdfSubjectAndObject
@@ -145,7 +148,6 @@ abstract class Responder(responderData: ResponderData) extends LazyLogging {
145148
isClassUsedInDataSparql <- Future(
146149
org.knora.webapi.messages.twirl.queries.sparql.v2.txt
147150
.isClassUsedInData(
148-
triplestore = settings.triplestoreType,
149151
classIri = classIri
150152
)
151153
.toString()

‎webapi/src/main/scala/org/knora/webapi/responders/admin/GroupsResponderADM.scala‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ import org.knora.webapi._
1111
import org.knora.webapi.exceptions._
1212
import org.knora.webapi.feature.FeatureFactoryConfig
1313
import org.knora.webapi.messages.IriConversions._
14+
import org.knora.webapi.messages.OntologyConstants
15+
import org.knora.webapi.messages.SmartIri
1416
import org.knora.webapi.messages.admin.responder.groupsmessages._
15-
import org.knora.webapi.messages.admin.responder.projectsmessages.{ProjectADM, ProjectGetADM, ProjectIdentifierADM}
17+
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectADM
18+
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectGetADM
19+
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM
1620
import org.knora.webapi.messages.admin.responder.usersmessages._
1721
import org.knora.webapi.messages.admin.responder.valueObjects.GroupStatus
1822
import org.knora.webapi.messages.store.triplestoremessages._
23+
import org.knora.webapi.messages.util.KnoraSystemInstances
24+
import org.knora.webapi.messages.util.ResponderData
1925
import org.knora.webapi.messages.util.rdf.SparqlSelectResult
20-
import org.knora.webapi.messages.util.{KnoraSystemInstances, ResponderData}
2126
import org.knora.webapi.messages.v1.responder.projectmessages._
22-
import org.knora.webapi.messages.{OntologyConstants, SmartIri}
27+
import org.knora.webapi.responders.IriLocker
28+
import org.knora.webapi.responders.Responder
2329
import org.knora.webapi.responders.Responder.handleUnexpectedMessage
24-
import org.knora.webapi.responders.{IriLocker, Responder}
2530

2631
import java.util.UUID
2732
import scala.concurrent.Future
@@ -88,7 +93,6 @@ class GroupsResponderADM(responderData: ResponderData) extends Responder(respond
8893
sparqlQuery <- Future(
8994
org.knora.webapi.messages.twirl.queries.sparql.admin.txt
9095
.getGroups(
91-
triplestore = settings.triplestoreType,
9296
maybeIri = None
9397
)
9498
.toString()
@@ -210,7 +214,6 @@ class GroupsResponderADM(responderData: ResponderData) extends Responder(respond
210214
sparqlQuery <- Future(
211215
org.knora.webapi.messages.twirl.queries.sparql.admin.txt
212216
.getGroups(
213-
triplestore = settings.triplestoreType,
214217
maybeIri = Some(groupIri)
215218
)
216219
.toString()
@@ -326,7 +329,6 @@ class GroupsResponderADM(responderData: ResponderData) extends Responder(respond
326329
sparqlQueryString <- Future(
327330
org.knora.webapi.messages.twirl.queries.sparql.v1.txt
328331
.getGroupMembersByIri(
329-
triplestore = settings.triplestoreType,
330332
groupIri
331333
)
332334
.toString()
@@ -461,7 +463,6 @@ class GroupsResponderADM(responderData: ResponderData) extends Responder(respond
461463
createNewGroupSparqlString = org.knora.webapi.messages.twirl.queries.sparql.admin.txt
462464
.createNewGroup(
463465
adminNamedGraphIri = OntologyConstants.NamedGraphs.AdminNamedGraph,
464-
triplestore = settings.triplestoreType,
465466
groupIri,
466467
groupClassIri = OntologyConstants.KnoraAdmin.UserGroup,
467468
name = createRequest.name.value,
@@ -726,7 +727,6 @@ class GroupsResponderADM(responderData: ResponderData) extends Responder(respond
726727
org.knora.webapi.messages.twirl.queries.sparql.admin.txt
727728
.updateGroup(
728729
adminNamedGraphIri = "http://www.knora.org/data/admin",
729-
triplestore = settings.triplestoreType,
730730
groupIri,
731731
maybeName = groupUpdatePayload.name.map(_.value),
732732
maybeDescriptions = groupUpdatePayload.descriptions.map(_.value),

0 commit comments

Comments
 (0)