// Inner classes -------------------------------------------------
public static void main(final String arg[])
{
TimeAndCounterIDGenerator idgenerator = new TimeAndCounterIDGenerator();
try
{
SequentialFileFactory fileFactory = new AIOSequentialFileFactory("/tmp"); // any dir you want
// SequentialFileFactory fileFactory = new NIOSequentialFileFactory("/tmp"); // any dir you want
JournalImpl journalExample = new JournalImpl(10 * 1024 * 1024, // 10M.. we believe that's the usual cilinder
// bufferSize.. not an exact science here
2, // number of files pre-allocated
0,
0,
fileFactory, // AIO or NIO
"exjournal", // file name
"dat", // extension
10000); // it's like a semaphore for callback on the AIO layer
ArrayList<RecordInfo> committedRecords = new ArrayList<RecordInfo>();
ArrayList<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
journalExample.start();
System.out.println("Loading records and creating data files");
journalExample.load(committedRecords, preparedTransactions, null);
System.out.println("Loaded Record List:");
for (RecordInfo record : committedRecords)
{
System.out.println("Record id = " + record.id +
" userType = " +
record.userRecordType +
" with " +
record.data.length +
" bytes is stored on the journal");
}
System.out.println("Adding Records:");
for (int i = 0; i < 10; i++)
{
journalExample.appendAddRecord(idgenerator.generateID(), (byte)1, new byte[] { 0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2 }, false);
}
long tx = idgenerator.generateID(); // some id generation system
for (int i = 0; i < 100; i++)
{
journalExample.appendAddRecordTransactional(tx, idgenerator.generateID(), (byte)2, new byte[] { 0,
1,
2,
0,
1,
2,