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;
}
示例#2
0
void IOTracePopStr(char* buffer,int size) {
    if (errorstack.empty()) {
        *buffer = 0;
        return;
    }
    strncpy(buffer,errorstack.top().c_str(),size);
    errorstack.pop();
}
示例#3
0
 virtual bool reap_error(ErrorStack& errs)
 {
     if (!the_error)
         return false;
     errs.push(the_error.release());
     return true;
 }
示例#4
0
namespace KDL {

// Trace of the call stack of the I/O routines to help user
// interprete error messages from I/O
typedef std::stack<std::string>  ErrorStack;

ErrorStack errorstack;
// should be in Thread Local Storage if this gets multithreaded one day...


void IOTrace(const std::string& description) {
    errorstack.push(description);   
}


void IOTracePop() {
    errorstack.pop();
}

void IOTraceOutput(std::ostream& os) {
    while (!errorstack.empty()) {
        os << errorstack.top().c_str() << std::endl;
        errorstack.pop();
    }
}


void IOTracePopStr(char* buffer,int size) {
    if (errorstack.empty()) {
        *buffer = 0;
        return;
    }
    strncpy(buffer,errorstack.top().c_str(),size);
    errorstack.pop();
}

}
示例#5
0
 // For argument dependent lookup
 inline void swap(ErrorStack& s1, ErrorStack& s2)
 {
     s1.swap(s2);
 }
示例#6
0
void IOTraceOutput(std::ostream& os) {
    while (!errorstack.empty()) {
        os << errorstack.top().c_str() << std::endl;
        errorstack.pop();
    }
}
示例#7
0
void IOTracePop() {
    errorstack.pop();
}
示例#8
0
void IOTrace(const std::string& description) {
    errorstack.push(description);   
}
示例#9
0
 void swap(ParseStatus& other) noexcept
 {
     std::swap(m_code, other.m_code);
     std::swap(m_offset, other.m_offset);
     m_stack.swap(other.m_stack);
 }
示例#10
0
 bool has_error() const { return m_code != 0 || !m_stack.empty(); }
示例#11
0
 const_iterator end() const { return m_stack.end(); }
示例#12
0
 const_iterator begin() const { return m_stack.begin(); }