コード例 #1
0
  public static String chooseService2Call(Configuration _config, int clientID) {

    Random rand = new Random();
    String service = _config.getServicesNames().get(rand.nextInt(_config.getServicesNumber() - 1));

    return service;
  }
コード例 #2
0
  public static int findHostID(Configuration config, String hostName) {

    int id = -1;

    for (int i = 0; i < config.getHostNames().size(); i++) {
      if (config.getHostNames().get(i).equals(hostName)) return i;
    }

    return id;
  }
コード例 #3
0
  public static int[][] findRequestPattern(Configuration _config) {

    // Moving Average
    int[][] r =
        new int[_config.getProvidersNumber()]
            [_config.getServicesNumber()]; // requests per service provider

    for (int j = 0; j < _config.getProvidersNumber(); j++)
      for (int s = 0; s < _config.getServicesNumber(); s++) {
        r[j][s] = 100 * (j + 1) / (s + 1);
      }

    System.out.println("Method Call: Find Request Pattern Called");
    return r;
  }
コード例 #4
0
  public static List<VMRequest> vmRequests2ActivateThisSlot(
      int slot, Slot[] _slots, Configuration _config) {

    List<VMRequest> vmRequests2ActivateThisSlot = new ArrayList<>();

    // Step 1: Find RequestIDs to remove
    for (int i = 0; i < _config.getProvidersNumber(); i++) {
      for (int j = 0; j < _slots[slot].getVmRequests2Remove()[i].size(); j++) {
        vmRequests2ActivateThisSlot.add(_slots[slot].getVmRequests2Activate()[i].get(j));
      }
    }

    return vmRequests2ActivateThisSlot;
  }
コード例 #5
0
  public static int determineVMService(int providerID, Configuration _config) {

    int type = Utilities.randInt(0, _config.getServicesNames().size() - 1);

    return type;
  }