Rework HdfsWriter for the sake of extensibility and split it into self-contained classes.