public final class VirtuosoTripleStore extends Object implements TripleStore
TripleStore
implementation accessing an external OpenLink Virtuoso server.
This class stores and access triples in an external Virtuoso triple store, communicating to it
via the Virtuoso Sesame driver. Data modification is performed without relying on Virtuoso
transactions, in order to support bulk loading. When writing data in a read-write
TripleTransaction
, a Virtuoso transaction is thus not created; a marker file is instead
stored and later removed upon successful 'commit' of the TripleTransaction
; in case of
failure, the marker file remain on disk and signals that the triplestore is in a potentially
corrupted state, triggering repopulation starting from master data. Given this mechanism, it is
thus important for the component to be wrapped in a SynchronizedTripleStore
that allows
at most a write transaction at a time, preventing simultaneous read transactions
(synchronization N:WX). Note that configuration, startup, shutdown and management in general of
the Virtuoso server are a responsibility of the user, with the VirtuosoTripleStore
component limiting to access Virtuoso for reading and writing triples.
Constructor and Description |
---|
VirtuosoTripleStore(FileSystem fileSystem,
String host,
Integer port,
String username,
String password)
Creates a new instance based on the supplied most relevant properties.
|
VirtuosoTripleStore(FileSystem fileSystem,
String host,
Integer port,
String username,
String password,
Boolean pooling,
Integer batchSize,
Integer fetchSize,
String markerFilename)
Creates a new instance based the supplied complete set of configuration properties.
|
Modifier and Type | Method and Description |
---|---|
TripleTransaction |
begin(boolean readOnly)
Begins a new read-only / read-write triple store transaction.
|
void |
close()
Closes this
Component object. |
void |
init()
Initializes the
Component with the supplied Runtime object. |
void |
reset()
Resets the triple store contents, possibly recreating or reinitializing the external
services / files this triple store is based on.
|
String |
toString() |
public VirtuosoTripleStore(FileSystem fileSystem, @Nullable String host, @Nullable Integer port, @Nullable String username, @Nullable String password)
fileSystem
- the file system where to store the marker filehost
- the name / IP address of the host where virtuoso is running; if null defaults to
localhostport
- the port Virtuoso is listening to; if null defaults to 1111username
- the username to login into Virtuoso; if null defaults to dbapassword
- the password to login into Virtuoso; if null default to dbapublic VirtuosoTripleStore(FileSystem fileSystem, @Nullable String host, @Nullable Integer port, @Nullable String username, @Nullable String password, @Nullable Boolean pooling, @Nullable Integer batchSize, @Nullable Integer fetchSize, @Nullable String markerFilename)
fileSystem
- the file system where to store the marker filehost
- the name / IP address of the host where virtuoso is running; if null defaults to
localhostport
- the port Virtuoso is listening to; if null defaults to 1111username
- the username to login into Virtuoso; if null defaults to dbapassword
- the password to login into Virtuoso; if null default to dbapooling
- true if connection pooling should be used (impact on performances is
negligible); if null defaults to falsebatchSize
- the number of added/removed triples to buffer on the client before sending them
to Virtuoso as a single chunk; if null defaults to 5000fetchSize
- the number of results (solutions, triples, ...) to fetch from Virtuoso in a
single operation when query results are iterated; if null defaults to 200markerFilename
- the name of the marker file created to signal Virtuoso is being used in a
non-transactional mode; if null defaults to virtuoso.bulk.transactionpublic void init() throws IOException
Component
Component
with the supplied Runtime
object. This method is
called after the instantiation of a Component
and before any other instance method
is called. It provides a Runtime
that can be used to access runtime services such
as locking, serialization and filesystem access. The Component
is allowed to
perform any initialization operation that is necessary in order to become functional; on
failure, these operations may result in a IOException
being thrown.init
in interface Component
IOException
- in case initialization failspublic TripleTransaction begin(boolean readOnly) throws DataCorruptedException, IOException
TripleStore
begin
in interface TripleStore
readOnly
- true if the transaction is not allowed to modify the contents of the
triple store (this allows for optimizing the access to the triple store).DataCorruptedException
- in case a transaction cannot be started due to triple store files being damaged
or non-existing; a TripleStore.reset()
call followed by a full triple store
re-population should be attempted to recover this situationIOException
- if another IO error occurs while starting the transaction, not implying a data
corruption situationpublic void reset() throws IOException
TripleStore
reset
in interface TripleStore
IOException
- if an IO error occurs while resetting the triple store (this situation is not
expected to be recovered automatically via code).public void close()
Component
Component
object. If the component has been initialized, closing a it
causes any allocated resource to be freed and any operation or transaction ongoing within
the component being aborted; in case the component has not been initialized yet, or
close()
has already being called, calling this method has no effect. Note that the
operation affects only the local Component
object and not any remote service this
object may rely on to implement its functionalities; in particular, such a remote service
is not shutdown by the operation, so that it can be accessed by other Component
instances possibly running in other (virtual) machines. Similarly, closing a
Component
object has no impact on stored data, that continues to be persisted and
will be accessed unchanged (provided no external modification occurs) the next time a
similarly configured Component
is created.Copyright © 2015–2016 FBK-irst. All rights reserved.