class LogOutputFile extends LogFile implements LogOps
LogInputFile. Each operation on the file is forced to
disk, so when the operation logging function returns, the data is
committed to the log in a recoverable way.
LogOutputFile cannot extend Observable
because it must extend LogFile (clearly
Observable should have been an interface). It acts as
an Observable by having a method that returns its
"observable part", which is an object that reports observable
events. Right now the only observable event is the switching to a
new physical file when the current one becomes full.
LogInputFile,
Observable| Modifier and Type | Field and Description |
|---|---|
private long |
deferedPosition |
private long |
deferedUpdateLength |
private byte[] |
intBuf |
private static long |
intBytes |
private long |
logBytes |
private FileDescriptor |
logFD |
private RandomAccessFile |
logFile |
private static Logger |
logger
Logger for logging persistent store related information
|
private int |
maxOps |
private Observable |
observable |
private int |
opCnt |
private ObjectOutputStream |
out |
private int |
suffix |
private byte[] |
zeroBuf |
ABORT_OP, baseDir, baseFile, BATCH_TAKE_OP, BATCH_WRITE_OP, BOOT_OP, CANCEL_OP, COMMIT_OP, JOINSTATE_OP, LOG_TYPE, LOG_VERSION, NOTIFIED_OP, PREPARE_OP, REGISTER_OP, RENEW_OP, TAKE_OP, UUID_OP, WRITE_OP| Constructor and Description |
|---|
LogOutputFile(String basePath,
int maxOps)
Create a
LogOutputFile object that will stream
output to a series of files described by basePath,
as interpreted by the relevant LogFile
constructor. |
| Modifier and Type | Method and Description |
|---|---|
void |
abortOp(Long txnId)
Log a transaction
abort operation. |
void |
bootOp(long time,
long sessionId)
Log a server boot.
|
void |
cancelOp(Uuid cookie,
boolean expired)
Log a
cancel operation. |
(package private) void |
close()
Close the log, but don't remove it.
|
void |
commitOp(Long txnId)
Log a transaction
commit operation. |
(package private) void |
destroy()
Override destroy so we can try to close logFile before calling
super tries to delete all the files.
|
private void |
failed(Exception e) |
private void |
flush()
Flush the current output after an operation.
|
private void |
flush(boolean forceToDisk)
Conditionally flush the current output.
|
private void |
flush(boolean forceToDisk,
int effectiveOpCount)
Conditionally flush the current output.
|
void |
joinStateOp(StorableObject state)
Log a change in join state
|
private void |
nextPath()
Switch this over to the next path in the list
|
(package private) Observable |
observable()
Return an
Observable object that represents this object
in the Observer/Observable pattern. |
void |
prepareOp(Long txnId,
StorableObject transaction)
Log a transaction
prepare operation. |
void |
registerOp(StorableResource registration,
String type,
StorableObject[] templates)
Log a
notify operation. |
void |
renewOp(Uuid cookie,
long expiration)
Log a
renew operation. |
void |
takeOp(Uuid[] cookies,
Long txnId)
Log a batch
take operation. |
void |
takeOp(Uuid cookie,
Long txnId)
Log a
take operation. |
void |
uuidOp(Uuid uuid)
Log the
Uuid that identifies the space as a whole. |
private void |
writeInt(int val)
Write an int value in single write operation.
|
void |
writeOp(StorableResource[] entries,
Long txnId)
Log a batch
write operation. |
void |
writeOp(StorableResource entry,
Long txnId)
Log a
write operation. |
existingLogsprivate volatile RandomAccessFile logFile
private volatile FileDescriptor logFD
private volatile ObjectOutputStream out
private volatile int suffix
private volatile int opCnt
private volatile int maxOps
private volatile Observable observable
private volatile long logBytes
private final byte[] intBuf
private final byte[] zeroBuf
private volatile long deferedUpdateLength
private volatile long deferedPosition
private static final long intBytes
private static final Logger logger
LogOutputFile(String basePath, int maxOps) throws IOException
LogOutputFile object that will stream
output to a series of files described by basePath,
as interpreted by the relevant LogFile
constructor. When the file becomes full (the maximum number of
operations is reached), the file is closed and a new file with
the next highest suffix is created. The
Observable notification for this event passes a
File argument for the filled file as the argument
to Observer.IOExceptionobservable()Observable observable()
Observable object that represents this object
in the Observer/Observable pattern.Observerprivate void nextPath()
throws IOException
IOExceptionvoid close()
throws IOException
IOExceptionvoid destroy()
public void bootOp(long time,
long sessionId)
bootOp in interface LogOpstime - stamp for this bootsessionId - of this bootRecover.recoverSessionId(long)public void joinStateOp(StorableObject state)
joinStateOp in interface LogOpsstate - to be loggedRecover.recoverJoinState(org.apache.river.outrigger.StoredObject)public void writeOp(StorableResource entry, Long txnId)
write operation.writeOp in interface LogOpsentry - to be loggedtxnId - transaction identifier or null if
no transaction is active for this writeRecover.recoverWrite(org.apache.river.outrigger.StoredResource, java.lang.Long)public void writeOp(StorableResource[] entries, Long txnId)
LogOpswrite operation. If the operation was
performed under a transaction the txnId is
the identifier for that transaction.writeOp in interface LogOpsentries - to be loggedtxnId - transaction identifier or null if
no transaction is active for this writeRecover.recoverWrite(org.apache.river.outrigger.StoredResource, java.lang.Long)public void takeOp(Uuid cookie, Long txnId)
take operation.takeOp in interface LogOpscookie - ID identifying the entry target to be takentxnId - transaction identifier or null if
no transaction is active for this takeRecover.recoverTake(net.jini.id.Uuid, java.lang.Long)public void takeOp(Uuid[] cookies, Long txnId)
LogOpstake operation. If the operation was
performed under a transaction the txnId is
the identifier for that transaction.takeOp in interface LogOpscookies - IDs identifying the entries to be takentxnId - transaction identifier or null if
no transaction is active for this takeRecover.recoverTake(net.jini.id.Uuid, java.lang.Long)public void registerOp(StorableResource registration, String type, StorableObject[] templates)
notify operation.registerOp in interface LogOpsregistration - to be loggedtype - of registration, passed back via type
parameter of corresponding recoverRegister
calltemplates - associated with this registrationRecover.recoverRegister(org.apache.river.outrigger.StoredResource, java.lang.String, org.apache.river.outrigger.StoredObject[])public void renewOp(Uuid cookie, long expiration)
renew operation.renewOp in interface LogOpscookie - ID of the entry or registration associated with this
renewexpiration - timeStoredResourcepublic void cancelOp(Uuid cookie, boolean expired)
cancel operation.public void prepareOp(Long txnId, StorableObject transaction)
prepare operation.prepareOp in interface LogOpstxnId - identifier of the transaction to be preparedtransaction - object associated with this transactionRecover.recoverTransaction(java.lang.Long, org.apache.river.outrigger.StoredObject)public void commitOp(Long txnId)
commit operation.public void abortOp(Long txnId)
abort operation.public void uuidOp(Uuid uuid)
LogOpsUuid that identifies the space as a whole.uuidOp in interface LogOpsuuid - The Uuid to be stored.Recover.recoverUuid(net.jini.id.Uuid)private void flush()
throws IOException
IOExceptionprivate void flush(boolean forceToDisk)
throws IOException
forceToDisk is false.IOExceptionprivate void flush(boolean forceToDisk,
int effectiveOpCount)
throws IOException
forceToDisk is false.IOExceptionprivate void writeInt(int val)
throws IOException
ObjectIn/OutputStream and this
method writes directly to the RandomAccessFile.val - int valueIOException - if any other I/O error occursprivate void failed(Exception e) throws InternalSpaceException
InternalSpaceExceptionCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.