public class FileSourceConnector extends SourceConnector
SourceConnector.IdAndTrans
adminLevelItemNr, adminLevelTripleNr, sourceItemNr
Constructor and Description |
---|
FileSourceConnector(SourceConnectorClient client,
long sourceNr,
java.io.File localDir,
java.io.File specFile,
Logger logger)
Construct a new file source connector.
|
Modifier and Type | Method and Description |
---|---|
SourceConnector.IdAndTrans |
addItem(Id onlyReadLevelId,
Id readOrWriteLevelId)
Add an item
|
void |
close()
Close the source connector
|
void |
create()
Create the source.
|
StoredTriple |
createTriple(Item subject,
Item verb,
Datum object,
Transaction trans)
Create a triple
|
void |
endTransaction(Transaction trans)
End a transaction.
|
Datum |
getBinaryTripleObject(long tripleNr)
Get a stored triple's binary object
|
long |
getHighestItemNr() |
long |
getHighestTripleNr() |
long |
getSourceNr() |
java.lang.Exception |
getTerminator()
Implements the getTerminator() method of SourceConnector
|
Datum |
getTextTripleObject(long tripleNr)
Get a stored triple's text object
|
boolean |
isCompleted(long transSeq)
Determine whether a transaction has completed
|
boolean |
isOwner() |
void |
load()
Load items and triples into a triple store from the connector,
but without adding the items to the triple store's index.
|
void |
loadItem(long itemNr,
long readLevelSourceNr,
long readLevelItemNr,
long writeLevelSourceNr,
long writeLevelItemNr,
int storeRef)
Load an item from the backing store
|
void |
loadTriple(long tripleNr,
long subjectItemNr,
long verbSourceNr,
long verbItemNr,
Datum object,
int storeRef)
Load a triple from the backing store
|
void |
removeItem(long itemNr,
Transaction trans)
Remove an item from the source
|
void |
removeTriple(long tripleNr,
Transaction trans)
Note that a triple is removed from the source.
|
StoredTriple |
replaceTriple(Triple triple,
Datum newObject,
Transaction trans)
Replace a triple in the source by a new triple with the
same subject and verb, but with a new object and a new
numeric identifier
|
void |
simulateIoError()
Simulate an I/O error for testing purposes
|
boolean |
sourceExists()
Determine whether the source exists or must be created.
|
Transaction |
startTransaction()
Start a transaction.
|
void |
updateItem(long itemNr,
Id onlyReadLevelId,
Id readOrWriteLevelId,
Transaction trans)
Update an item in the source
|
addSourceItem, createSourceTriple, endSourceTransaction, getClient, getLocalDir, getSourceBinaryTripleObject, getSourceTextTripleObject, getSpecFile, getSpecFilePath, isDomainSourceNr, isInstallationSourceNr, isOperational, isRegisteredSourceNr, log, makeOperational, removeSourceItem, removeSourceTriple, replaceSourceTriple, startSourceTransaction, stopOperation, updateSourceItem
public FileSourceConnector(SourceConnectorClient client, long sourceNr, java.io.File localDir, java.io.File specFile, Logger logger) throws SourceConnectorException
Construct a new file source connector.
A file source connector can only connect to a private source
directory
- the directory containing the the file backing store
that is the source of items and triplessourceNr
- the numeric identifier of the sourceSourceConnectorStateException
SourceConnectorException
public long getSourceNr()
getSourceNr
in class SourceConnector
public boolean sourceExists() throws SourceConnectorException
SourceConnector
sourceExists
in class SourceConnector
SourceConnectorException
public void create() throws SourceConnectorException, TripleStoreNonFatalException
SourceConnector
Create the source.
A new source is created.
A source must be created, or loaded, but not both, before it can be used.
A source is created with a source item and a source administration access level. The only-read level of the source item is the lowest access level, and its read-or-write level is the highest access level.The only-read level of the source administration access level is the lowest access level, and it is its own read-or-write level.
create
in class SourceConnector
SourceConnectorException
TripleStoreNonFatalException
public void load() throws SourceConnectorException
SourceConnector
Load items and triples into a triple store from the connector, but without adding the items to the triple store's index.
Invoked by the loadFromSource() method to apply a set of deltas that add items and triples in the source to the invoking triple store. This part of the load process is specific to the source. The subsequent part, in which the loaded items are indexed, is handled by the loadFromSource() method.
Note that the deltas may contain deletions as well as additions, and must be applied in order. This implies that the connector must apply deltas adding the items referenced by a triple before applying the delta that adds the triple. However, triples setting access level superiority permissions can be loaded before the triples defining the access levels concerned.
A source must be created, or loaded, but not both, before it can be used.
load
in class SourceConnector
SourceConnectorException
public boolean isOwner()
isOwner
in class SourceConnector
public void close()
SourceConnector
close
in class SourceConnector
public void simulateIoError()
SourceConnector
simulateIoError
in class SourceConnector
public java.lang.Exception getTerminator()
getTerminator
in class SourceConnector
public Transaction startTransaction() throws SourceConnectorException
startTransaction
in class SourceConnector
FileSourceConnectorException
SourceConnectorException
public void endTransaction(Transaction trans) throws SourceConnectorException
End a transaction.
All data written by the transaction is stored on disc, and the transaction is noted as completed.
No check is made that the transaction is not already complete. The results of invoking this method twice for the same transaction are indeterminate.
endTransaction
in class SourceConnector
trans
- a transaction to be endedSourceConnectorException
public boolean isCompleted(long transSeq) throws SourceConnectorException
transSeq
- a transaction sequence numberFileSourceConnectorException
SourceConnectorException
public long getHighestItemNr()
public long getHighestTripleNr()
public void loadItem(long itemNr, long readLevelSourceNr, long readLevelItemNr, long writeLevelSourceNr, long writeLevelItemNr, int storeRef) throws org.lacibus.backingstore.BackingStoreClientException
itemNr
- the numeric identifier of the item in its sourcereadLevelSourceNr
- the numeric identifier of the source of
the only-read access level of the itemreadLevelItemNr
- the numeric identifier in its source of
the only-read access level of the itemwriteLevelSourceNr
- the numeric identifier of the source of
the read-or-write access level of the itemwriteLevelItemNr
- the numeric identifier in its source of
the read-or-write access level of the itemstoreRef
- a reference to the item in the backing storeBackingStoreClientException
public void loadTriple(long tripleNr, long subjectItemNr, long verbSourceNr, long verbItemNr, Datum object, int storeRef) throws org.lacibus.backingstore.BackingStoreClientException
tripleNr
- the numeric identifier of the triple in its sourcesubjectItemNr
- the numeric identifier of the subject of the
triple in its sourceverbSourceNr
- the numeric identifier of the source of the verb
of the tripleverbItemNr
- the numeric identifier of the verb of the triple
in its sourceobject
- the object of the triplestoreRef
- a reference to the triple in the backing storeBackingStoreClientException
public SourceConnector.IdAndTrans addItem(Id onlyReadLevelId, Id readOrWriteLevelId) throws SourceConnectorException
SourceConnector
addItem
in class SourceConnector
onlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to haveSourceConnectorException
public void updateItem(long itemNr, Id onlyReadLevelId, Id readOrWriteLevelId, Transaction trans) throws SourceConnectorException
SourceConnector
updateItem
in class SourceConnector
itemNr
- the numeric identifier of the item in the sourceonlyReadLevelId
- the identifier of the item representing
the only-read access level that the item is to havereadOrWriteLevelId
- the identifier of the item representing
the read-or-write access level that the item is to havetrans
- the transaction of which this operation is a partSourceConnectorException
public void removeItem(long itemNr, Transaction trans) throws SourceConnectorException
SourceConnector
removeItem
in class SourceConnector
itemNr
- the numeric identifier of the item in the sourcetrans
- the transaction of which this operation is a partSourceConnectorException
public StoredTriple createTriple(Item subject, Item verb, Datum object, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
SourceConnector
createTriple
in class SourceConnector
subject
- the triple's subjectverb
- the triple's verbobject
- the triple's objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public StoredTriple replaceTriple(Triple triple, Datum newObject, Transaction trans) throws SourceConnectorException, TripleStoreNonFatalException
SourceConnector
replaceTriple
in class SourceConnector
triple
- the triple to be replacednewObject
- the triple's new objecttrans
- the transaction of which this operation is a partSourceConnectorException
TripleStoreNonFatalException
public void removeTriple(long tripleNr, Transaction trans) throws SourceConnectorException
SourceConnector
removeTriple
in class SourceConnector
tripleNr
- the numeric identifier within the source of the
triple to be removedtrans
- the transaction of which this operation is a partSourceConnectorException
public Datum getTextTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
SourceConnector
getTextTripleObject
in class SourceConnector
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException
public Datum getBinaryTripleObject(long tripleNr) throws SourceConnectorException, TripleStoreNonFatalException
SourceConnector
getBinaryTripleObject
in class SourceConnector
tripleNr
- the numeric identifier in its source of a stored
tripleSourceConnectorException
TripleStoreNonFatalException