void transitionTo(MigrationDriverState newState) {
        if (!isValidStateChange(newState)) {
            throw new IllegalStateException(
                String.format("Invalid transition in migration driver from %s to %s", migrationState, newState));
        }

        if (newState != migrationState) {
            log.info("{} transitioning from {} to {} state", nodeId, migrationState, newState);
            pollTimeSupplier.reset();
            wakeup();
        } else {
            log.trace("{} transitioning from {} to {} state", nodeId, migrationState, newState);
        }

        migrationState = newState;
    }
Check that the migration driver is in the correct state for a given event. If the event causes
updates (i.e., to ZK or broker RPCs), also check that the event is for the current KRaft controller epoch.
metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java