Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
  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;
  }
Ejemplo n.º 3
0
  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;
  }