private LocalReplicaInPipeline buildTemporaryReplica() throws IllegalArgumentException { if (null != fromReplica && fromReplica.getState() == ReplicaState.TEMPORARY) { return new LocalReplicaInPipeline((LocalReplicaInPipeline) fromReplica); } else if (null != fromReplica) { throw new IllegalArgumentException("Incompatible fromReplica " + "state: " + fromReplica.getState()); } else { if (null != block) { if (null == writer) { throw new IllegalArgumentException("A valid writer is " + "required for constructing a Replica from block " + block.getBlockId()); } return new LocalReplicaInPipeline(block, volume, directoryUsed, writer); } else { if (length != -1) { return new LocalReplicaInPipeline(blockId, length, genStamp, volume, directoryUsed, writer, bytesToReserve); } else { return new LocalReplicaInPipeline(blockId, genStamp, volume, directoryUsed, bytesToReserve); } } } }