joonejobrunner.java

来自「jooneDTE的源码」· Java 代码 · 共 85 行

JAVA
85
字号
package org.joone.dte;import java.io.*;import org.tiling.computefarm.Job;import org.tiling.computefarm.JobRunner;import org.tiling.computefarm.util.ClassServer;import org.springframework.beans.factory.xml.XmlBeanFactory;public class JooneJobRunner extends JobRunner {            public JooneJobRunner(Job job) throws IOException {        super(job);    }        public static void main(String[] args) throws Exception {        XmlBeanFactory factory;                if (args.length != 1) {            System.err.println("Usage: JooneJobRunner <parametersFile.xml>");            System.exit(1);        }        startClassServer();                /**** Pre-processing ****/        factory = getBeanFactory(args[0]);        JooneJob jooneJob = (JooneJob)factory.getBean("Job");                boolean done = false;        int cycle=0;        while (!done) {            /**** Processing ****/            JooneJobRunner runner = new JooneJobRunner(jooneJob);            runner.start();            runner.join();            ++cycle;                        /**** Stop-condition ****/            // Gets the results of the processing phase and...            factory = getBeanFactory(jooneJob.getLogName());            TaskList tasks = (TaskList)factory.getBean(jooneJob.getName());            /* ...inserts them into a TaskListFactory in order to provide the             * stop condition phase with a mechanism to retrieve the current             * list of NeuralNets             */            TaskListFactory tlf = new TaskListFactory();            tlf.setTaskList(tasks);            StopCondition control = jooneJob.getControl();            if (control != null)                done = control.done(tlf, cycle);            else                // If the StopCondition is not declared, we stop anyway                done = true;                                    /**** Post-processing ****/            if (!done) {                TaskListFactory newTasks = tlf;                Selector select = jooneJob.getSelector();                if (select != null) {                    newTasks = select.execute(tlf,  cycle);                    if (newTasks == null) {                        System.out.println("Error: the post-processing has generated no tasks to elaborate");                        done = true;                    }                }                jooneJob.setTaskFactory(newTasks);            }        }        System.out.println("DTE Stopped");    }        private static void startClassServer() throws IOException {        new ClassServer(new File("./"), 8383, true).start();    }        private static XmlBeanFactory getBeanFactory(String xmlDescr) throws IOException {        InputStream is = new FileInputStream(xmlDescr);        XmlBeanFactory factory = new XmlBeanFactory(is);        return factory;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?