📄 gridagent.java
字号:
switch (ev.get_tag()) {
// Denotes the return of a Gridlet back to sender
case GridSimTags.GRIDLET_RETURN:
// Assert.fail();
Gridlet receivedGridlet = (Gridlet) ev.get_data();
this.getScheduler().gridletReceive(receivedGridlet);
break;
default:
break;
}
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends ACK/NACK about presence of gridlets
* in an agent
* @param ev
* @param agentRequest
* @param flag
*/
private void sendHASGRIDLETSACKNACK(Sim_event ev,
AgentRequest agentRequest, boolean flag) {
AgentReply agentReply = null;
int SIZE = 500;
int replyToID = 0;
replyToID = agentRequest.getSrc_ID();
agentReply = new AgentReply(ev.get_tag(), flag, agentRequest);
super.send(super.output, GridSimTags.SCHEDULE_NOW,
Tags.HASGRIDLETS_REPLY,
new IO_data(agentReply, SIZE, replyToID));
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends ACK/NACK related to gridlets in an
* agent
* @param ev
* @param gridletRequest
* @param flag
* @param gridlet
*/
private void sendSTATUSACKNACK(Sim_event ev, GridletRequest gridletRequest,
boolean flag, Gridlet gridlet) {
GridletReply gridletReply = null;
int SIZE = 500;
int replyToID = 0;
replyToID = gridletRequest.getSrc_ID();
gridletReply = new GridletReply(ev.get_tag(), flag, gridletRequest,
gridlet);
super.send(super.output, GridSimTags.SCHEDULE_NOW,
Tags.GRIDLET_STATUS_REP, new IO_data(gridletReply, SIZE,
replyToID));
}
/**
* @TODO Fix semanthics Sends ACK related to gridlets in an agent
* @param ev
* @param gridletRequest
* @param gridlet
*/
@SuppressWarnings("unused")
private void sendSTATUSACK(Sim_event ev, GridletRequest gridletRequest,
Gridlet gridlet) {
this.sendSTATUSACKNACK(ev, gridletRequest, true, gridlet);
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends NACK related to gridlets in an agent
* @param ev
* @param gridletRequest
* @param gridlet
*/
@SuppressWarnings("unused")
private void sendSTATUSNACK(Sim_event ev, GridletRequest gridletRequest,
Gridlet gridlet) {
this.sendSTATUSACKNACK(ev, gridletRequest, false, gridlet);
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed
* @param ev
* @param gridletRequest
* @param flag
* @param gridlet
*/
private void sendACKNACK(Sim_event ev, GridletRequest gridletRequest,
boolean flag, Gridlet gridlet) {
GridletReply gridletReply = null;
int SIZE = 500;
int replyToID = 0;
replyToID = gridletRequest.getSrc_ID();
gridletReply = new GridletReply(ev.get_tag(), flag, gridletRequest,
gridlet);
@SuppressWarnings("unused")
double evsend_time = GridSim.clock();
super.send(super.output, GridSimTags.SCHEDULE_NOW,
Tags.GRIDLET_SUBMIT_REP, new IO_data(gridletReply, SIZE,
replyToID));
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends ACK related to gridlets presence in
* an agent
* @param ev
* @param agentRequest
*/
private void sendHASGRIDLETSACK(Sim_event ev, AgentRequest agentRequest) {
this.sendHASGRIDLETSACKNACK(ev, agentRequest, true);
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends NACK related to gridlets presence in
* an agent
* @param ev
* @param agentRequest
*/
private void sendHASGRIDLETSNACK(Sim_event ev, AgentRequest agentRequest) {
this.sendHASGRIDLETSACKNACK(ev, agentRequest, false);
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends ACK related to gridlets in an agent
* @param ev
* @param agentRequest
*/
private void sendACK(Sim_event ev, GridletRequest gridletRequest,
Gridlet gridlet) {
this.sendACKNACK(ev, gridletRequest, true, gridlet);
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed Sends NACK related to gridlets in an agent
* @param ev
* @param agentRequest
*/
private void sendNACK(Sim_event ev, GridletRequest gridletRequest,
Gridlet gridlet) {
this.sendACKNACK(ev, gridletRequest, false, gridlet);
}
@Override
protected boolean hasGridlets() {
return this.getScheduler().hasGridlets();
}
/**
* @TODO Fix semanthics
* @TODO Comments to be completed
* @param agentRequest
*/
@Override
protected void onWaitingGridlets(AgentRequest agentRequest) {
// Assert.fail();
}
/**
* Sends a Gridlet to the Grid Element of this agent without any delay. An
* acknowledgement to denote the success of this method is by default off or
* false
*
* @param gl
* the gridlet submitted
* @return <tt>true</tt> for successful submission <tt>false</tt>
* otherwise
*/
public boolean gridletSubmit(Gridlet gl) {
return super.gridletSubmit(gl, this.getResourceID(), 0.0, true);
}
/**
* Syncronously receives a gridlet from Grid Element
*
* @return <tt>true</tt> for successful receival <tt>false</tt>
* otherwise
*/
@Override
public Gridlet gridletReceive() {
return super.gridletReceive();
}
/**
* Cancels a Gridlet on the Grid Element of this agent without any delay. An
* acknowledgement to denote the success of this method is by default off or
* false
*
* @param gl
* the gridlet to be canceled
* @return canceled gridlet
*/
public Gridlet gridletCancel(Gridlet gl) {
return super.gridletCancel(gl, this.getResourceID(), 0.0);
}
/**
* Pauses a Gridlet on the Grid Element of this agent without any delay. An
* acknowledgement to denote the success of this method is by default off or
* false
*
* @param gl
* the gridlet to be paused
* @return <tt>true</tt> for successful pause <tt>false</tt> otherwise
*/
public boolean gridletPause(Gridlet gl) {
return super.gridletPause(gl, this.getResourceID(), 0.0);
}
/**
* Resumes a Gridlet on the Grid Element of this agent without any delay. An
* acknowledgement to denote the success of this method is by default off or
* false
*
* @param gl
* the gridlet to be resumed
* @return <tt>true</tt> for successful resume <tt>false</tt> otherwise
*/
public boolean gridletResume(Gridlet gl) {
return super.gridletResume(gl, this.getResourceID(), 0.0);
}
/**
*
* @param gl
* the gridlet of which to know the status
* @return the current Gridlet status or <tt>-1</tt> if not found. The
* various Gridlet status can be found in Gridlet class.
*/
public int gridletStatus(Gridlet gl) {
return super.gridletStatus(gl, this.getResourceID());
}
/**
* This method is responsible for moving a gridlet to another resource ID
*
* @TODO Note: To complete migration it's needed to change the agent that
* manages
* @TODO the gridlet using an existing agent or the migrated entity of this
*
* @param gl
* the gridlet to move
* @param destResID
* the destination resource ID
* @return <tt>true</tt> for successful move <tt>false</tt> otherwise
*/
public boolean gridletMove(Gridlet gl, int destResID) {
return super.gridletMove(gl, this.getResourceID(), destResID, 0.0);
}
public RRScheduler getScheduler() {
return scheduler;
}
public void setScheduler(RRScheduler scheduler) {
this.scheduler = scheduler;
}
public double getMIPS() {
return this.getScheduler().getMIPS();
}
public long getInputSize() {
return this.getScheduler().getInputSize();
}
public long getOutputSize() {
return this.getScheduler().getOutputSize();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -