Exemplo n.º 1
0
  public GridletReply askGridletStatusToAgent(int dst_agentID, int dst_resID, Gridlet gridlet) {
    GridletRequest request =
        new GridletRequest(this.get_id(), this.get_id(), dst_agentID, dst_resID, gridlet);
    int requestID = request.getRequestID();
    int reqrepID = request.getReqrepID();
    super.send(
        super.output,
        GridSimTags.SCHEDULE_NOW,
        Tags.GRIDLET_STATUS_REQ,
        new IO_data(request, gridlet.getGridletFileSize(), request.getDst_agentID()));

    Sim_type_p ptag = new Sim_type_p(Tags.GRIDLET_STATUS_REP);
    Sim_event ev = new Sim_event();
    super.sim_get_next(ptag, ev); // only look for this type of ack
    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;
  }
Exemplo n.º 2
0
  public GridletReply submitGridletToAgent(int dst_agentID, int dst_resID, Gridlet gridlet) {
    GridletRequest request =
        new GridletRequest(this.get_id(), this.get_id(), dst_agentID, dst_resID, gridlet);
    int requestID = request.getRequestID();
    int reqrepID = request.getReqrepID();
    super.send(
        super.output,
        GridSimTags.SCHEDULE_NOW,
        Tags.GRIDLET_SUBMIT_REQ,
        new IO_data(request, gridlet.getGridletFileSize(), request.getDst_agentID()));

    Sim_type_p ptag = new Sim_type_p(Tags.GRIDLET_SUBMIT_REP);
    Sim_event ev = new Sim_event();
    super.sim_get_next(ptag, ev); // only look for this type of ack
    GridletReply reply = GridletReply.get_data(ev);

    Assert.assertEquals(requestID, reply.getRequestID());
    Assert.assertEquals(Tags.GRIDLET_SUBMIT_REQ, reply.getRequestTAG());
    Assert.assertEquals(Tags.GRIDLET_SUBMIT_REP, ev.get_tag());
    double evrecv_time = GridSim.clock();
    if (reply.isOk()) {
      String msg =
          String.format(
              "%1$f %2$d %3$s <-- GOT GRIDLET_REPLY for Gridlet %4$d of Gridlet %5$d with result TRUE on AM_%6$s",
              evrecv_time,
              reqrepID,
              this.get_name(),
              reply.getReceivedGridlet().getGridletID(),
              reply.getRequest().getGridlet().getGridletID(),
              super.getEntityName(reply.getRequest().getDst_resID()));
      this.write(msg);
    } else {
      String msg =
          String.format(
              "%1$f %2$d %3$s <-- GOT GRIDLET_REPLY for Gridlet %4$d of Gridlet %5$d with result FALSE on AM_%6$s",
              evrecv_time,
              reqrepID,
              this.get_name(),
              reply.getReceivedGridlet().getGridletID(),
              reply.getRequest().getGridlet().getGridletID(),
              super.getEntityName(reply.getRequest().getDst_resID()));
      this.write(msg);
    }
    return reply;
  }