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

📄 resourcequery.java

📁 P2P模拟器P2Psim的程序源码
💻 JAVA
字号:
package graph;

import java.io.Serializable;

import org.jgraph.graph.DefaultGraphCell;

public class ResourceQuery implements Serializable
{
	public ResourceQuery(String searchFor, int startTime)
	{
		this.startTime = startTime;
		this.searchFor = searchFor;
		waitingTime = 0;
		numberOfAgents = 0;
	}

	public void start(DefaultGraphCell origin)
	{
		numberOfAgents++;
		
		//agentType = GraphEventManager.getReference().eventgetAgentType();
		//System.out.println(agentType);
		
		/*
		Agent agent = null;
		
		if (agentType.equals("Pheromone agents"))
		{
			agent = new PheromoneAgent(origin, this);
		}
		else if (agentType.equals("Simple agents"))
		{
			agent = new SimpleAgent(origin, this);
		}	
		else if (agentType.equals("Probability agents"))
		{
			agent = new ProbabilityAgent(origin, this);
		}
		*/
		
		Agent agent = GraphEventManager.getReference().constructNewAgent(origin, this);
		
		GraphEventManager.getReference().getProperties(origin).addInformation("Agents", agent);
		
		status = RUNNING;
	}
	
	public void finished()
	{
		numberOfAgents--;
		System.out.println("ResourceQuery :: finished : " + numberOfAgents);
		if (numberOfAgents == 0)
		{
			status = FINISHED;
		}
	}
	
	public void increaseWaitingTime()
	{
		if (status == RUNNING)
		{
			waitingTime++;
		}
	}
	
	public int getWaitingTime()
	{
		return waitingTime;
	}
	
	public int getStartTime()
	{
		return startTime;
	}
	
	public String getSearchFor()
	{
		return searchFor;
	}
	
	public int getNumberOfAgents()
	{
		return numberOfAgents;
	}
	
	public String getStatus()
	{
		if (status == RUNNING)
		{
			return "Running";
		}
		else if (status == TIMEOUT)
		{
			return "Timeout";
		}
		else if (status == FINISHED)
		{
			return "Finished";
		}

		return null;
	}

	protected String agentType;
	protected String searchFor;
	protected int waitingTime, startTime;
	protected int numberOfAgents;
	
	protected int status;
	protected static final int RUNNING = 1;
	protected static final int TIMEOUT = 2;
	protected static final int FINISHED = 3;

}

⌨️ 快捷键说明

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