/**
   * Process a cloudlet (job) return event.
   *
   * @param ev a SimEvent object
   * @pre ev != $null
   * @post $none
   */
  @Override
  protected void processCloudletReturn(SimEvent ev) {
    Cloudlet cloudlet = (Cloudlet) ev.getData();
    Job job = (Job) cloudlet;

    /** Generate a failure if failure rate is not zeros. */
    FailureGenerator.generate(job);

    getCloudletReceivedList().add(cloudlet);
    getCloudletSubmittedList().remove(cloudlet);

    CondorVM vm = (CondorVM) getVmsCreatedList().get(cloudlet.getVmId());
    // so that this resource is released
    vm.setState(WorkflowSimTags.VM_STATUS_IDLE);

    double delay = 0.0;
    if (Parameters.getOverheadParams().getPostDelay() != null) {
      delay = Parameters.getOverheadParams().getPostDelay(job);
    }
    schedule(this.workflowEngineId, delay, CloudSimTags.CLOUDLET_RETURN, cloudlet);

    cloudletsSubmitted--;
    // not really update right now, should wait 1 s until many jobs have returned
    schedule(this.getId(), 0.0, WorkflowSimTags.CLOUDLET_UPDATE);
  }
  /**
   * Update a cloudlet (job)
   *
   * @param ev a simEvent object
   */
  protected void processCloudletUpdate(SimEvent ev) {

    BaseSchedulingAlgorithm scheduler = getScheduler(Parameters.getSchedulingAlgorithm());
    scheduler.setCloudletList(getCloudletList());
    scheduler.setVmList(getVmsCreatedList());

    try {
      scheduler.run();
    } catch (Exception e) {
      Log.printLine("Error in configuring scheduler_method");
      e.printStackTrace();
    }

    List<Cloudlet> scheduledList = scheduler.getScheduledList();
    for (Cloudlet cloudlet : scheduledList) {
      int vmId = cloudlet.getVmId();
      double delay = 0.0;
      if (Parameters.getOverheadParams().getQueueDelay() != null) {
        delay = Parameters.getOverheadParams().getQueueDelay(cloudlet);
      }
      schedule(getVmsToDatacentersMap().get(vmId), delay, CloudSimTags.CLOUDLET_SUBMIT, cloudlet);
    }
    getCloudletList().removeAll(scheduledList);
    getCloudletSubmittedList().addAll(scheduledList);
    cloudletsSubmitted += scheduledList.size();
  }