db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel Matos <razieluk...@gmail.com>
Subject How to create a ContainerHandle from a given LogRecord
Date Thu, 20 Dec 2007 18:22:56 GMT
I've been studying derby's logging system. I want to parse the log files 
on disk extract its LogRecord(s) and write those
to an arbitrary stream to do some post-processing latter on.
I am using LogFactory.openForwardsScan() to traverse the log between the 
desired LogInstant(s).
This works well except for the log records on the group 
Loggable.RAWSTORE (and ContainerOperation instances in particular).
The problem is that when I try to invoke writeExternal on LogRecords of 
that group I get an NPE because
some fields of the Loggable are null (due to being transient and hence 
not saved to disk).
I will try to explain better with a small code snippet:

void parseLog(){
        StreamLogScan redoScan;
            try {
            LogInstant a = ...
           LogInstant b = ...
           //go from LogInstant 'a' to 'b'
                redoScan = (StreamLogScan) logFactory.openForwardsScan(a,b);
                LogRecord record;
                while ((record = redoScan.getNextRecord(logIn, null, 0)) 
!= null) {
                return ;
//write the LogRecord to a stream ...                
void writeLog(TransactionId transactionId,Loggable operation, long 
instant) throws IOException, StandardException {

            DynamicByteArrayOutputStream logOutputBuffer = new 

            FormatIdOutputStream logicalOut = new 
            ArrayInputStream logIn = new ArrayInputStream();
            LogRecord logRecord = new LogRecord();
            logRecord.setValue(transactionId, operation);

            //ERROR here when logrecord group is Loggable.RAWSTORE
            byte[] data = logOutputBuffer.getByteArray();
            //do something with the data ...
Let's focus on the particular case that the LogRecord's Loggable is a 
The line "logicalOut.writeObject(logRecord)" eventually invokes 
ContainerOperation.writeExternal() and because that object
is not correctly instantiated it throws an NPE when trying to access the 
RawContainerHandle containerHdl.
I think that I must create a ContainerOperation object with an adequate 
but I am unable to do it from the information contained _only_ in the 
I have been playing around with RawStoreFactory and TransactionFactory 
but without any success.
What am I  missing ? Is my reasoning correct ? And if so how can I solve 
this problem?

Thanks for you time.


View raw message