// Path: xjob-executor/src/main/java/org/x/job/executor/pipeline/support/PipelineSupport.java
// public class PipelineSupport {
// 
//     private static String defaultPath = System.getProperty("user.dir")+"/tmp";
// 
//     public static String nextRandomName(){
//         return defaultPath + "/" +new Snowflake(randomSuffix());
//     }
// 
//     private static int randomSuffix(){
//         Random random = new Random(1024);
//         int max = 0;
//         for(int i = 0; i < 10; i++){
//             int curr = random.nextInt();
//             if(i == 0) max = random.nextInt();
//             else if(max < curr) max = curr;
//         }
//         return max;
//     }
// 
//     private PipelineSupport(){}
// 
//     public static Section jobToSection(List<String> jobUUIDs) throws Exception {
//         return fixSection(fixJob(jobUUIDs));
//     }
// 
//     public static List<Job> fixJob(List<String> jobUUIDs) throws Exception {
//         // 这里待处理，把JobUUIDs转成job集合，先做个伪代码
//         List<Job> jobs = new ArrayList<>();
//         for(String uuids : jobUUIDs){
//             jobs.add(getJobByPath(uuids));
//         }
//         return jobs;
//     }
// 
//     public static Section fixSection(List<Job> jobList){
//         Collections.reverse(jobList);
//         return push(null, jobList, 0);
//     }
// 
//     public static Section push(Section sct, List<Job> jobs, int i){
//         if(i == jobs.size())
//             return sct;
//         Section s = new Section(sct, jobs.get(i));
//         return push(s, jobs, ++i);
//     }
// 
//     private static Job getJobByPath(String path){
//         File file = new File(nextRandomName());
//         try (FileOutputStream fos = new FileOutputStream(file)){
//             byte[] javaFile = HDFSUtils.readHDFSFile(path);
//             fos.write(javaFile);
// 
//             Class<?> class1 = JDKCompile.getClass(file);
//             Object object = class1.newInstance();
//             return (Job) object;
//         } catch (Exception e){
//             return null;
//         }
//     }
// 
// }
// 
// Path: xjob-executor/src/main/java/org/x/job/executor/receive/TaskHandler.java
// public class TaskHandler {
// 
//     private static List<String> machines = new ArrayList<>(); //all machines
// 
//     private static List<String> job = new ArrayList<>(); // jobID
// 
//     private static Map<String, Object> others = new HashMap<>(); // all others
// 
//     public static List<String> getMachines() {
//         return machines;
//     }
// 
//     public static void setMachines(List<String> machines) {
//         TaskHandler.machines = machines;
//     }
// 
//     public static List<String> getJob() {
//         return job;
//     }
// 
//     public static void setJob(List<String> job) {
//         TaskHandler.job = job;
//     }
// 
//     public static Map<String, Object> getOthers() {
//         return others;
//     }
// 
//     public static void setOthers(Map<String, Object> others) {
//         TaskHandler.others = others;
//     }
// }


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.x.job.executor.pipeline.support.PipelineSupport;
import org.x.job.executor.receive.TaskHandler;
package org.x.job.executor.pipeline;


/**
 * pipeline执行器
 * @author Eightmonth
 */
@Service
public class PipelineExecutor {

// Path: xjob-executor/src/main/java/org/x/job/executor/pipeline/support/PipelineSupport.java
// public class PipelineSupport {
// 
//     private static String defaultPath = System.getProperty("user.dir")+"/tmp";
// 
//     public static String nextRandomName(){
//         return defaultPath + "/" +new Snowflake(randomSuffix());
//     }
// 
//     private static int randomSuffix(){
//         Random random = new Random(1024);
//         int max = 0;
//         for(int i = 0; i < 10; i++){
//             int curr = random.nextInt();
//             if(i == 0) max = random.nextInt();
//             else if(max < curr) max = curr;
//         }
//         return max;
//     }
// 
//     private PipelineSupport(){}
// 
//     public static Section jobToSection(List<String> jobUUIDs) throws Exception {
//         return fixSection(fixJob(jobUUIDs));
//     }
// 
//     public static List<Job> fixJob(List<String> jobUUIDs) throws Exception {
//         // 这里待处理，把JobUUIDs转成job集合，先做个伪代码
//         List<Job> jobs = new ArrayList<>();
//         for(String uuids : jobUUIDs){
//             jobs.add(getJobByPath(uuids));
//         }
//         return jobs;
//     }
// 
//     public static Section fixSection(List<Job> jobList){
//         Collections.reverse(jobList);
//         return push(null, jobList, 0);
//     }
// 
//     public static Section push(Section sct, List<Job> jobs, int i){
//         if(i == jobs.size())
//             return sct;
//         Section s = new Section(sct, jobs.get(i));
//         return push(s, jobs, ++i);
//     }
// 
//     private static Job getJobByPath(String path){
//         File file = new File(nextRandomName());
//         try (FileOutputStream fos = new FileOutputStream(file)){
//             byte[] javaFile = HDFSUtils.readHDFSFile(path);
//             fos.write(javaFile);
// 
//             Class<?> class1 = JDKCompile.getClass(file);
//             Object object = class1.newInstance();
//             return (Job) object;
//         } catch (Exception e){
//             return null;
//         }
//     }
// 
// }
// 
// Path: xjob-executor/src/main/java/org/x/job/executor/receive/TaskHandler.java
// public class TaskHandler {
// 
//     private static List<String> machines = new ArrayList<>(); //all machines
// 
//     private static List<String> job = new ArrayList<>(); // jobID
// 
//     private static Map<String, Object> others = new HashMap<>(); // all others
// 
//     public static List<String> getMachines() {
//         return machines;
//     }
// 
//     public static void setMachines(List<String> machines) {
//         TaskHandler.machines = machines;
//     }
// 
//     public static List<String> getJob() {
//         return job;
//     }
// 
//     public static void setJob(List<String> job) {
//         TaskHandler.job = job;
//     }
// 
//     public static Map<String, Object> getOthers() {
//         return others;
//     }
// 
//     public static void setOthers(Map<String, Object> others) {
//         TaskHandler.others = others;
//     }
// }


// Path: xjob-executor/src/main/java/org/x/job/executor/pipeline/PipelineExecutor.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.x.job.executor.pipeline.support.PipelineSupport;
import org.x.job.executor.receive.TaskHandler;

package org.x.job.executor.pipeline;


/**
 * pipeline执行器
 * @author Eightmonth
 */
@Service
public class PipelineExecutor {

    @Autowired