FSDatasetInterface#writeToBlock() currently allows to create/recover a temporary replica, create/recover a RBW replica, or append to a replica. The implementation of the method in FSDataset is very complicated and error prone. I'd like to break this method into 3:
1. writeToTemporary allows to create a Temporary replica or recover from a packet error for a Tempoary replica;
2. writeToRBW allows to create a RBW replica or recover from a packet error for a RBW replica;
3. append allows to append to an existing Finalized replica.