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

📄 dispatcherinfo.java

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

import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Vector;

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

public class DispatcherInfo
    implements Serializable
{
    private String dispatcherId;
    //private int serverPort;
    private String firstMonitorId;
    private String firstMonitorIp;
    private String secondMonitorId;
    private String secondMonitorIp;
    private String dispatcherIp;
  
    private int jobCount;
    //private int workerLoad;
    //需要定时手动更新的内容:
    private String dispatcherLoad;
    private int workerCount;
    private boolean canAcceptJob;
    private int idleWorkerCount;

    private Vector dispatcherJob; //队列元素是jobid,而不是job,不同于dispatcherjobmanagement中的joblist。

    public DispatcherInfo()
    {
        this.setDispatcherInfo("", "","","", "",0, 0, true, null,true);
    } // DispatcherInfo

    public DispatcherInfo(String d_Id,String f_M_Id,String f_M_Ip,String s_M_Id,String s_M_Ip)
    {
    this.setDispatcherInfo(d_Id,f_M_Id,f_M_Ip,s_M_Id,s_M_Ip,0,0,true,null,true);
    }

    public DispatcherInfo(String dispatcherId,String firstMonitorId,String secondMonitorId)
    {
        //....
    }
    
    /*
     * This function is invoked by monitor.nodemanagement, when the dispatcher take part in
     * the system for the first time.
     */
    public DispatcherInfo(String dispatcherId,String dispatcherIp)
    {
        this.dispatcherId = dispatcherId;
        this.firstMonitorId = "";
        this.firstMonitorIp="";
        this.secondMonitorId ="";
        this.secondMonitorIp="";
        this.jobCount = 0;
        this.workerCount = 0;
        //this.dispatcherUpdate();
        this.canAcceptJob = true;
        this.dispatcherJob = new Vector();
        this.idleWorkerCount=0;
        this.dispatcherIp=dispatcherIp;

    }

    public DispatcherInfo(DispatcherInfo d_info)
    {
    	this.setDispatcherInfo(d_info.getDispatcherId(),d_info.getFirstMonitorId(),d_info.getFirstMonitorIp(),d_info.getSecondMonitorId(),d_info.getSecondMonitorIp(),d_info.getJobCount(),d_info.getWorkerCount(),d_info.getCanAcceptJob(),d_info.getDispacherJob(),true);
    }

    public void setDispatcherInfo(String dispatcherId, String firstMonitorId,
                                  String firstMonitorIp,
                                  String secondMonitorId,
                                  String secondMonitorIp,int jobCount,
                                  int workerCount,
                                  boolean canAcceptJob, Vector dJob,boolean flag)
    {
        this.dispatcherId = dispatcherId;
        this.firstMonitorId = firstMonitorId;
        this.firstMonitorIp=firstMonitorIp;
        this.secondMonitorId = secondMonitorId;
        this.secondMonitorIp=secondMonitorIp;
        this.jobCount = jobCount;
        this.workerCount = workerCount;
        this.canAcceptJob = canAcceptJob;
       // this.dispatcherJob = dispatcherJob;
        //this.serverPort=5001;
        if(dJob!=null) this.dispatcherJob=new Vector(dJob);
        else dispatcherJob=new Vector();//notice this place...
        if(flag)
        {
        this.idleWorkerCount=0;
        //this.dispatcherUpdate();
        try{
        this.dispatcherIp=InetAddress.getLocalHost().getHostAddress();
        }catch(UnknownHostException e)
        {
        e.printStackTrace();
        }
        }
    } //DispatcherInfo

    public void init(String d_Id,String f_M_Id,String f_M_Ip,String s_M_Id,String s_M_Ip)
    {
    	this.setDispatcherInfo(d_Id,f_M_Id,f_M_Ip,s_M_Id,s_M_Ip,0,0,true,null,true);
    }

    public void setIdleWorkerCount(int n)
    {
    this.idleWorkerCount=n;
    }
    
    public void setDispatcherLoad(String s)
    {
    	this.dispatcherLoad=s;
    }

    public void setWorkerCount(int n)
    {
    this.workerCount=n;
    }

    /*public void dispatcherUpdate()
    {
        //It take our about one second to get the cpu information.
    CpuInformationMonitor cim=new CpuInformationMonitor();
    this.dispatcherLoad=cim.getCpuUsage();
    }*/

    public void insertJob(String jobId)
    {
        jobCount++;
        //synchronized(dispatcherJob)
		//{
        this.dispatcherJob.addElement(jobId);
		//}
        //return true;
    }

    public boolean cancelJob(String jobId)
    {
        jobCount--;
        return (this.dispatcherJob.remove(jobId));
    }

    public String getDispatcherId()
    {
        return this.dispatcherId;
    }

    public String getDispatcherIp()
    {
    return this.dispatcherIp;
    }


    public int getWorkerCount()
    {
        return this.workerCount;
    } // getWorkerCount

    public int getJobCount()
    {
        return this.jobCount;
    } // getJobCount

    /*public int getWorkerLoad()
    {
        return this.workerLoad;
    } // getWorkerLoad*/

    public String getDispatcherLoad()
    {
        return this.dispatcherLoad;
    } // getDispatcherLoad

    public boolean getCanAcceptJob()
    {
        return this.canAcceptJob;
    }

    public Vector getDispacherJob()
    {
        return this.dispatcherJob;
    } //getDispacherJob

    public String getFirstMonitorId()
    {
        return this.firstMonitorId;
    }

    public String getSecondMonitorId()
    {
        return this.secondMonitorId;
    }

    public int getIdleWorkerCount()
    {
        return this.idleWorkerCount;
    }

    public String getFirstMonitorIp()
    {
    	return this.firstMonitorIp;
    }

    public String getSecondMonitorIp()
    {
    	return this.secondMonitorIp;
    }

} //DispatcherInfo

⌨️ 快捷键说明

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