Hi all,

As you might already know, Chainsaw is a remote log mintoring tool. We are
using Commons-VFS to receive log events from the log files in different file
systems through different protocols (http, ftp, etc..). When the log entries
are added to the log files, Chaisaw should show new entries without having
to restart the log event receiver. This capability is called 'tailing'.
When the log file is in the local file system, VFS loads new log events on
the fly. But when it comes to log files which are loaded through different
protocols (say http), VFS doesn't load the new events and the receiver
should be restarted to get the new events.

Currently I'm working on fixing this issue and I used the following method,

//in this case fileObject represents the log file accessed over http..

do {
     RandomAccessContent rac = fileObject.getContent().getRandomAccessContent(
RandomAccessMode.READ);
     rac.seek(lastFilePointer);
     reader = new InputStreamReader(rac.getInputStream());
     bufferedReader = new BufferedReader(reader);
     process(bufferedReader);               //sends the events to
Chainsaw...
     lastFilePointer = rac.getFilePointer();
     rac.close();

     try {
     synchronized (this) {
     wait(5000);
     }
     } catch (InterruptedException ie) {
     }

} while (tailing);

This implementation works as far as log events are frequently added to the
remote log file. But when log events are not added for more than 10 or 15
seconds, suddenly 'rac.getInputStream()' method call returns the following
exeption and the execution gets stuck at that point.

org.apache.commons.vfs.FileSystemException: GET method failed for "
http://localhost:8080/logTest/re_log.log"; range "51088-".
   at
org.apache.commons.vfs.provider.http.HttpRandomAccesContent.getDataInputStream(
HttpRandomAccesContent.java:89)
   at
org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent.getInputStream
AbstractRandomAccessStreamContent.java:125)
   at org.apache.commons.vfs.util.MonitorRandomAccessContent.getInputStream(
MonitorRandomAccessContent.java:249)
   at org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver$VFSReader.run
(VFSLogFilePatternReceiver.java:315)
   at java.lang.Thread.run(Thread.java:534)

But we need the above loop to run until new log events are added to the log
file (even after 5 or 10 minutes) and load them immediately. But even if the
new events are added later, execution remains stuck.

Is this a bug with Commons-VFS or is this due to some other reason? Could
someone help me by suggesting how to overcome this problem?...

Thanks in advance,
~Isuru

Reply via email to