⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taskrun.java

📁 分布式计算平台P2HP-1的源代码;P2HP-1是基于P2P的高性能计算平台
💻 JAVA
字号:
package cn.edu.hust.cgcl.biogrid.BioSDK;

import java.io.Serializable;
import java.text.ParseException;

import cn.edu.hust.cgcl.biogrid.dispatcher.SubJob;
import cn.edu.hust.cgcl.biogrid.service.MessageService;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public abstract class TaskRun  implements Serializable
{
    public abstract void run();
    public abstract int getStatus();

    protected String dataFile=null;
    protected String dataFileFolder=null;
    protected int taskStat=SubTask.SUBTASK_STOP;
    private SubJob subTask=null;
    private String workerId=null;
    private String userId=null;
    private String userPwd=null;
    public static String resultPath=null;
    public static String programPath=null;

    protected String subTaskId="";
    //protected int

    public void setDataFile(String datafile)
    {
        this.dataFile = datafile;
    } // setDataFile

    public void setDataFileFolder(String datafilefolder)
    {
        this.dataFileFolder = datafilefolder;
    } // setDataFile

    public void start(SubJob subtask, String datafile, String datafilefolder,
                      String workerid,String programpath,String resultPath)
        throws Exception
    {
        this.workerId=workerid;
        this.dataFile=datafile;
        this.dataFileFolder=datafilefolder;
        this.subTask=subtask;
        this.programPath=programpath;
        this.resultPath=resultPath;
        this.userId=subtask.getUserId();
        this.userPwd=subtask.getUserPwd();
        this.subTaskId=subTask.getSubJobId();

        if (subTask==null)
        {
            throw new ParseException("parameter error!", 0);
        }
        this.taskStat = SubTask.SUBTASK_RUNNING;
        run();
        this.taskStat = SubTask.SUBTASK_FINISH;
    } // start

    public void start(String datafile, String datafilefolder,String resultPath)
    throws Exception
    {
        this.dataFile=datafile;
        this.dataFileFolder=datafilefolder;
        this.resultPath=resultPath;
        //this.subTask=subtask;
       // if (subTask==null)
        //{
          //  throw new ParseException("parameter error!", 0);
        //}
        this.taskStat = SubTask.SUBTASK_RUNNING;
        run();
        this.taskStat = SubTask.SUBTASK_FINISH;
    } // start

    public boolean sendResult(String originalpath, String resultname)
    throws Exception
    {
        MessageService msgService=new MessageService();
        /*if (msgService.conncetRequest(subTask.getDataServerIp(), subTask.getDataServerPort())<0)
        {
            throw new ParseException("protocol parse error0!", 0);
        } // if
        if (msgService.registerServ(this.userId, this.userPwd, "worker") < 0)
        {
            msgService.disConnect();
            throw new ParseException("protocol parse error1!", 0);
        } // if
        */
        //if (msgService.insertSubTaskResult(null, resultname, "anom", subTask.getJobId()) !=0)
        if (resultname!=null)
        {
            if (msgService.insertResultOnce(subTask.getDataServerIp(), 
            		this.userId, this.userPwd,originalpath, resultname,
					this.userId, subTask.getJobId(),subTask.getSubJobId(),
					workerId) != 0)
            {
                //msgService.disConnect();
                throw new ParseException("protocol parse error2!", 0);
            } // if
        } // if
        else
        {
            if (msgService.insertResultOnce(subTask.getDataServerIp(), 
            		this.userId, this.userPwd,originalpath,
					this.userId, subTask.getJobId(),subTask.getSubJobId(),
					workerId) != 0)
            {
                //msgService.disConnect();
                throw new ParseException("protocol parse error3!", 0);
            } // if
        } // else

        //msgService.disConnect();

        return true;
    } // sendResult

} // TaskRun

⌨️ 快捷键说明

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