private void applyMigrationOperation(String name, KRaftMigrationOperation migrationOp, boolean alwaysLog) {
        ZkMigrationLeadershipState beforeState = this.migrationLeadershipState;
        long startTimeNs = time.nanoseconds();
        ZkMigrationLeadershipState afterState = migrationOp.apply(beforeState);
        long durationNs = time.nanoseconds() - startTimeNs;
        if (afterState.loggableChangeSinceState(beforeState) || alwaysLog) {
            log.info("{} in {} ns. Transitioned migration state from {} to {}",
                name, durationNs, beforeState, afterState);
        } else if (afterState.equals(beforeState)) {
            log.trace("{} in {} ns. Kept migration state as {}", name, durationNs, afterState);
        } else {
            log.trace("{} in {} ns. Transitioned migration state from {} to {}",
                name, durationNs, beforeState, afterState);
        }
        this.migrationLeadershipState = afterState;
    }
Apply a function which transforms our internal migration state.

@param name         A descriptive name of the function that is being applied
@param migrationOp  A function which performs some migration operations and possibly transforms our internal state
metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java