0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Macros
FailureInducer.h File Reference

The FailureInducer simulates errors. More...

#include <Common/String.h>
#include <Common/StringExt.h>
#include <mutex>
#include <unordered_map>
Include dependency graph for FailureInducer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Hypertable::FailureInducer
 
struct  Hypertable::FailureInducer::failure_inducer_state
 Internal structure to store a single failure setting. More...
 

Namespaces

 Hypertable
 Hypertable definitions
 

Macros

#define HT_MAYBE_FAIL(_label_)
 
#define HT_MAYBE_FAIL_X(_label_, _exp_)
 
#define HT_FAILURE_SIGNALLED(_label_)
 

Detailed Description

The FailureInducer simulates errors.

The FailureInducer parses a list of specs (usually set in a test) and returns errors, throws exceptions or terminates the application depending on the these arguments.

There are a few helper macros that will check for induced failures:

Will induce a failure if "label" is active HT_MAYBE_FAIL(label)

Will induce a failure if "label" is active and "test" is true HT_MAYBE_FAIL_X(label, test)

Allows usage in an "if" block: if (HT_FAILURE_SIGNALLED("lbl")) { } HT_FAILURE_SIGNALLED(label) { }

A FailureInducer spec has the following layout: label:action<(parameter)>:iteration

Examples: label:exit:0 label:signal:10 label:pause(<milli-sec>):5 label:throw(<decimal-code>):0 label:throw(0x<hexadecimal-code>):0

Definition in file FailureInducer.h.

Macro Definition Documentation

#define HT_FAILURE_SIGNALLED (   _label_)
Value:
static FailureInducer * instance
This is a singleton class.
static bool enabled()
Returns true if the FailureInducer is enabled (= if an instance was allocated)
bool failure_signalled(const String &label)
Returns true if a failure was signalled.

Definition at line 148 of file FailureInducer.h.

#define HT_MAYBE_FAIL (   _label_)
Value:
}
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.

Definition at line 134 of file FailureInducer.h.

#define HT_MAYBE_FAIL_X (   _label_,
  _exp_ 
)
Value:
}
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.

Definition at line 142 of file FailureInducer.h.