50 #ifndef Common_FailureInducer_h
51 #define Common_FailureInducer_h
57 #include <unordered_map>
80 static bool enabled() {
return instance != 0; }
120 typedef std::unordered_map<String, failure_inducer_state *>
StateMap;
134 #define HT_MAYBE_FAIL(_label_) \
135 if (Hypertable::FailureInducer::enabled()) { \
136 Hypertable::FailureInducer::instance->maybe_fail(_label_); \
142 #define HT_MAYBE_FAIL_X(_label_, _exp_) \
143 if (Hypertable::FailureInducer::enabled() && (_exp_)) { \
144 Hypertable::FailureInducer::instance->maybe_fail(_label_); \
148 #define HT_FAILURE_SIGNALLED(_label_) \
149 Hypertable::FailureInducer::enabled() && \
150 Hypertable::FailureInducer::instance->failure_signalled(_label_)
152 #endif // Common_FailureInducer_h
uint32_t iteration
Current iteration of the failure.
void clear()
Clears the failure inducer.
std::string String
A String is simply a typedef to std::string.
int failure_type
The failure type; an enum in FailureInducer.cc.
std::mutex m_mutex
A mutex to serialize access.
uint32_t trigger_iteration
Number of iterations after which the failure is triggered.
static FailureInducer * instance
This is a singleton class.
static bool enabled()
Returns true if the FailureInducer is enabled (= if an instance was allocated)
void maybe_fail(const String &label)
Tests and executes the induced failures.
void parse_option(String spec)
Parses a spec string (as explained above) and stores it in an internal structure. ...
std::unordered_map< String, failure_inducer_state * > StateMap
int pause_millis
Milliseconds to pause (if type is FAILURE_TYPE_PAUSE)
StateMap m_state_map
A list of all failure settings.
A String class based on std::string.
bool failure_signalled(const String &label)
Returns true if a failure was signalled.
void parse_option_single(String option)
Helper function to parse a single option.
String extensions and helpers: sets, maps, append operators etc.
Internal structure to store a single failure setting.
int error_code
The error code which is thrown (if type is FAILURE_TYPE_THROW)