class BackEnd extends Object implements Observer
Likewise, cancels will cause the removal of write and register records. Also renew records update the expiration of the entry or registration and are not stored directly in the database.
Modifier and Type | Class and Description |
---|---|
private class |
BackEnd.ConsumerThread
Thread to consume log files.
|
private static class |
BackEnd.LastLog
This class remembers which log file was the last to be
successfully consumed.
|
Modifier and Type | Field and Description |
---|---|
private BackEnd.ConsumerThread |
consumer
Log file consumer thread.
|
private Map<ByteArrayWrapper,Resource> |
entries |
private StoredObject |
joinState |
private BackEnd.LastLog |
lastLog |
private String |
logFileBase
The base name for the log files.
|
private static Logger |
logger
Logger for logging persistent store related information
|
private Map<Long,PendingTxn> |
pendingTxns |
private Map<ByteArrayWrapper,Registration> |
registrations |
private java.util.concurrent.atomic.AtomicLong |
sessionId |
private static int |
SNAPSHOT_VERSION
Keep logs and snapshot tied, though not necessary
|
private SnapshotFile |
snapshotFile
Snapshot object
|
private String |
snapshotFileBase
The base name for the snapshot files
|
private byte[] |
topUuid |
private static long |
WAIT_FOR_THREAD
Max time to wait for the consumer thread to die on destroy
|
Constructor and Description |
---|
BackEnd(String path)
Create a new
BackEnd with the given path . |
Modifier and Type | Method and Description |
---|---|
(package private) void |
abortOp(Long txnId)
This method aborts a pending transaction.
|
(package private) void |
bootOp(long time,
long session)
This method sets the session id in the database.
|
(package private) void |
cancelOp(byte[] cookie)
This method processes a logged cancel operation.
|
(package private) void |
close()
Stop the consumer and close the database.
|
(package private) void |
commitOp(Long txnId)
This method commits a pending transaction.
|
private void |
consumeLogs(boolean all)
Consume the log files that exist.
|
(package private) void |
destroy()
Destroy the consumer thread and database
|
(package private) void |
joinStateOp(StoredObject state)
Record the join state.
|
private InternalSpaceException |
logAndThrowRecoveryException(String msg,
Throwable nested)
Log and throw an InternalSpaceException to flag a store
recovery problem.
|
private PendingTxn |
pendingTxn(Long txnId)
Return the pending transaction description for the given
transaction, creating the object and adding it to the table if
necessary.
|
(package private) void |
prepareOp(Long txnId,
StoredObject transaction)
This method prepares a pending transaction.
|
private void |
recoverSnapshot() |
(package private) void |
registerOp(Registration registration) |
private void |
removePendingTxn(Long txnId)
Remove a pending transaction from the table.
|
(package private) void |
renewOp(byte[] cookie,
long expiration)
This method processes a logged renew operation.
|
(package private) void |
setupStore(Recover space)
Setup the database store and recover any existing state.
|
private void |
startConsumer() |
(package private) void |
takeOp(byte[] cookie,
Long txnId)
This method records a logged take operation.
|
void |
update(Observable source,
Object arg) |
(package private) void |
uuidOp(byte[] uuid)
This method records the service's top level
Uuid |
(package private) void |
writeOp(Resource entry,
Long txnId)
This method records a logged write operation.
|
private final java.util.concurrent.atomic.AtomicLong sessionId
private volatile StoredObject joinState
private final Map<ByteArrayWrapper,Resource> entries
private final Map<ByteArrayWrapper,Registration> registrations
private final Map<Long,PendingTxn> pendingTxns
private volatile byte[] topUuid
private volatile BackEnd.LastLog lastLog
private volatile SnapshotFile snapshotFile
private static final int SNAPSHOT_VERSION
private final String logFileBase
private final String snapshotFileBase
private final BackEnd.ConsumerThread consumer
private static final long WAIT_FOR_THREAD
private static final Logger logger
BackEnd(String path)
BackEnd
with the given path
.void setupStore(Recover space)
private void recoverSnapshot()
private void startConsumer()
public void update(Observable source, Object arg)
void destroy()
void close()
private PendingTxn pendingTxn(Long txnId)
private void removePendingTxn(Long txnId)
void bootOp(long time, long session)
void joinStateOp(StoredObject state)
void writeOp(Resource entry, Long txnId)
void takeOp(byte[] cookie, Long txnId)
void registerOp(Registration registration)
void renewOp(byte[] cookie, long expiration)
void cancelOp(byte[] cookie)
void prepareOp(Long txnId, StoredObject transaction)
void commitOp(Long txnId)
void abortOp(Long txnId)
void uuidOp(byte[] uuid)
Uuid
uuid
- The service's Uuid
represented as a
byte[16]
.private void consumeLogs(boolean all)
all
is
true
, all found log files will be processed.
If log
is false
, then all but the
most recent will be processed; this will prevent the back
end from reading the log file that is currently being
produced by the front end.private InternalSpaceException logAndThrowRecoveryException(String msg, Throwable nested)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.