示例#1
0
  /*
   * Standard set of MetaData. Updated by invoke,
   * overridden by individual schedulers as needed.
   */
  public MetaData createMetaData() {
    MetaData md = new MetaData();
    md.setConversionFactor((long) 3600000); // everything is in mills.
    md.setStatusVector("2;3;4");
    md.setKValue(1);
    md.setMaxPriority(13);
    md.setTravelVector("10;20;40;60;80");
    md.setTravelImportance(40);
    md.setTravelFunction(1);

    return md;
  }
示例#2
0
  /*
   * Invoke prepares data calls run
   * This should likely not get overridden.
   */
  public void invoke(
      Long periodStart, Long hours, String topLevelLocator, SchedulerController scheduler) {
    schedulerRunComplete = false;
    schedulerUtility = BigDecimal.ZERO;
    schedulerRunTime = 0F;
    schedulerTotalSchedules = 0L;
    schedulerTotalLegalSchedules = 0L;

    SchedulerInterface si = new SchedulerInterface();
    SchedulingInputData sid = new SchedulingInputData();
    SchedulingOutputData sod = new SchedulingOutputData();

    // set up the metadata
    MetaData md = createMetaData();
    md.setPeriodStart(periodStart);
    md.setPeriodEnd(periodStart + (hours * 3600000)); // hours x 3.6M (convert to mills)
    md.setTopLevelLocatorId(topLevelLocator);
    md.setConversionFactor(3600000L);

    sid = si.buildSid(md);
    if (!validateSid(sid)) {
      // Validation Failed. Punt the invoke
      // TODO: Exception?
      return;
    }

    // We have a valid sid at this point. Run the scheduler
    try {
      sod = scheduler.schedule(sid);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // Validate sod. Don't persist and error
    if (sod == null) {
      System.out.println("Scheduler Output is NULL!");
      return;
    } else {
      if (!validateSod(sod)) {
        // Validation Failed. Do not persist.
        // TODO: Exception?
        return;
      }
    }

    // We have a valid sod at this point. Persist the results!
    si.persistSod(sod, md.getPeriodStart());

    schedulerUtility = sod.getUtility();
    schedulerRunTime = sod.getRunTime();
    schedulerTotalSchedules = sod.getNumberSchedulesAttempted();
    schedulerTotalLegalSchedules = sod.getNumberLegalSchedulesAttempted();
    schedulerRunComplete = true;
  } // ALL DONE, END INVOKE