I would looking at example given alexhomes’s hadoop-book here
I could not understand why close method is synchronized? and why only close() and no other method ?
public synchronized void close() throws IOException {
reader.close();
}
Can some one explain me? That will be very helpful.
As I mention in the book, I used the ElephantBird project’s LzoJsonRecordReader class as a basis for my version, as I wanted to write one which didn’t require LZOP compression. ElephantBird used a synchronized close method in their RecordReader, which as a result made its way into my version too. As other have mentioned there is no reason that I know of to synchronize the close method in MapReduce.