|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.messaging.core.journal.impl.JournalImpl
public class JournalImpl
A JournalImpl
WIKI Page: http://wiki.jboss.org/wiki/JBossMessaging2JournalLook at load(LoadManager)
for the file layout
Field Summary | |
---|---|
static byte |
ADD_RECORD
|
static byte |
ADD_RECORD_TX
|
static int |
BASIC_SIZE
|
static byte |
COMMIT_RECORD
|
static byte |
DELETE_RECORD
|
static byte |
DELETE_RECORD_TX
|
java.lang.String |
fileExtension
|
java.lang.String |
filePrefix
|
static byte |
FILL_CHARACTER
|
static int |
MIN_FILE_SIZE
|
static byte |
PREPARE_RECORD
|
static byte |
ROLLBACK_RECORD
|
static int |
SIZE_ADD_RECORD
|
static int |
SIZE_ADD_RECORD_TX
|
static int |
SIZE_COMMIT_RECORD
|
static int |
SIZE_COMPLETE_TRANSACTION_RECORD
|
static int |
SIZE_DELETE_RECORD
|
static int |
SIZE_DELETE_RECORD_TX
|
static int |
SIZE_HEADER
|
static int |
SIZE_PREPARE_RECORD
|
static int |
SIZE_ROLLBACK_RECORD
|
static byte |
SIZE_UPDATE_RECORD
|
static int |
SIZE_UPDATE_RECORD_TX
|
static byte |
UPDATE_RECORD
|
static byte |
UPDATE_RECORD_TX
|
Constructor Summary | |
---|---|
JournalImpl(int fileSize,
int minFiles,
SequentialFileFactory fileFactory,
java.lang.String filePrefix,
java.lang.String fileExtension,
int maxAIO)
|
Method Summary | |
---|---|
void |
appendAddRecord(long id,
byte recordType,
byte[] record,
boolean sync)
|
void |
appendAddRecord(long id,
byte recordType,
EncodingSupport record,
boolean sync)
|
void |
appendAddRecordTransactional(long txID,
long id,
byte recordType,
byte[] record,
boolean sync)
|
void |
appendAddRecordTransactional(long txID,
long id,
byte recordType,
EncodingSupport record,
boolean sync)
|
void |
appendCommitRecord(long txID,
boolean sync)
A transaction record (Commit or Prepare), will hold the number of elements the transaction has on each file. |
void |
appendDeleteRecord(long id,
boolean sync)
|
void |
appendDeleteRecordTransactional(long txID,
long id,
boolean sync)
|
void |
appendDeleteRecordTransactional(long txID,
long id,
byte[] record,
boolean sync)
|
void |
appendDeleteRecordTransactional(long txID,
long id,
EncodingSupport record,
boolean sync)
|
void |
appendPrepareRecord(long txID,
EncodingSupport transactionData,
boolean sync)
If the system crashed after a prepare was called, it should store information that is required to bring the transaction back to a state it could be committed. |
void |
appendRollbackRecord(long txID,
boolean sync)
|
void |
appendUpdateRecord(long id,
byte recordType,
byte[] record,
boolean sync)
|
void |
appendUpdateRecord(long id,
byte recordType,
EncodingSupport record,
boolean sync)
|
void |
appendUpdateRecordTransactional(long txID,
long id,
byte recordType,
byte[] record,
boolean sync)
|
void |
appendUpdateRecordTransactional(long txID,
long id,
byte recordType,
EncodingSupport record,
boolean sync)
|
void |
checkAndReclaimFiles()
|
java.lang.String |
debug()
|
void |
debugWait()
Method for use on testcases. |
void |
forceMoveNextFile()
|
int |
getAlignment()
|
int |
getDataFilesCount()
|
java.lang.String |
getFileExtension()
|
java.lang.String |
getFilePrefix()
|
int |
getFileSize()
|
int |
getFreeFilesCount()
|
int |
getIDMapSize()
|
int |
getMaxAIO()
|
int |
getMinFiles()
|
int |
getOpenedFilesCount()
|
boolean |
isAutoReclaim()
|
boolean |
isStarted()
|
long |
load(java.util.List<RecordInfo> committedRecords,
java.util.List<PreparedTransactionInfo> preparedTransactions)
|
long |
load(LoadManager loadManager)
Load data accordingly to the record layouts |
ChannelBuffer |
newBuffer(int size)
|
void |
perfBlast(int pages)
|
void |
setAutoReclaim(boolean autoReclaim)
|
void |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MIN_FILE_SIZE
public static final int SIZE_HEADER
public static final int BASIC_SIZE
public static final int SIZE_ADD_RECORD
public static final byte ADD_RECORD
public static final byte SIZE_UPDATE_RECORD
public static final byte UPDATE_RECORD
public static final int SIZE_ADD_RECORD_TX
public static final byte ADD_RECORD_TX
public static final int SIZE_UPDATE_RECORD_TX
public static final byte UPDATE_RECORD_TX
public static final int SIZE_DELETE_RECORD_TX
public static final byte DELETE_RECORD_TX
public static final int SIZE_DELETE_RECORD
public static final byte DELETE_RECORD
public static final int SIZE_COMPLETE_TRANSACTION_RECORD
public static final int SIZE_PREPARE_RECORD
public static final byte PREPARE_RECORD
public static final int SIZE_COMMIT_RECORD
public static final byte COMMIT_RECORD
public static final int SIZE_ROLLBACK_RECORD
public static final byte ROLLBACK_RECORD
public static final byte FILL_CHARACTER
public final java.lang.String filePrefix
public final java.lang.String fileExtension
Constructor Detail |
---|
public JournalImpl(int fileSize, int minFiles, SequentialFileFactory fileFactory, java.lang.String filePrefix, java.lang.String fileExtension, int maxAIO)
Method Detail |
---|
public void appendAddRecord(long id, byte recordType, byte[] record, boolean sync) throws java.lang.Exception
appendAddRecord
in interface Journal
java.lang.Exception
public void appendAddRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws java.lang.Exception
appendAddRecord
in interface Journal
java.lang.Exception
public void appendUpdateRecord(long id, byte recordType, byte[] record, boolean sync) throws java.lang.Exception
appendUpdateRecord
in interface Journal
java.lang.Exception
public void appendUpdateRecord(long id, byte recordType, EncodingSupport record, boolean sync) throws java.lang.Exception
appendUpdateRecord
in interface Journal
java.lang.Exception
public void appendDeleteRecord(long id, boolean sync) throws java.lang.Exception
appendDeleteRecord
in interface Journal
java.lang.Exception
public void appendAddRecordTransactional(long txID, long id, byte recordType, byte[] record, boolean sync) throws java.lang.Exception
appendAddRecordTransactional
in interface Journal
java.lang.Exception
public void appendAddRecordTransactional(long txID, long id, byte recordType, EncodingSupport record, boolean sync) throws java.lang.Exception
appendAddRecordTransactional
in interface Journal
java.lang.Exception
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, byte[] record, boolean sync) throws java.lang.Exception
appendUpdateRecordTransactional
in interface Journal
java.lang.Exception
public void appendUpdateRecordTransactional(long txID, long id, byte recordType, EncodingSupport record, boolean sync) throws java.lang.Exception
appendUpdateRecordTransactional
in interface Journal
java.lang.Exception
public void appendDeleteRecordTransactional(long txID, long id, byte[] record, boolean sync) throws java.lang.Exception
appendDeleteRecordTransactional
in interface Journal
java.lang.Exception
public void appendDeleteRecordTransactional(long txID, long id, EncodingSupport record, boolean sync) throws java.lang.Exception
appendDeleteRecordTransactional
in interface Journal
java.lang.Exception
public void appendDeleteRecordTransactional(long txID, long id, boolean sync) throws java.lang.Exception
appendDeleteRecordTransactional
in interface Journal
java.lang.Exception
public void appendPrepareRecord(long txID, EncodingSupport transactionData, boolean sync) throws java.lang.Exception
If the system crashed after a prepare was called, it should store information that is required to bring the transaction back to a state it could be committed.
transactionData allows you to store any other supporting user-data related to the transaction
This method also uses the same logic applied on JournalImpl#appendCommitRecord(long)
appendPrepareRecord
in interface Journal
txID
- transactionData
- - extra user data for the prepare
java.lang.Exception
public void appendCommitRecord(long txID, boolean sync) throws java.lang.Exception
A transaction record (Commit or Prepare), will hold the number of elements the transaction has on each file.
For example, a transaction was spread along 3 journal files with 10 records on each file. (What could happen if there are too many records, or if an user event delayed records to come in time to a single file).
The element-summary will then have
FileID1, 10
FileID2, 10
FileID3, 10
During the load, the transaction needs to have 30 records spread across the files as originally written.
If for any reason there are missing records, that means the transaction was not completed and we should ignore the whole transaction
We can't just use a global counter as reclaiming could delete files after the transaction was successfully committed. That also means not having a whole file on journal-reload doesn't mean we have to invalidate the transaction
appendCommitRecord
in interface Journal
java.lang.Exception
writeTransaction(byte, long, org.jboss.messaging.core.journal.impl.JournalImpl.JournalTransaction, EncodingSupport)
public void appendRollbackRecord(long txID, boolean sync) throws java.lang.Exception
appendRollbackRecord
in interface Journal
java.lang.Exception
public long load(java.util.List<RecordInfo> committedRecords, java.util.List<PreparedTransactionInfo> preparedTransactions) throws java.lang.Exception
load
in interface Journal
java.lang.Exception
load(LoadManager)
public long load(LoadManager loadManager) throws java.lang.Exception
Load data accordingly to the record layouts
Basic record layout:
Field Name | Size |
RecordType | Byte (1) |
FileID | Integer (4 bytes) |
TransactionID (if record is transactional) | Long (8 bytes) |
RecordID | Long (8 bytes) |
BodySize(Add, update and delete) | Integer (4 bytes) |
UserDefinedRecordType (If add/update only) | Byte (1) |
RecordBody | Byte Array (size=BodySize) |
Check Size | Integer (4 bytes) |
The check-size is used to validate if the record is valid and complete
Commit/Prepare record layout:
Field Name | Size |
RecordType | Byte (1) |
FileID | Integer (4 bytes) |
TransactionID (if record is transactional) | Long (8 bytes) |
ExtraDataLength (Prepares only) | Integer (4 bytes) |
Number Of Files (N) | Integer (4 bytes) |
ExtraDataBytes | Bytes (sized by ExtraDataLength) |
* FileID(n) | Integer (4 bytes) |
* NumberOfElements(n) | Integer (4 bytes) |
CheckSize | Integer (4 bytes) |
* FileID and NumberOfElements are the transaction summary, and they will be repeated (N)umberOfFiles times
load
in interface TestableJournal
java.lang.Exception
public int getAlignment() throws java.lang.Exception
getAlignment
in interface Journal
java.lang.Exception
public void setAutoReclaim(boolean autoReclaim)
setAutoReclaim
in interface TestableJournal
public boolean isAutoReclaim()
isAutoReclaim
in interface TestableJournal
public java.lang.String debug() throws java.lang.Exception
debug
in interface TestableJournal
java.lang.Exception
public void debugWait() throws java.lang.Exception
debugWait
in interface TestableJournal
java.lang.Exception
public void checkAndReclaimFiles() throws java.lang.Exception
checkAndReclaimFiles
in interface TestableJournal
java.lang.Exception
public int getDataFilesCount()
getDataFilesCount
in interface TestableJournal
public int getFreeFilesCount()
getFreeFilesCount
in interface TestableJournal
public int getOpenedFilesCount()
getOpenedFilesCount
in interface TestableJournal
public int getIDMapSize()
getIDMapSize
in interface TestableJournal
public int getFileSize()
getFileSize
in interface TestableJournal
public int getMinFiles()
getMinFiles
in interface TestableJournal
public java.lang.String getFilePrefix()
getFilePrefix
in interface TestableJournal
public java.lang.String getFileExtension()
getFileExtension
in interface TestableJournal
public int getMaxAIO()
getMaxAIO
in interface TestableJournal
public void forceMoveNextFile() throws java.lang.Exception
forceMoveNextFile
in interface TestableJournal
java.lang.Exception
public void perfBlast(int pages) throws java.lang.Exception
perfBlast
in interface Journal
java.lang.Exception
public boolean isStarted()
isStarted
in interface MessagingComponent
public void start()
start
in interface MessagingComponent
public void stop() throws java.lang.Exception
stop
in interface MessagingComponent
java.lang.Exception
public ChannelBuffer newBuffer(int size)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |