libfoedus-core
FOEDUS Core Library
foedus::snapshot::MapReduceBase Class Referenceabstract

Base class for LogMapper and LogReducer to share common code. More...

Detailed Description

Base class for LogMapper and LogReducer to share common code.

The shared parts are:

  • init/uninit
  • synchronization with gleaner (main thread)
Note
This is a private implementation-details of Snapshot Manager, thus file name ends with _impl. Do not include this header from a client program. There is no case client program needs to access this internal class.

Definition at line 51 of file mapreduce_base_impl.hpp.

#include <mapreduce_base_impl.hpp>

Inheritance diagram for foedus::snapshot::MapReduceBase:
Collaboration diagram for foedus::snapshot::MapReduceBase:

Public Member Functions

 MapReduceBase (Engine *engine, uint16_t id)
 
 MapReduceBase ()=delete
 
 MapReduceBase (const MapReduceBase &other)=delete
 
MapReduceBaseoperator= (const MapReduceBase &other)=delete
 
LogGleanerRefget_parent ()
 
uint16_t get_id () const
 
uint16_t get_numa_node () const
 
virtual std::string to_string () const =0
 Expects "LogReducer-x", "LogMapper-y" etc. More...
 
void launch_thread ()
 Start executing. More...
 
void join_thread ()
 
- Public Member Functions inherited from foedus::DefaultInitializable
 DefaultInitializable ()
 
virtual ~DefaultInitializable ()
 
 DefaultInitializable (const DefaultInitializable &)=delete
 
DefaultInitializableoperator= (const DefaultInitializable &)=delete
 
ErrorStack initialize () override final
 Typical implementation of Initializable::initialize() that provides initialize-once semantics. More...
 
ErrorStack uninitialize () override final
 Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics. More...
 
bool is_initialized () const override final
 Returns whether the object has been already initialized or not. More...
 
virtual ErrorStack initialize_once ()=0
 
virtual ErrorStack uninitialize_once ()=0
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Protected Member Functions

virtual ErrorStack handle_process ()=0
 Implements the specific logics in derived class. More...
 
ErrorCode check_cancelled () const
 Derived class's handle_process() should occasionally call this to exit if it's cancelled. More...
 

Protected Attributes

Engine *const engine_
 
LogGleanerRef parent_
 
const uint16_t id_
 Unique ID of this mapper or reducer. More...
 
const uint16_t numa_node_
 
std::atomic< bool > running_
 only for sanity check More...
 
std::thread thread_
 

Constructor & Destructor Documentation

foedus::snapshot::MapReduceBase::MapReduceBase ( Engine engine,
uint16_t  id 
)

Definition at line 37 of file mapreduce_base_impl.cpp.

38  : engine_(engine), parent_(engine), id_(id), numa_node_(engine->get_soc_id()), running_(false) {}
std::atomic< bool > running_
only for sanity check
const uint16_t id_
Unique ID of this mapper or reducer.
foedus::snapshot::MapReduceBase::MapReduceBase ( )
delete
foedus::snapshot::MapReduceBase::MapReduceBase ( const MapReduceBase other)
delete

Member Function Documentation

ErrorCode foedus::snapshot::MapReduceBase::check_cancelled ( ) const
protected

Derived class's handle_process() should occasionally call this to exit if it's cancelled.

Definition at line 54 of file mapreduce_base_impl.cpp.

References foedus::snapshot::LogGleanerRef::is_error(), foedus::kErrorCodeOk, foedus::kErrorCodeSnapshotCancelled, and parent_.

Referenced by foedus::snapshot::LogMapper::handle_process(), and foedus::snapshot::LogReducer::handle_process().

54  {
55  if (parent_.is_error()) {
57  }
58  return kErrorCodeOk;
59 }
0 means no-error.
Definition: error_code.hpp:87
0x0602 : "SNAPSHT: (internal error code) Snapshot task cancelled." .
Definition: error_code.hpp:162

Here is the call graph for this function:

Here is the caller graph for this function:

uint16_t foedus::snapshot::MapReduceBase::get_id ( ) const
inline

Definition at line 60 of file mapreduce_base_impl.hpp.

References id_.

Referenced by foedus::snapshot::operator<<().

60 { return id_; }
const uint16_t id_
Unique ID of this mapper or reducer.

Here is the caller graph for this function:

uint16_t foedus::snapshot::MapReduceBase::get_numa_node ( ) const
inline

Definition at line 61 of file mapreduce_base_impl.hpp.

References numa_node_.

Referenced by foedus::snapshot::LogReducer::initialize_once(), and foedus::snapshot::operator<<().

61 { return numa_node_; }

Here is the caller graph for this function:

LogGleanerRef* foedus::snapshot::MapReduceBase::get_parent ( )
inline

Definition at line 59 of file mapreduce_base_impl.hpp.

References parent_.

59 { return &parent_; }
virtual ErrorStack foedus::snapshot::MapReduceBase::handle_process ( )
protectedpure virtual

Implements the specific logics in derived class.

Implemented in foedus::snapshot::LogReducer, and foedus::snapshot::LogMapper.

void foedus::snapshot::MapReduceBase::join_thread ( )

Definition at line 45 of file mapreduce_base_impl.cpp.

References thread_, and to_string().

Referenced by foedus::snapshot::SnapshotManagerPimpl::handle_snapshot_child().

45  {
46  LOG(INFO) << "Waiting for the completion of thread: " << to_string();
47  if (thread_.joinable()) {
48  thread_.join();
49  }
50  LOG(INFO) << "Observed completion of thread: " << to_string();
51 }
virtual std::string to_string() const =0
Expects "LogReducer-x", "LogMapper-y" etc.

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::snapshot::MapReduceBase::launch_thread ( )

Start executing.

Definition at line 40 of file mapreduce_base_impl.cpp.

References thread_, and to_string().

Referenced by foedus::snapshot::SnapshotManagerPimpl::handle_snapshot_child().

40  {
41  LOG(INFO) << "Launching thread for " << to_string();
42  thread_ = std::move(std::thread(&MapReduceBase::handle, this));
43 }
virtual std::string to_string() const =0
Expects "LogReducer-x", "LogMapper-y" etc.

Here is the call graph for this function:

Here is the caller graph for this function:

MapReduceBase& foedus::snapshot::MapReduceBase::operator= ( const MapReduceBase other)
delete
virtual std::string foedus::snapshot::MapReduceBase::to_string ( ) const
pure virtual

Expects "LogReducer-x", "LogMapper-y" etc.

Used only for logging/debugging.

Implemented in foedus::snapshot::LogReducer, and foedus::snapshot::LogMapper.

Referenced by join_thread(), and launch_thread().

Here is the caller graph for this function:

Member Data Documentation

const uint16_t foedus::snapshot::MapReduceBase::id_
protected
LogGleanerRef foedus::snapshot::MapReduceBase::parent_
protected
std::atomic<bool> foedus::snapshot::MapReduceBase::running_
protected

only for sanity check

Definition at line 77 of file mapreduce_base_impl.hpp.

std::thread foedus::snapshot::MapReduceBase::thread_
protected

Definition at line 79 of file mapreduce_base_impl.hpp.

Referenced by join_thread(), and launch_thread().


The documentation for this class was generated from the following files: