public class SynchronizedTripleStore extends ForwardingTripleStore
TripleStore
wrapper that synchronizes and enforces a proper access to a wrapped
TripleStore
.
This wrapper provides the following guarantees with respect to external access to the wrapped
TripleStore
:
Synchronizer
;TripleStore
and its
TripleTransaction
s, with the only exception of Component.close()
and
TripleTransaction.end(boolean)
which may be called concurrently with other active
operations;TripleStore
and its TripleTransaction
is enforced to
occur strictly in adherence with the lifecycle defined for Component
s (
IllegalStateException
s are returned to the caller otherwise);reset()
of wrapped TripleStore
is called with no transactions
active (this implies waiting for completion of pending transactions);TripleTransaction
is ended, all the iterations previously returned and
still open to be forcedly closed;TripleStore
is closed, pending TripleTransaction
are forcedly
ended with a rollback.Constructor and Description |
---|
SynchronizedTripleStore(TripleStore delegate,
String synchronizerSpec)
Creates a new instance for the wrapped
TripleStore and the Synchronizer
specification string supplied. |
SynchronizedTripleStore(TripleStore delegate,
Synchronizer synchronizer)
Creates a new instance for the wrapped
TripleStore and Synchronizer
specified. |
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. |
protected TripleStore |
delegate() |
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.
|
toString
public SynchronizedTripleStore(TripleStore delegate, String synchronizerSpec)
TripleStore
and the Synchronizer
specification string supplied.delegate
- the wrapped DataStore
synchronizerSpec
- the synchronizer specification string (see Synchronizer
)public SynchronizedTripleStore(TripleStore delegate, Synchronizer synchronizer)
TripleStore
and Synchronizer
specified.delegate
- the wrapped TripleStore
synchronizer
- the synchronizer responsible to regulate the access to the wrapped
TripleStore
protected TripleStore delegate()
delegate
in class ForwardingTripleStore
public 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
init
in class ForwardingTripleStore
IOException
- in case initialization failspublic TripleTransaction begin(boolean readOnly) throws IOException
TripleStore
begin
in interface TripleStore
begin
in class ForwardingTripleStore
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
reset
in class ForwardingTripleStore
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.close
in interface Component
close
in interface Closeable
close
in interface AutoCloseable
close
in class ForwardingTripleStore
Copyright © 2015–2016 FBK-irst. All rights reserved.