Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.log

public Class FlushedScan

extends Object
implements StreamLogScan
Class Inheritance
All Implemented Interfaces
org.apache.derby.impl.store.raw.log.StreamLogScan, org.apache.derby.iapi.store.raw.log.LogScan
Imports
org.apache.derby.shared.common.reference.SQLState, .MessageId, org.apache.derby.impl.store.raw.log.LogCounter, .LogRecord, .StreamLogScan, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.store.raw.log.LogInstant, .LogFactory, org.apache.derby.iapi.store.raw.xact.TransactionId, org.apache.derby.iapi.services.io.ArrayInputStream, org.apache.derby.io.StorageRandomAccessFile, java.io.IOException

Scan the the log which is implemented by a series of log files.n This log scan knows how to move across log file if it is positioned at the boundary of a log file and needs to getNextRecord.
4 bytes - length of user data, i.e. N
8 bytes - long representing log instant
N bytes of supplied data
4 bytes - length of user data, i.e. N

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv static final int
pack-priv LogToFile
pack-priv int
nextRecordLength

The length of the next record.

pack-priv boolean
pack-priv boolean
readNextRecordLength

Flag to indicate that the length of the next log record has been read by currentLogFileHasUnflushedRecord.

private StorageRandomAccessFile

Constructor Summary

AccessConstructor and Description
public
FlushedScan(LogToFile logFactory, long startAt)

Method Summary

Modifier and TypeMethod and Description
public void
private boolean
public long
getInstant()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getInstant.

Return the log instant (as an integer) the scan is currently on - this is the log instant of the log record that was returned by getNextRecord.

public LogInstant
getLogInstant()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getLogInstant.

Return the log instant the scan is currently on - this is the log instant of the log record that was returned by getNextRecord.

public long

Returns:

INVALID_LOG_INSTANT if this is not a FORWARD scan or, no record have been returned yet or the scan has completed.
getLogRecordEnd
()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getLogRecordEnd.

Get the log instant that is right after the record just retrived

public LogRecord

Returns:

the length of the data written into data, or -1 if the end of the scan has been reached.
getNextRecord
(ArrayInputStream
the ArrayInputStream to put the log record
input
,
TransactionId
if non-null, only log record that equals tranId will be returned. If null, log records are not filtered on transaction Id.
tranId
,
int
if non-zero, only log record whose Loggable's group value is included in the groupmask is returned. groupmask can be a bit wise OR of many Loggable groups. If zero, log records are not filtered on the Loggable's group.
groupmask
)

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getNextRecord.

Read a log record into the byte array provided.

public boolean
isLogEndFuzzy()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.isLogEndFuzzy.

returns true if there is partially writen log records before the crash in the last log file.

private boolean
public void
resetPosition(LogInstant
the position to reset to
instant
)

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.resetPosition.

Reset the scan to the given LogInstant.

private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentInstantback to summary
pack-priv long currentInstant
currentLogFileFirstUnflushedPositionback to summary
pack-priv long currentLogFileFirstUnflushedPosition
currentLogFileNumberback to summary
pack-priv long currentLogFileNumber
firstUnflushedback to summary
pack-priv long firstUnflushed
firstUnflushedFileNumberback to summary
pack-priv long firstUnflushedFileNumber
firstUnflushedFilePositionback to summary
pack-priv long firstUnflushedFilePosition
LOG_REC_LEN_BYTE_LENGTHback to summary
pack-priv static final int LOG_REC_LEN_BYTE_LENGTH
logFactoryback to summary
pack-priv LogToFile logFactory
nextRecordLengthback to summary
pack-priv int nextRecordLength

The length of the next record. Read from scan and set by currentLogFileHasUnflushedRecord. This is used to retain the length of a log record in the case currentLogFileHasUnflushedRecord reads the length and determines that some bytes in the log record are not yet flushed.

openback to summary
pack-priv boolean open
readNextRecordLengthback to summary
pack-priv boolean readNextRecordLength

Flag to indicate that the length of the next log record has been read by currentLogFileHasUnflushedRecord. This flag gets reset in two ways:

  1. currentLogFileHasUnflushedRecord determines that the entire log record is flushed and returns true. In this case getNextRecord reads and returns the log record.
  2. we switch log files --due to a partial log record at the end of an old log file.
scanback to summary
private StorageRandomAccessFile scan

Constructor Detail

FlushedScanback to summary
public FlushedScan(LogToFile logFactory, long startAt) throws StandardException

Method Detail

closeback to summary
public void close()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.close.

Close the scan.

currentLogFileHasUnflushedRecordback to summary
private boolean currentLogFileHasUnflushedRecord() throws IOException
getInstantback to summary
public long getInstant()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getInstant.

Return the log instant (as an integer) the scan is currently on - this is the log instant of the log record that was returned by getNextRecord.

Returns:long

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.getInstant.

INVALID_LOG_INSTANT if no records have been returned yet or the scan has completed.

getLogInstantback to summary
public LogInstant getLogInstant()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getLogInstant.

Return the log instant the scan is currently on - this is the log instant of the log record that was returned by getNextRecord.

Returns:LogInstant

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.getLogInstant.

null if no records have been returned yet or the scan has completed.

getLogRecordEndback to summary
public long getLogRecordEnd()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getLogRecordEnd.

Get the log instant that is right after the record just retrived

Returns:long

INVALID_LOG_INSTANT if this is not a FORWARD scan or, no record have been returned yet or the scan has completed.

getNextRecordback to summary
public LogRecord getNextRecord(ArrayInputStream input, TransactionId tranId, int groupmask) throws StandardException

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.getNextRecord.

Read a log record into the byte array provided. Resize the input stream byte array if necessary.

Parameters
input:ArrayInputStream

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.getNextRecord.

the ArrayInputStream to put the log record

tranId:TransactionId

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.getNextRecord.

if non-null, only log record that equals tranId will be returned. If null, log records are not filtered on transaction Id.

groupmask:int

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.getNextRecord.

if non-zero, only log record whose Loggable's group value is included in the groupmask is returned. groupmask can be a bit wise OR of many Loggable groups. If zero, log records are not filtered on the Loggable's group.

Returns:LogRecord

the length of the data written into data, or -1 if the end of the scan has been reached.

Exceptions
StandardException:
Standard Derby error policy
isLogEndFuzzyback to summary
public boolean isLogEndFuzzy()

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.isLogEndFuzzy.

returns true if there is partially writen log records before the crash in the last log file. Partiall wrires are identified during forward scans for log recovery.

Returns:boolean

Doc from org.apache.derby.impl.store.raw.log.StreamLogScan.isLogEndFuzzy.

true if fuzzy log end found during forward scan, this happens if there was a partially written log records before the crash.

positionToNextRecordback to summary
private boolean positionToNextRecord() throws StandardException, IOException
resetPositionback to summary
public void resetPosition(LogInstant instant) throws IOException

Implements org.apache.derby.impl.store.raw.log.StreamLogScan.resetPosition.

Reset the scan to the given LogInstant.

Parameters
instant:LogInstant

the position to reset to

Exceptions
IOException:
scan cannot access the log at the new position.
setCurrentLogFileFirstUnflushedPositionback to summary
private void setCurrentLogFileFirstUnflushedPosition() throws IOException
setFirstUnflushedback to summary
private void setFirstUnflushed() throws StandardException, IOException
switchLogFileback to summary
private void switchLogFile() throws StandardException