Skip to content

Commit

Permalink
Merge "Option to disable flow collection in contrail-collector" into …
Browse files Browse the repository at this point in the history
…R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 5, 2016
2 parents 51153c1 + be94bbe commit c0ba0ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/cpp/sandesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int Sandesh::http_port_ = 0;
bool Sandesh::enable_trace_print_ = false;
bool Sandesh::send_queue_enabled_ = true;
bool Sandesh::connect_to_collector_ = false;
bool Sandesh::disable_flow_collection_ = false;
SandeshLevel::type Sandesh::sending_level_ = SandeshLevel::INVALID;
SandeshClient *Sandesh::client_ = NULL;
std::auto_ptr<Sandesh::SandeshRxQueue> Sandesh::recv_queue_;
Expand Down Expand Up @@ -452,6 +453,14 @@ void Sandesh::SetFlowLogging(bool enable_flow_log) {
}
}

void Sandesh::DisableFlowCollection(bool disable) {
if (disable_flow_collection_ != disable) {
SANDESH_LOG(INFO, "SANDESH: Disable Flow Collection: " <<
disable_flow_collection_ << " -> " << disable);
disable_flow_collection_ = disable;
}
}

bool Sandesh::Enqueue(SandeshQueue *queue) {
if (!queue) {
if (IsLoggingDroppedAllowed()) {
Expand Down Expand Up @@ -875,6 +884,10 @@ bool DoDropSandeshMessage(const SandeshHeader &header,
return true;
}
}
// Drop flow message if flow collection is disabled
if (Sandesh::IsFlowCollectionDisabled() && stype == SandeshType::FLOW) {
return true;
}
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions library/cpp/sandesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ class Sandesh {
int collector_port);
static void Uninit();

// Disable flow collection
static void DisableFlowCollection(bool disable);
static bool IsFlowCollectionDisabled() { return disable_flow_collection_; }

// Logging and category APIs
static void SetLoggingParams(bool enable_local_log, std::string category,
std::string level, bool enable_trace_print = false,
Expand Down Expand Up @@ -372,6 +376,7 @@ class Sandesh {
static SandeshStatistics stats_;
static tbb::mutex stats_mutex_;
static log4cplus::Logger logger_;
static bool disable_flow_collection_; // disable flow collection

const uint32_t seqnum_;
std::string context_;
Expand Down

0 comments on commit c0ba0ed

Please sign in to comment.