BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balm::PublicationScheduler Class Reference

#include <balm_publicationscheduler.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (PublicationScheduler, bslma::UsesBslmaAllocator)
 
 PublicationScheduler (MetricsManager *metricsManager, bdlmt::TimerEventScheduler *eventScheduler, bslma::Allocator *basicAllocator=0)
 
 ~PublicationScheduler ()
 
void scheduleCategory (const char *category, const bsls::TimeInterval &interval)
 
void scheduleCategory (const Category *category, const bsls::TimeInterval &interval)
 
void setDefaultSchedule (const bsls::TimeInterval &interval)
 
int cancelCategorySchedule (const char *category)
 
int cancelCategorySchedule (const Category *category)
 
int clearDefaultSchedule ()
 
void cancelAll ()
 
MetricsManagermanager ()
 
bool findCategorySchedule (bsls::TimeInterval *result, const char *category) const
 
bool findCategorySchedule (bsls::TimeInterval *result, const Category *category) const
 
bool getDefaultSchedule (bsls::TimeInterval *result) const
 
int getCategorySchedule (bsl::vector< bsl::pair< const Category *, bsls::TimeInterval > > *result) const
 
int getCategorySchedule (std::vector< std::pair< const Category *, bsls::TimeInterval > > *result) const
 
const MetricsManagermanager () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

class PublicationScheduler_Proctor
 

Detailed Description

This class defines a mechanism for scheduling the periodic publication of metrics. Each publication scheduler object is supplied the address of a MetricsManager and a bdlmt::TimerEventScheduler at construction. The metrics manager is used to publish metrics, while the timer-event scheduler provides the underlying scheduling mechanism. Metrics are scheduled for publication using the scheduleCategory and setDefaultSchedule methods. The scheduleCategory method schedules an individual category to be publisher periodically at the provided interval, whereas setDefaultSchedule schedules the periodic publication of any category not given an individual schedule. The publication scheduler will create a recurring timer for each unique time interval supplied, and will group together categories that share a common time interval into a single call to MetricsManager::publish. Note that it is left unspecified whether publication events that occur on a common multiple of different intervals will be grouped into a single invocation of MetricsManager::publish.

See balm_publicationscheduler

Constructor & Destructor Documentation

◆ PublicationScheduler()

balm::PublicationScheduler::PublicationScheduler ( MetricsManager metricsManager,
bdlmt::TimerEventScheduler eventScheduler,
bslma::Allocator basicAllocator = 0 
)

Create a publication scheduler that will use the specified metricsManager to publish metrics, and the specified eventScheduler to supply timer events. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~PublicationScheduler()

balm::PublicationScheduler::~PublicationScheduler ( )

Destroy this publication scheduler and cancel any pending publications. Note that, if any metrics are currently being published, this operation will block until all of their publications have completed.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

balm::PublicationScheduler::BSLMF_NESTED_TRAIT_DECLARATION ( PublicationScheduler  ,
bslma::UsesBslmaAllocator   
)

◆ cancelAll()

void balm::PublicationScheduler::cancelAll ( )

Cancel all periodic publication of metrics. This operation (atomically) clears the default publication schedule and cancels the publication schedule of any category individually scheduled using the scheduleCategory method. Any scheduled publication is either canceled or completed before this method returns.

◆ cancelCategorySchedule() [1/2]

int balm::PublicationScheduler::cancelCategorySchedule ( const Category category)

Cancel the periodic publication of the specified category. Return 0 on success, and a non-zero value if the category is not scheduled for publication. Any scheduled publication of category is either canceled or completed before this method returns. The behavior is undefined unless category is a valid address supplied by the balm::MetricRegistry owned by metricsManager. Note that if a default publication schedule has been set (using setDefaultSchedule), then category will continue to be published as part of that scheduled default publication; to exclude a category from any publication, clients can disable the category using the MetricsManager object supplied at construction.

◆ cancelCategorySchedule() [2/2]

int balm::PublicationScheduler::cancelCategorySchedule ( const char *  category)
inline

Cancel the periodic publication of the specified null-terminated string category. Return 0 on success, and a non-zero value if the category is not scheduled for publication. Any scheduled publication of category is either canceled or completed before this method returns. Note that if a default publication schedule has been set (using setDefaultSchedule), then category will continue to be published as part of that scheduled default publication; to exclude a category from any publication, clients can disable the category using the MetricsManager object supplied at construction.

◆ clearDefaultSchedule()

int balm::PublicationScheduler::clearDefaultSchedule ( )

If the default publication schedule has been set (using setDefaultSchedule), cancel that periodic default publication, and return 0. This method has no effect and will return a non-zero value if a default publication schedule has not been set. Any scheduled publication is either canceled or completed before this method returns.

◆ findCategorySchedule() [1/2]

bool balm::PublicationScheduler::findCategorySchedule ( bsls::TimeInterval result,
const Category category 
) const

Load into the specified result the individual schedule interval (set using the scheduleCategory method) that corresponds to the specified category, if found, and return true, or (if not found) return false with no effect. This method will return false and will not modify result if category is published as part of the default scheduled publication. The behavior is undefined unless category is a valid address supplied by the balm::MetricRegistry owned by the MetricsManager object supplied at construction.

◆ findCategorySchedule() [2/2]

bool balm::PublicationScheduler::findCategorySchedule ( bsls::TimeInterval result,
const char *  category 
) const
inline

Load into the specified result the individual schedule interval (set using the scheduleCategory method) that corresponds to the specified null-terminated string category, if found, and return true, or (if not found) return false with no effect. This method will return false and will not modify result if category is published as part of the default scheduled publication.

◆ getCategorySchedule() [1/2]

int balm::PublicationScheduler::getCategorySchedule ( bsl::vector< bsl::pair< const Category *, bsls::TimeInterval > > *  result) const

◆ getCategorySchedule() [2/2]

int balm::PublicationScheduler::getCategorySchedule ( std::vector< std::pair< const Category *, bsls::TimeInterval > > *  result) const

◆ getDefaultSchedule()

bool balm::PublicationScheduler::getDefaultSchedule ( bsls::TimeInterval result) const

Load into the specified result the default scheduled interval, (set using the setDefaultSchedule method), for periodically publishing metrics, if found, and return true, or (if not found) return false with no effect.

◆ manager() [1/2]

MetricsManager * balm::PublicationScheduler::manager ( )
inline

Return the address of the modifiable metrics manager for which this publication scheduler publishes metrics.

◆ manager() [2/2]

const MetricsManager * balm::PublicationScheduler::manager ( ) const
inline

Return the address of the non-modifiable metrics manager for which this publication scheduler will publish metrics.

◆ print()

bsl::ostream & balm::PublicationScheduler::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Print a formatted string describing the current state of this PublicationScheduler object to the specified stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress all indentation AND format the entire output on one line. If stream is not valid on entry, this operation has no effect. Note that this is provided primarily for debugging purposes.

◆ scheduleCategory() [1/2]

void balm::PublicationScheduler::scheduleCategory ( const Category category,
const bsls::TimeInterval interval 
)

Schedule the specified category to be published periodically at the specified interval using the MetricManager supplied at construction. If category has already been scheduled, change the scheduled period to interval; any previously scheduled publication of category is either canceled or completed (atomically) prior to rescheduling. If a category is rescheduled with the same interval as it is currently scheduled, this operation has no effect. The behavior is undefined unless bsls::TimeInterval(0, 0) < interval and category is a valid address supplied by the balm::MetricRegistry owned by the MetricsManager object supplied at construction.

◆ scheduleCategory() [2/2]

void balm::PublicationScheduler::scheduleCategory ( const char *  category,
const bsls::TimeInterval interval 
)
inline

Schedule the specified null-terminated string category to be published periodically at the specified interval using the MetricManager supplied at construction. If category has already been scheduled, change the scheduled period to interval; any previously scheduled publication of category is either canceled or completed (atomically) prior to rescheduling. If a category is rescheduled with the same interval as it is currently scheduled, this operation has no effect. The behavior is undefined unless bsls::TimeInterval(0, 0) < interval.

◆ setDefaultSchedule()

void balm::PublicationScheduler::setDefaultSchedule ( const bsls::TimeInterval interval)

Set, to the specified interval, the default interval for metrics to be periodically published using the MetricsManager supplied at construction. This method schedules every metric category not given a individual schedule (using scheduleCategory), to be published periodically until that category is either given an individual schedule, or the default schedule is canceled (using either clearDefaultSchedule or cancelAllPublications). If a default publication has already been scheduled, change its schedule to interval; any previously scheduled publication is either canceled or completed (atomically) before rescheduling. If the default publication is rescheduled with the same interval as it is currently scheduled, this operation has no effect. The behavior is undefined unless bsls::TimeInterval(0, 0) < interval. Note that, to exclude a category from any publication, clients can disable the category using the MetricsManager object supplied at construction.

Friends And Related Symbol Documentation

◆ PublicationScheduler_Proctor

friend class PublicationScheduler_Proctor
friend

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