public void execute()

in computer-core/src/main/java/org/apache/hugegraph/computer/core/master/MasterService.java [181:277]


    public void execute() {
        StopWatch watcher = new StopWatch();
        this.checkInited();

        LOG.info("{} MasterService execute", this);
        /*
         * Step 1: Determines which superstep to start from, and resume this
         * superstep.
         */
        int superstep = this.superstepToResume();
        LOG.info("{} MasterService resume from superstep: {}",
                 this, superstep);

        /*
         * TODO: Get input splits from HugeGraph if resume from
         * Constants.INPUT_SUPERSTEP.
         */
        this.bsp4Master.masterResumeDone(superstep);

        /*
         * Step 2: Input superstep for loading vertices and edges.
         * This step may be skipped if resume from other superstep than
         * Constants.INPUT_SUPERSTEP.
         */
        SuperstepStat superstepStat;
        watcher.start();
        if (superstep == Constants.INPUT_SUPERSTEP) {
            superstepStat = this.inputstep();
            superstep++;
        } else {
            // TODO: Get superstepStat from bsp service.
            superstepStat = null;
        }
        watcher.stop();
        LOG.info("{} MasterService input step cost: {}",
                 this, TimeUtil.readableTime(watcher.getTime()));
        E.checkState(superstep <= this.maxSuperStep,
                     "The superstep {} can't be > maxSuperStep {}",
                     superstep, this.maxSuperStep);

        watcher.reset();
        watcher.start();
        // Step 3: Iteration computation of all supersteps.
        for (; superstepStat.active(); superstep++) {
            LOG.info("{} MasterService superstep {} started",
                     this, superstep);
            /*
             * Superstep iteration. The steps in each superstep are:
             * 1) Master waits workers superstep prepared.
             * 2) All managers call beforeSuperstep.
             * 3) Master signals the workers that the master prepared
             *    superstep.
             * 4) Master waits the workers do vertex computation.
             * 5) Master signal the workers that all workers have finished
             *    vertex computation.
             * 6) Master waits the workers end the superstep, and get
             *    superstepStat.
             * 7) Master compute whether to continue the next superstep
             *    iteration.
             * 8) All managers call afterSuperstep.
             * 9) Master signals the workers with superstepStat, and workers
             *    know whether to continue the next superstep iteration.
             */
            this.bsp4Master.waitWorkersStepPrepareDone(superstep);
            this.managers.beforeSuperstep(this.config, superstep);
            this.bsp4Master.masterStepPrepareDone(superstep);

            this.bsp4Master.waitWorkersStepComputeDone(superstep);
            this.bsp4Master.masterStepComputeDone(superstep);
            List<WorkerStat> workerStats =
                             this.bsp4Master.waitWorkersStepDone(superstep);
            superstepStat = SuperstepStat.from(workerStats);
            SuperstepContext context = new SuperstepContext(superstep,
                                                            superstepStat);
            // Call master compute(), note the worker afterSuperstep() is done
            boolean masterContinue = this.masterComputation.compute(context);
            if (this.finishedIteration(masterContinue, context)) {
                superstepStat.inactivate();
            }
            this.managers.afterSuperstep(this.config, superstep);
            this.bsp4Master.masterStepDone(superstep, superstepStat);

            LOG.info("{} MasterService superstep {} finished",
                     this, superstep);
        }
        watcher.stop();
        LOG.info("{} MasterService compute step cost: {}",
                 this, TimeUtil.readableTime(watcher.getTime()));

        watcher.reset();
        watcher.start();
        // Step 4: Output superstep for outputting results.
        this.outputstep();
        watcher.stop();
        LOG.info("{} MasterService output step cost: {}",
                 this, TimeUtil.readableTime(watcher.getTime()));
    }