📄 abstractuser.java
字号:
GridletReply gridletReply = GridletReply.get_data(ev);
Assert.assertEquals(requestID, gridletReply.getRequestID());
Assert.assertEquals(Tags.GRIDLET_STATUS_REQ, gridletReply
.getRequestTAG());
Assert.assertEquals(Tags.GRIDLET_STATUS_REP, ev.get_tag());
double evrecv_time = GridSim.clock();
String msg = String
.format(
"%1$f %2$d %3$s <-- GOT GRIDLET_STATUS_REP for Gridlet %4$d of Gridlet %5$d with status %6$d",
evrecv_time, reqrepID, this.get_name(), gridletReply
.getReceivedGridlet().getGridletID(),
gridletReply.getRequest().getGridlet().getGridletID(),
gridletReply.getRequest().getGridlet()
.getGridletStatus());
this.write(msg);
return gridletReply;
}
public AgentReply testTestService() {
double evsend_time = 0;
int SIZE = 500;
AgentRequest request = null;
request = new AgentRequest(this.get_id(), this.get_id(), null, this
.getVirtualOrganization().getPlatform().getGridElement()
.get_id(), Sim_system.get_entity_id("TestService"),
EntityTypes.AGENT_ZOMBIE, SIZE, this.getVirtualOrganization()
.getPlatform().getGridElement().get_id(),
EntityTypes.NOBODY);
int requestID = request.getRequestID();
int reqrepID = request.getReqrepID();
super.send(super.output, GridSimTags.SCHEDULE_NOW,
Tags.TEST_SERVICE_REQ, new IO_data(request, SIZE, Sim_system
.get_entity_id("TestService")));
evsend_time = GridSim.clock();
String msg = String.format("%1$f %2$d %3$s --> %4$s", evsend_time,
reqrepID, this.get_name(), "TestService");
this.write(msg);
Sim_type_p ptag = new Sim_type_p(Tags.TEST_SERVICE_REP);
Sim_event ev = new Sim_event();
super.sim_get_next(ptag, ev); // only look for this type of ack
AgentReply reply = AgentReply.get_data(ev);
Assert.assertEquals(requestID, reply.getRequestID());
Assert.assertEquals(Tags.TEST_SERVICE_REQ, reply.getRequestTAG());
Assert.assertEquals(Tags.TEST_SERVICE_REP, ev.get_tag());
double evrecv_time = GridSim.clock();
msg = String.format("%1$f %2$d %3$s <-- %4$s", evrecv_time, reqrepID,
this.get_name(), "TestService");
this.write(msg);
return reply;
}
AgentReply requestToAgent(AgentRequest request, int tag) {
int requestID = request.getRequestID();
int reqrepID = request.getReqrepID();
double evsend_time = 0;
int agentType = request.getDst_entityType();
int SIZE;
if (tag == Tags.AGENT_RUN_REQ) {
SIZE = request.getDst_agentSize();
} else {
SIZE = 500;
}
if ((tag == Tags.AGENT_RUN_REQ) || (tag == Tags.AGENT_KILL_REQ)
|| (tag == Tags.AGENT_KILLAWAIT_REQ)
|| (tag == Tags.AGENT_PAUSE_REQ)
|| (tag == Tags.AGENT_RESUME_REQ)) {
super.send(super.output, GridSimTags.SCHEDULE_NOW, tag,
new IO_data(request, SIZE, request.getDst_resID()));
} else {
super.send(super.output, GridSimTags.SCHEDULE_NOW, tag,
new IO_data(request, SIZE, request.getDst_agentID()));
}
evsend_time = GridSim.clock();
String msg = String
.format(
"%1$f %2$d %3$s --> AM_%4$s::REQUEST %6$s (%7$s AID %9$d) %5$s AM_%8$s",
evsend_time, reqrepID, this.get_name(), super
.getEntityName(request.getDst_resID()),
EntityTypes.toString(request.getDst_entityType()), Tags
.toString(tag), super.getEntityName(request
.getDst_agentID()), super.getEntityName(request
.getDst_moveToresID()), request.getDst_AID());
this.write(msg);
Sim_type_p ptag = new Sim_type_p(tag + 1);
Sim_event ev = new Sim_event();
super.sim_get_next(ptag, ev); // only look for this type of ack
AgentReply agentReply = AgentReply.get_data(ev);
if (agentReply != null) {
Assert.assertEquals(requestID, agentReply.getRequestID());
Assert.assertEquals(tag, agentReply.getRequestTAG());
Assert.assertEquals(ev.get_tag(), tag + 1);
double evrecv_time = GridSim.clock();
msg = String
.format(
"%1$f %2$d %3$s <-- AM_%4$s::%7$s %8$s (%6$s AID %10$d) %5$s AM_%9$s",
evrecv_time, reqrepID, this.get_name(), super
.getEntityName(agentReply.getRequest()
.getDst_resID()), EntityTypes
.toString(agentType), super
.getEntityName(request.getDst_agentID()),
agentReply.isOk(), Tags.toString(tag),
super.getEntityName(request.getDst_moveToresID()),
request.getDst_AID());
this.write(msg);
}
return agentReply;
}
public AgentReply hasGridletsAgent(AgentRequest request, boolean trace) {
int requestID = request.getRequestID();
int reqrepID = request.getReqrepID();
double evsend_time = 0;
int agentType = request.getDst_entityType();
int SIZE = 500;
super.send(super.output, GridSimTags.SCHEDULE_NOW,
Tags.HASGRIDLETS_REQUEST, new IO_data(request, SIZE, request
.getDst_agentID()));
evsend_time = GridSim.clock();
String msg = String
.format(
"%1$f %2$d %3$s --> AM_%4$s::HASGRIDLETS_REQUEST %6$s (%7$s AID %9$d) %5$s AM_%8$s",
evsend_time, reqrepID, this.get_name(), super
.getEntityName(request.getDst_resID()),
EntityTypes.toString(request.getDst_entityType()), Tags
.toString(Tags.HASGRIDLETS_REQUEST), super
.getEntityName(request.getDst_agentID()), super
.getEntityName(request.getDst_moveToresID()),
request.getDst_AID());
if (trace) {
this.write(msg);
}
Sim_type_p ptag = new Sim_type_p(Tags.HASGRIDLETS_REPLY);
Sim_event ev = new Sim_event();
super.sim_get_next(ptag, ev); // only look for this type of ack
AgentReply agentReply = AgentReply.get_data(ev);
if (agentReply == null) {
Assert.fail();
}
Assert.assertEquals(requestID, agentReply.getRequestID());
Assert.assertEquals(Tags.HASGRIDLETS_REQUEST, agentReply
.getRequestTAG());
Assert.assertEquals(ev.get_tag(), Tags.HASGRIDLETS_REPLY);
double evrecv_time = GridSim.clock();
msg = String
.format(
"%1$f %2$d %3$s <-- AM_%4$s::%7$s %8$s (%6$s AID %10$d) %5$s AM_%9$s",
evrecv_time, reqrepID, this.get_name(), super
.getEntityName(agentReply.getRequest()
.getDst_resID()), EntityTypes
.toString(agentType), super
.getEntityName(request.getDst_agentID()),
agentReply.isOk(), Tags
.toString(Tags.HASGRIDLETS_REPLY), super
.getEntityName(request.getDst_moveToresID()),
request.getDst_AID());
if (trace) {
this.write(msg);
}
return agentReply;
}
public int getEntityType() {
return this.entityType;
}
public SimReport getReport_() {
return this.report_;
}
public FIFOScheduler getUserSched() {
return this.userSched;
}
public AbstractVirtualOrganization getVirtualOrganization() {
return this.virtualOrganization;
}
public void setEntityType(int entityType) {
this.entityType = entityType;
}
public void setReport_(SimReport report_) {
this.report_ = report_;
}
public void setUserSched(FIFOScheduler userSched) {
this.userSched = userSched;
}
public void setVirtualOrganization(
AbstractVirtualOrganization virtualOrganization) {
this.virtualOrganization = virtualOrganization;
}
/**
* Prints out the given message into stdout. In addition, writes it into a
* file.
*
* @param msg
* a message
*/
protected void write(String msg) {
System.out.println(msg);
if (this.report_ != null) {
this.report_.write(msg);
}
}
public void initialize() throws Exception {
// creates a report file
if (this.isTraceFlag() == true) {
this.setReport_(new SimReport(this.get_name()));
}
}
public abstract void printStats();
@Override
public void body() {
super.gridSimHold(AbstractGAP.getStartTime());
try {
this.initialize();
} catch (Exception e) {
e.printStackTrace();
}
try {
this.initWork();
} catch (Exception e) {
e.printStackTrace();
}
Sim_event ev = new Sim_event();
while (AbstractGAP.isRunning()) {
this.doWork();
super.sim_wait_for(Sim_system.SIM_ANY, 0.1, ev);
this.processEvent(ev);
while (super.sim_waiting() > 0) {
this.processEvents();
}
}
this.printStats();
// //////////////////////////////////////////////////////
// shut down I/O ports
this.shutdownUserEntity();
this.terminateIOEntities();
// don't forget to close the file
if (this.getReport_() != null) {
this.getReport_().finalWrite();
}
}
public abstract void initWork();
public abstract void doWork();
public boolean isTraceFlag() {
return traceFlag;
}
public void setTraceFlag(boolean traceFlag) {
this.traceFlag = traceFlag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -