Beispiel #1
0
int run_task(task_type_t type, metric_type_t metric, task_option_t *options, char *id) {
  switch (type) {
    case PROCESS:
      return handle_process(metric, options, id);
    case DIRECTORY:
      return handle_directory(options, id);
    case DISK:
      return handle_disk(metric, options, id);
    case SWAP:
      return handle_swap(id);
    case LOAD:
      return handle_load(id);
    case TOTAL:
      return handle_total(id, metric);
    default: {
      // We've been passed an incorrectly initialized task. Shouldn't happen, but handle
      // for debugging. Plus it gets GCC off my case.
      task_report_t report;
      init_task_report(&report, id, type, metric);
      sprintf(report.message, "FATAL CAUSE INVALID_TASK");
      lpush(&reports, &report);
      return NOTGIOS_GENERIC_ERROR;
    }
  }
}
void MapReduceBase::handle() {
  if (running_) {
    LOG(FATAL) << "Duplicate launch of " << to_string();
  }
  running_ = true;
  LOG(INFO) << "Started running: " << to_string() << " NUMA node=" << static_cast<int>(numa_node_);
  thread::NumaThreadScope scope(numa_node_);
  ErrorStack result = handle_process();  // calls main logic in derived class
  if (result.is_error()) {
    if (result.get_error_code() == kErrorCodeSnapshotCancelled) {
      LOG(WARNING) << to_string() << " cancelled";
    } else {
      LOG(ERROR) << to_string() << " got an error while processing:" << result;
      parent_.increment_error_count();
      parent_.wakeup();
    }
  } else {
    LOG(INFO) << to_string() << " successfully finished";
  }

  // let the gleaner know that I'm done.
  uint16_t value_after = parent_.increment_completed_count();
  ASSERT_ND(value_after <= parent_.get_all_count());
  if (value_after == parent_.get_all_count()) {
    // I was the last one to go into sleep, this means everything is fully processed.
    // let gleaner knows about it.
    ASSERT_ND(parent_.is_all_completed());
    LOG(INFO) << to_string() << " was the last one to finish, waking up gleaner.. ";
    parent_.wakeup();
  }

  parent_.increment_exit_count();
  LOG(INFO) << "Stopped running: " << to_string();
  running_ = false;
}
Beispiel #3
0
void widget::process() {
	handle_process();
}
Beispiel #4
0
			void process(float t) {
				handle_process(t);
			}