Exemplo n.º 1
0
  /**
   * Returns the next <code>Operation</code> given the <code>lastOperation</code> according to the
   * current mix matrix.
   *
   * @param lastOperation The last <code>Operation</code> that was executed.
   */
  public Operation nextRequest(int lastOperation) {
    LoadProfile currentLoad = this.getTrack().getCurrentLoadProfile();
    this._latestLoadProfile = currentLoad;
    int nextOperation = -1;

    if (lastOperation == -1) {
      nextOperation = 0;
    } else {
      // Get the selection matrix
      double[][] selectionMix =
          this.getTrack().getMixMatrix(currentLoad.getMixName()).getSelectionMix();
      double rand = this._randomNumberGenerator.nextDouble();

      int j;
      for (j = 0; j < selectionMix.length; j++) {
        if (rand <= selectionMix[lastOperation][j]) {
          break;
        }
      }
      nextOperation = j;
    }

    Operation op = getOperation(nextOperation);

    operations.add(op);

    return op;
  }
  public static void main(String[] args) throws JSONException {
    HotspotScheduleCreator creator = new HotspotScheduleCreator();

    creator.setInitialWorkload(800);

    // Would like to give a duration and have the workload stretched/compressed into that
    LinkedList<LoadProfile> profiles = creator.createSchedule(new JSONObject());
    for (LoadProfile p : profiles) {
      if (p instanceof StorageLoadProfile) {
        StorageLoadProfile slp = (StorageLoadProfile) p;
        System.out.println(
            slp.getNumberOfUsers()
                + " "
                + slp.getNumHotObjects()
                + " "
                + slp.getHotTrafficFraction());
      } else System.out.println(p.getNumberOfUsers());
    }
  }