diff --git a/src/analytics/OpServerProxy.cc b/src/analytics/OpServerProxy.cc index 93ce8536cc0..ae4a8ae8922 100644 --- a/src/analytics/OpServerProxy.cc +++ b/src/analytics/OpServerProxy.cc @@ -341,6 +341,7 @@ class OpServerProxy::OpServerImpl { tbb::mutex::scoped_lock lock(rac_mutex_); redis_uve_.RedisStatusUpdate(RAC_DOWN); } + started_ = false; collector_->RedisUpdate(false); redis_up_ = false; @@ -630,6 +631,8 @@ class OpServerProxy::OpServerImpl { } RedisInfo redis_uve_; + bool IsInitDone() { return started_;} + private: /* these are made public, so they are accessed by OpServerProxy */ EventManager *evm_; @@ -867,3 +870,13 @@ RedisUVERequest::HandleRequest() const { resp->Response(); } +/* + * After redis collector connection is UP, + * we do initialization as part of a callback. + * We set the started_ flag during that step. + */ +bool +OpServerProxy::IsRedisInitDone() { + return impl_->IsInitDone(); +} + diff --git a/src/analytics/OpServerProxy.h b/src/analytics/OpServerProxy.h index cb7d825dbc2..46443f534cf 100644 --- a/src/analytics/OpServerProxy.h +++ b/src/analytics/OpServerProxy.h @@ -67,6 +67,7 @@ class OpServerProxy { const std::string &instance_id); void FillRedisUVEInfo(RedisUveInfo& redis_uve_info); + virtual bool IsRedisInitDone(); private: class OpServerImpl; OpServerImpl *impl_; diff --git a/src/analytics/collector.cc b/src/analytics/collector.cc index 6703821b347..331ec8b38be 100644 --- a/src/analytics/collector.cc +++ b/src/analytics/collector.cc @@ -231,7 +231,10 @@ bool Collector::ReceiveSandeshCtrlMsg(SandeshStateMachine *state_machine, snh->get_source() << ":" << snh->get_module_name()); return false; } - + if (!osp_->IsRedisInitDone()) { + LOG(ERROR, "Collector connection to redis is not establised and flush done"); + return false; + } SandeshGenerator::GeneratorId id(boost::make_tuple(snh->get_source(), snh->get_module_name(), snh->get_instance_id_name(), snh->get_node_type_name()));