92 : settings_ (settings),
94 dropped_messages_ (0),
95 consecutive_drops_ (0)
116 MADARA_GUARD_TYPE guard (
mutex_);
129 MADARA_GUARD_TYPE guard (
mutex_);
150 if (drop_rate >= 100 ||
162 drop_rate = drop_rate / (drop_burst - 1);
208 "PacketScheduler::add: ERROR: Invalid settings class\n");
224 MADARA_GUARD_TYPE guard (
mutex_);
236 MADARA_GUARD_TYPE guard (
mutex_);
245 drop_rate = drop_rate / (burst - 1);
248 StrideTask send_message (1 - drop_rate,
true);
253 queue_.push (drop_message);
254 queue_.push (send_message);
259 "PacketScheduler::reset: ERROR: Invalid settings class\n");
265 unsigned int log_level,
268 MADARA_GUARD_TYPE guard (
mutex_);
271 "%s: %d sent, %d dropped, %d consec dropped\n",
278 MADARA_GUARD_TYPE guard (
mutex_);
285 MADARA_GUARD_TYPE guard (
mutex_);
std::priority_queue< StrideTask, std::vector< StrideTask > > queue_
queue used by stride scheduling algorithm
void operator=(const PacketScheduler &rhs)
Assignment operator.
void print_status(unsigned int log_level=0, const char *prefix="PacketScheduler")
Prints the number of status of the packet scheduler.
const uint64_t max_stride(150000000)
int get_drop_type(void) const
Returns the policy type for packet drops.
uint64_t consecutive_drops_
Consecutive dropped messages.
bool operation
the type of operation
bool operator<(const StrideTask &rhs) const
Checks for lower pass value.
Provides scheduler for dropping packets.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
bool operator>(const StrideTask &rhs) const
Checks for greater pass value.
PacketScheduler(const QoSTransportSettings *settings=0)
Default constructor.
bool add(void)
Adds a message to the monitor.
void set_rate(double rate)
Sets the ticket rate, which influences stride.
MADARA_Export double rand_double(double floor=0.0, double ceiling=1.0, bool set_seed_to_time=true)
Returns a random double between floor and ceiling.
uint64_t tickets
the number of tickets, which influences stride
uint64_t get_drop_burst(void) const
Returns the bursts of packet drops.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
uint64_t stride
the stride to take
const QoSTransportSettings * settings_
Transport settings.
void clear(void)
Clears the packet scheduler.
bool operator==(const StrideTask &rhs) const
Checks for pass equality.
void attach(const QoSTransportSettings *settings)
Attaches settings.
virtual ~PacketScheduler()
Destructor.
uint64_t dropped_messages_
Number of dropped messages.
uint64_t get_dropped(void)
Queries the monitor for the current dropped messages.
MADARA_LOCK_TYPE mutex_
Mutex for supporting multithreaded monitor calls.
Container for quality-of-service settings.
void reset(void)
Resets the packet scheduler to current settings.
StrideTask(double rate, bool op)
Constructor.
uint64_t pass
the current pass which determines next schedule
double get_drop_rate(void) const
Returns the percentage of dropped packets to enforce on sends.
INTERNAL USE: Task that can be added to a Stride scheduler
void operator++(void)
Increases pass by stride.
uint64_t sent_messages_
Number of sent messages.
uint64_t get_sent(void)
Queries the monitor for the current sent messages per second over the past window.