use of org.apache.jena.dboe.transaction.txn.TransactionException in project jena by apache.
the class StoreConnection method internalExpel.
/**
* Use via {@link TDBInternal#expel} wherever possible.
* <p>
* Stop managing a location.<br/>
* Use with great care (testing only).
*/
public static synchronized void internalExpel(Location location, boolean force) {
StoreConnection sConn = cache.get(location);
if (sConn == null)
return;
TransactionCoordinator txnCoord = sConn.getDatasetGraphTDB().getTxnSystem().getTxnMgr();
if (!force && txnCoord.countActive() > 0)
throw new TransactionException("Can't expel: Active transactions for location: " + location);
// No transactions at this point
// (or we don't care and are clearing up forcefully.)
sConn.getDatasetGraphTDB().shutdown();
// Done by DatasetGraphTDB()
// txnCoord.shutdown();
sConn.isValid = false;
cache.remove(location);
// Release the lock after the cache is emptied.
if (SystemTDB.DiskLocationMultiJvmUsagePrevention && !location.isMem()) {
if (!sConn.lock.isLockedHere())
SystemTDB.errlog.warn("Location " + location.getDirectoryPath() + " was not locked by this process.");
sConn.lock.unlock();
ProcessFileLock.release(sConn.lock);
}
}
use of org.apache.jena.dboe.transaction.txn.TransactionException in project jena by apache.
the class StoragePrefixesTDB method ensureWriteTxn.
// private void requireTxn() {
// if ( ! txnSystem.isInTransaction() )
// throw new TransactionException("Not on a transaction");
// }
private void ensureWriteTxn() {
Transaction txn = txnSystem.getThreadTransaction();
if (txn == null)
throw new TransactionException("Not in a transaction");
txn.ensureWriteTxn();
}
use of org.apache.jena.dboe.transaction.txn.TransactionException in project jena by apache.
the class Journal method _read.
// -- Journal write cycle.
// read one entry at the channel position.
// Move position to end of read.
private JournalEntry _read() {
if (LOGGING) {
log("read@%-3d >>", channel.position());
}
header.clear();
int lenRead = channel.read(header);
if (lenRead == -1) {
// probably broken file.
throw new TransactionException("Read off the end of a journal file");
// return null;
}
if (lenRead != header.capacity())
throw new TransactionException("Partial read of journal file");
header.rewind();
// Header: (length/4, crc/4, entry/4, component/16)
int len = header.getInt();
int checksum = header.getInt();
header.putInt(posnCRC, 0);
int entryType = header.getInt();
byte[] bytes = new byte[ComponentId.SIZE];
header.get(bytes);
ComponentId component = ComponentId.create(null, bytes);
Adler32 adler = new Adler32();
adler.update(header.array());
ByteBuffer bb = null;
if (len > 0) {
bb = ByteBuffer.allocate(len);
lenRead = channel.read(bb);
if (lenRead != len)
throw new TransactionException("Failed to read the journal entry data: wanted " + len + " bytes, got " + lenRead);
bb.rewind();
adler.update(bb);
bb.rewind();
}
int crc = (int) adler.getValue();
if (checksum != crc)
throw new TransactionException("Checksum error reading from the Journal. " + Integer.toHexString(checksum) + " / " + Integer.toHexString(crc));
JournalEntryType type = JournalEntryType.type(entryType);
JournalEntry entry = new JournalEntry(type, component, bb);
if (LOGGING)
log("read@%-3d >> %s", channel.position(), entry);
return entry;
}
use of org.apache.jena.dboe.transaction.txn.TransactionException in project jena by apache.
the class NodeTableTRDF method writeNodeToTable.
@Override
protected NodeId writeNodeToTable(Node node) {
RDF_Term term = ThriftConvert.convert(node, true);
try {
long x = diskFile.length();
// Paired : [*]
NodeId nid = NodeIdFactory.createPtr(x);
term.write(protocol);
// transport.flush();
return nid;
} catch (TransactionException ex) {
throw ex;
} catch (Exception ex) {
throw new TDBException("NodeTableThrift/Write", ex);
}
}
use of org.apache.jena.dboe.transaction.txn.TransactionException in project jena by apache.
the class StorageTDB method ensureWriteTxn.
// private void requireTxn() {
// if ( ! txnSystem.isInTransaction() )
// throw new TransactionException("Not on a transaction");
// }
private void ensureWriteTxn() {
Transaction txn = txnSystem.getThreadTransaction();
if (txn == null)
throw new TransactionException("Not on a write transaction");
txn.ensureWriteTxn();
}
Aggregations