Code review comment: This can not be `checkState(writer == null)` because single dispatcher will handle 5 `CheckpointStartRequests` from 5 subtasks (assuming 5 subtasks are configured to share the same file?).  If so, maybe add a comment explaining this?

Code under review:
private void dispatchInternal(ChannelStateWriteRequest request) throws Exception {
        if (request instanceof SubtaskRegisterRequest) {
            SubtaskRegisterRequest req = (SubtaskRegisterRequest) request;
            SubtaskID subtaskID =
                    SubtaskID.of(req.getJobID(), req.getJobVertexID(), req.getSubtaskIndex());
            subtasks.add(subtaskID);
            return;
        } else if (request instanceof SubtaskReleaseRequest) {
            SubtaskReleaseRequest req = (SubtaskReleaseRequest) request;
            SubtaskID subtaskID =
                    SubtaskID.of(req.getJobID(), req.getJobVertexID(), req.getSubtaskIndex());
            subtasks.remove(subtaskID);
            if (writer == null) {
                return;
            }
            writer.releaseSubtask(subtaskID);
            return;
        }
        if (isAbortedCheckpoint(request.getCheckpointId())) {
            if (request.getCheckpointId() != maxAbortedCheckpointId) {
                request.cancel(new CheckpointException(CHECKPOINT_DECLINED_SUBSUMED));
                return;
            }

            SubtaskID requestSubtask =
                    SubtaskID.of(
                            request.getJobID(),
                            request.getJobVertexID(),
                            request.getSubtaskIndex());
            if (requestSubtask.equals(abortedSubtaskID)) {
                request.cancel(abortedCause);
            } else {
                request.cancel(
                        new CheckpointException(
                                CHANNEL_STATE_SHARED_STREAM_EXCEPTION, abortedCause));
            }
            return;
        }

        if (request instanceof CheckpointStartRequest) {
            checkState(
                    request.getCheckpointId() >= ongoingCheckpointId,
                    String.format(
                            "Checkpoint must be incremented, ongoingCheckpointId is %s, but the request is %s.",
                            ongoingCheckpointId, request));
            if (request.getCheckpointId() > ongoingCheckpointId) {
                
                failAndClearWriter(new CheckpointException(CHECKPOINT_DECLINED_SUBSUMED));
            }
            CheckpointStartRequest req = (CheckpointStartRequest) request;
            if (writer == null) {
                this.writer = buildWriter(req);
                this.ongoingCheckpointId = request.getCheckpointId();
            }
            writer.registerSubtaskResult(
                    SubtaskID.of(req.getJobID(), req.getJobVertexID(), req.getSubtaskIndex()),
                    req.getTargetResult());
        } else if (request instanceof CheckpointInProgressRequest) {
            CheckpointInProgressRequest req = (CheckpointInProgressRequest) request;
            checkArgument(
                    ongoingCheckpointId == req.getCheckpointId() && writer != null,
                    "writer not found while processing request: " + req);
            req.execute(writer);
        } else if (request instanceof CheckpointAbortRequest) {
            CheckpointAbortRequest req = (CheckpointAbortRequest) request;
            if (request.getCheckpointId() > maxAbortedCheckpointId) {
                this.maxAbortedCheckpointId = req.getCheckpointId();
                this.abortedCause = req.getThrowable();
                this.abortedSubtaskID =
                        SubtaskID.of(req.getJobID(), req.getJobVertexID(), req.getSubtaskIndex());
            }

            if (req.getCheckpointId() == ongoingCheckpointId) {
                failAndClearWriter(
                        req.getJobID(),
                        req.getJobVertexID(),
                        req.getSubtaskIndex(),
                        req.getThrowable());
            } else if (request.getCheckpointId() > ongoingCheckpointId) {
                failAndClearWriter(new CheckpointException(CHECKPOINT_DECLINED_SUBSUMED));
            }
        } else {
            throw new IllegalArgumentException("unknown request type: " + request);
        }
    }

Line commented on: if (writer == null) {

Revised code:
private void dispatchInternal(ChannelStateWriteRequest request) throws Exception {
        if (request instanceof SubtaskRegisterRequest) {
            SubtaskRegisterRequest req = (SubtaskRegisterRequest) request;
            SubtaskID subtaskID = SubtaskID.of(req.getJobVertexID(), req.getSubtaskIndex());
            registeredSubtasks.add(subtaskID);
            return;
        } else if (request instanceof SubtaskReleaseRequest) {
            SubtaskReleaseRequest req = (SubtaskReleaseRequest) request;
            SubtaskID subtaskID = SubtaskID.of(req.getJobVertexID(), req.getSubtaskIndex());
            registeredSubtasks.remove(subtaskID);
            if (writer == null) {
                return;
            }
            writer.releaseSubtask(subtaskID);
            return;
        }

        if (isAbortedCheckpoint(request.getCheckpointId())) {
            handleAbortedRequest(request);
        } else if (request instanceof CheckpointStartRequest) {
            handleCheckpointStartRequest(request);
        } else if (request instanceof CheckpointInProgressRequest) {
            handleCheckpointInProgressRequest((CheckpointInProgressRequest) request);
        } else if (request instanceof CheckpointAbortRequest) {
            handleCheckpointAbortRequest(request);
        } else {
            throw new IllegalArgumentException("unknown request type: " + request);
        }
    }