
public class ExtremeTask {
	//private TaskList tasklist = null;
	SeverList serverlist = null;
	
	public boolean  taskSolve(TaskList tasklist)
	{
		//this.tasklist = tasklist;
		serverlist = main_program.serverlist_head;
		if(isExtremetask(tasklist))
		{
			serverlist =  main_program.serverlist_head;
			
			while(serverlist.getNext() != null)
			{
				serverlist = serverlist.getNext();
				if( serverlist.get_all_Memory() >= tasklist.get_need_Memory())
				{
					//添加到队列中
					System.out.println("是极端任务：" + tasklist.get_taskName() +":"+ tasklist.get_need_Memory()+",分给："+serverlist.get_host_name()+serverlist.get_all_Memory());
					serverlist.queue.add(tasklist);
					return true;
				}
		
			}
			
		}
		return false;
	}
	
	public boolean isExtremetask(TaskList tasklist)
	{
		int i=0;
		int host_name = Input.server_num;
		serverlist =  main_program.serverlist_head;
		while(serverlist.getNext() != null)
		{
			serverlist = serverlist.getNext();
			if( serverlist.get_all_Memory() >= tasklist.get_need_Memory())
			{
				i++;
			}
		}
		if(i == 0)
		{
			System.out.println(tasklist.get_taskName()+"该任务超出服务器负载的，无法执行,强行作废");
			tasklist.need_Memory = 0;
			return false;
		}
		else if(i > 1 )
		{
			return false;
		}
		else return true;
		
	}

}
