Ejemplo n.º 1
0
    @Override
    public String doInBackground() {
      System.out.println("Strart Job Monitoring Worker");
      String out = "";
      String defStatus = "Unknown";
      starttime = System.nanoTime();

      CURRENT_STATUS = RUN_STATUS.NOT_RUN;

      try {

        while (CURRENT_STATUS == RUN_STATUS.ACTIVE
            || CURRENT_STATUS == RUN_STATUS.SUBMITTED
            || CURRENT_STATUS == RUN_STATUS.NOT_RUN) {

          List<String> resultsToPublish = new ArrayList<String>();
          int updateTimeInMS = (int) (updateTimeInSeconds * 1000);
          Thread.sleep(updateTimeInMS);

          // get job status
          String status =
              Run.getJobStatusOnServer(jobid, defStatus, account, url, user, expName, password);
          resultsToPublish.add(0, defStatus);
          CURRENT_STATUS = RUN_STATUS.getStatus(status);

          // get outputs
          Run.getStatusFileFromServer(
              jobid, account, url, user, expName, analysDir, password, statusUpdateFiles);

          String report = "";
          if (statusUpdateFiles.exists()) {
            report = IO.readFileToString(statusUpdateFiles);
          }

          publish(report);
        }

      } catch (Exception e) {
        e.printStackTrace();

      } finally {

        publish(out);
      }
      return out;
    }
Ejemplo n.º 2
0
  /** Execute these events by this run. */
  public void run() {

    double segWithAccAhead;
    double start = System.currentTimeMillis() - startOfSimulation;

    for (PositionReport event : events) {

      if (event == null) System.out.println("NULL EVENT!!!");
      if (run == null) System.out.println("NULL RUN!!!" + event.toString());

      // READ: If a new vehicle on a travel lane arrives, lookup accidents ahead
      if (run.vehicles.get(event.id) == null && event.lane < 4) {

        if (event.min > run.time.minOfLastUpdateOfAccidentAhead) {

          segWithAccAhead = run.getSegWithAccidentAhead(runs, event);
          if (segWithAccAhead != -1) run.accidentsAhead.put(event.min, segWithAccAhead);
          run.time.minOfLastUpdateOfAccidentAhead = event.min;
        } else {
          segWithAccAhead =
              (run.accidentsAhead.containsKey(event.min)) ? run.accidentsAhead.get(event.min) : -1;
        }
      } else {
        segWithAccAhead = -1;
      }
      // System.out.println("Execute event " + event.toString() + " " + query_number + " times.");

      // Query replication
      for (int i = 1; i < query_number; i++) {
        run.fake_trafficManagement(
            event,
            segWithAccAhead,
            startOfSimulation,
            distrFinishTimes,
            schedStartTimes,
            accidentWarningsFailed,
            tollNotificationsFailed);
        run.fake_collectGarbage(event.min);
      }
      // Avoid multiple storage of complex events due to replicated queries
      // System.out.println("Size: " + (run.fake_output.tollNotifications.size() +
      // run.fake_output.accidentWarnings.size()));
      run.fake_output.tollNotifications.clear();
      run.fake_output.accidentWarnings.clear();

      // WRITE: Update this run and remove old data
      run.trafficManagement(
          event,
          segWithAccAhead,
          startOfSimulation,
          distrFinishTimes,
          schedStartTimes,
          accidentWarningsFailed,
          tollNotificationsFailed);
      run.collectGarbage(event.min);
    }

    double end = System.currentTimeMillis() - startOfSimulation;
    Double duration =
        end - start; // + (events.size()*query_number); // simulate replicated query execution

    total_exe_time.addAndGet(duration.intValue());

    // System.out.println("Run id: " + run.runID + " Duration: " + duration + " Total execution
    // time: " + total_exe_time.toString());

    // Count down the number of transactions
    transaction_number.countDown();
  }