Exemplo n.º 1
0
  public void messageIn(Message m) {
    if (m instanceof Reply) {
      if (m.getDest().equals(this.getSOID())) {
        WebSim.traceObjectOperation("Client", getName(), "Recieved reply " + m);

        in++;
        replies.add(((Reply) m).requestTimeToNow());
      } else {
        WebSim.warning(
            "There is probably a routing error in your system specification.\n"
                + "Client "
                + getName()
                + " has recieved a reply destined for  "
                + m.getDest()
                + "\n"
                + "It will be ignored.");

        faultyIn++;
      }
    } else if (m instanceof Refusal) {
      WebSim.traceObjectOperation("Client", getName(), "Recieved refusal " + m);
      refusals++;
    } else {
      WebSim.warning(
          "WARNING: There is probably a routing error in your system specification.\n"
              + "Client "
              + getName()
              + " has recieved the message  "
              + m
              + "\n"
              + "It will be ignored.");

      faultyIn++;
    }
  }
Exemplo n.º 2
0
  public void runProcess() throws InterruptedException {
    while (true) {
      hold(interarrivalTime.next());

      SystemObjectID destination = destinations[random.nextInt(destinations.length)];

      String fileName =
          WebSim.isTraceObjectOperation()
              ? "/testFile_" + random.nextInt(FILE_RANDOM_NAME_EXCLUSIVEMAX) + ".html"
              : "/testFile_uncalculated.html";

      Request r = new Request(fileName, this.getSOID(), destination);

      WebSim.traceObjectOperation("Client", getName(), "Created " + r + ": finding route.");

      Connection c = findRoute(r);

      if (c != null) {
        WebSim.traceObjectOperation("Client", getName(), "Route found. Sending " + r + " via " + c);
        c.sendMessageVia(r);
        out++;
      }
    }
  }
Exemplo n.º 3
0
  public String toFinalString() {
    String s = "Client " + getName() + "\n";
    s +=
        "Sent "
            + out
            + " requests, Recieved "
            + in
            + " replies, "
            + WebSim.formatFloat(((float) in) / ((float) out) * 100)
            + "% replies.\n";

    if (faultyIn > 0) s += "Also recieved " + faultyIn + " faulty messages.\n";

    if (refusals > 0) s += "Also recieved " + refusals + " refusals.\n";

    s +=
        "Average response time: "
            + WebSim.formatDouble(replies.mean())
            + ", variance in response time: "
            + WebSim.formatDouble(replies.variance())
            + "\n";

    return s;
  }