@@ -590,24 +590,9 @@ Http::Code AdminImpl::handlerHystrixEventStream(const std::string&,
590590 Http::Headers::get ().AccessControlAllowOriginValue .All );
591591 response_headers.insertNoChunks ().value ().setReference (" 0" );
592592
593- HystrixHandlerInfoImpl& hystrix_handler_info = dynamic_cast <HystrixHandlerInfoImpl&>(handler_info);
594-
595- // start streaming
596- hystrix_handler_info.data_timer_ = hystrix_handler_info.callbacks_ ->dispatcher ().createTimer (
597- [this , &hystrix_handler_info]() -> void {
598- HystrixHandler::prepareAndSendHystrixStream (&hystrix_handler_info, server_);
599- });
600- hystrix_handler_info.data_timer_ ->enableTimer (
601- std::chrono::milliseconds (Stats::Hystrix::GetRollingWindowIntervalInMs ()));
602-
603- // start keep alive ping
604- hystrix_handler_info.ping_timer_ =
605- hystrix_handler_info.callbacks_ ->dispatcher ().createTimer ([&hystrix_handler_info]() -> void {
606- HystrixHandler::sendKeepAlivePing (&hystrix_handler_info);
607- });
608-
609- hystrix_handler_info.ping_timer_ ->enableTimer (
610- std::chrono::milliseconds (Stats::Hystrix::GetPingIntervalInMs ()));
593+ Stats::HystrixHandlerInfoImpl& hystrix_handler_info =
594+ dynamic_cast <Stats::HystrixHandlerInfoImpl&>(handler_info);
595+ Stats::HystrixHandler::HandleEventStream (&hystrix_handler_info, server_);
611596
612597 ENVOY_LOG (debug, " start sending data to hystrix dashboard on port {}" ,
613598 hystrix_handler_info.callbacks_ ->connection ()->localAddress ()->asString ());
@@ -627,7 +612,7 @@ void AdminFilter::onComplete() {
627612 handler_info_ = std::make_unique<HandlerInfoImpl>();
628613 code = parent_.runCallback (path, *header_map, response, *handler_info_);
629614 } else {
630- handler_info_ = std::make_unique<HystrixHandlerInfoImpl>(callbacks_);
615+ handler_info_ = std::make_unique<Stats:: HystrixHandlerInfoImpl>(callbacks_);
631616 code = parent_.runCallback (path, *header_map, response, *handler_info_);
632617 end_stream = false ;
633618 }
@@ -846,60 +831,5 @@ bool AdminImpl::removeHandler(const std::string& prefix) {
846831 return false ;
847832}
848833
849- void HystrixHandlerInfoImpl::Destroy () {
850- if (data_timer_) {
851- data_timer_->disableTimer ();
852- data_timer_.reset ();
853- }
854- if (ping_timer_) {
855- ping_timer_->disableTimer ();
856- ping_timer_.reset ();
857- }
858- }
859-
860- void HystrixHandler::updateHystrixRollingWindow (HystrixHandlerInfoImpl* hystrix_handler_info,
861- Server::Instance& server) {
862- hystrix_handler_info->stats_ ->incCounter ();
863- for (auto & cluster : server.clusterManager ().clusters ()) {
864- hystrix_handler_info->stats_ ->updateRollingWindowMap (server.stats (),
865- cluster.second .get ().info ()->name ());
866- }
867- }
868-
869- void HystrixHandler::prepareAndSendHystrixStream (HystrixHandlerInfoImpl* hystrix_handler_info,
870- Server::Instance& server) {
871- updateHystrixRollingWindow (hystrix_handler_info, server);
872- std::stringstream ss;
873- for (auto & cluster : server.clusterManager ().clusters ()) {
874- hystrix_handler_info->stats_ ->getClusterStats (
875- ss, cluster.second .get ().info ()->name (),
876- cluster.second .get ()
877- .info ()
878- ->resourceManager (Upstream::ResourcePriority::Default)
879- .pendingRequests ()
880- .max (),
881- server.stats ()
882- .gauge (" cluster." + cluster.second .get ().info ()->name () + " .membership_total" )
883- .value ());
884- }
885- Buffer::OwnedImpl data;
886- data.add (ss.str ());
887- hystrix_handler_info->callbacks_ ->encodeData (data, false );
888-
889- // restart timer
890- hystrix_handler_info->data_timer_ ->enableTimer (
891- std::chrono::milliseconds (Stats::Hystrix::GetRollingWindowIntervalInMs ()));
892- }
893-
894- void HystrixHandler::sendKeepAlivePing (HystrixHandlerInfoImpl* hystrix_handler_info) {
895- Buffer::OwnedImpl data;
896- data.add (" :\n\n " );
897- hystrix_handler_info->callbacks_ ->encodeData (data, false );
898-
899- // restart timer
900- hystrix_handler_info->ping_timer_ ->enableTimer (
901- std::chrono::milliseconds (Stats::Hystrix::GetPingIntervalInMs ()));
902- }
903-
904834} // namespace Server
905835} // namespace Envoy
0 commit comments