Skip to content

Commit

Permalink
Rename methods
Browse files Browse the repository at this point in the history
As they are related to queue dispatcher, we rename
some methods in order to clarify.
  • Loading branch information
testillano authored and Eduardo Ramos Testillano (eramedu) committed Jul 23, 2023
1 parent c2de613 commit 4b550d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
15 changes: 10 additions & 5 deletions include/ert/http2comm/Http2Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Http2Server
std::string api_version_{};
boost::asio::io_service *timers_io_service_;
ert::queuedispatcher::QueueDispatcher *queue_dispatcher_;
int max_queue_dispatcher_size_{};
int queue_dispatcher_max_size_{};

nghttp2::asio_http2::server::request_cb handler();

Expand Down Expand Up @@ -115,11 +115,11 @@ class Http2Server
* @param workerThreads number of worker threads.
* @param maxWorkerThreads number of maximum worker threads which internal processing could grow to. Defaults to '0' which means that maximum equals to provided worker threads.
* @param timerIoService Optional io service to manage response delays
* @param maxQueueDispatcherSize This library implements a simple congestion control algorithm which will indicate congestion status when queue dispatcher (when used) has no
* @param queueDispatcherMaxSize This library implements a simple congestion control algorithm which will indicate congestion status when queue dispatcher (when used) has no
* idle consumer threads, and queue dispatcher size is over this value. Defaults to -1 which means 'no limit' to grow the queue (this probably implies response time degradation).
* So, to enable the described congestion control algorithm, provide a non-negative value.
*/
Http2Server(const std::string& name, size_t workerThreads, size_t maxWorkerThreads = 0, boost::asio::io_service *timerIoService = nullptr, int maxQueueDispatcherSize = -1 /* no limit */);
Http2Server(const std::string& name, size_t workerThreads, size_t maxWorkerThreads = 0, boost::asio::io_service *timerIoService = nullptr, int queueDispatcherMaxSize = -1 /* no limit */);
virtual ~Http2Server();

// setters
Expand All @@ -128,7 +128,12 @@ class Http2Server
/**
* Gets the queue dispatcher busy threads
*/
int busyThreads() const;
int getQueueDispatcherBusyThreads() const;

/**
* Gets the queue dispatcher number of scheduled threads
*/
int getQueueDispacherThreads() const;

/**
* Gets the queue dispatcher size
Expand All @@ -143,7 +148,7 @@ class Http2Server
* queue dispatcher has no idle consumer threads and also, queue size is over this specific
* value.
*/
int getMaxQueueDispacherSize() const;
int getQueueDispacherMaxSize() const;

/**
* Enable metrics
Expand Down
14 changes: 9 additions & 5 deletions src/Http2Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,26 @@ namespace ert
namespace http2comm
{

Http2Server::Http2Server(const std::string& name, size_t workerThreads, size_t maxWorkerThreads, boost::asio::io_service *timersIoService, int maxQueueDispatcherSize):
name_(name), timers_io_service_(timersIoService), reception_id_(0), maximum_request_body_size_(0), max_queue_dispatcher_size_(maxQueueDispatcherSize) {
Http2Server::Http2Server(const std::string& name, size_t workerThreads, size_t maxWorkerThreads, boost::asio::io_service *timersIoService, int queueDispatcherMaxSize):
name_(name), timers_io_service_(timersIoService), reception_id_(0), maximum_request_body_size_(0), queue_dispatcher_max_size_(queueDispatcherMaxSize) {

queue_dispatcher_ = (workerThreads > 1) ? new ert::queuedispatcher::QueueDispatcher(name + "_queueDispatcher", workerThreads, maxWorkerThreads) : nullptr;
}

int Http2Server::busyThreads() const {
int Http2Server::getQueueDispatcherBusyThreads() const {
return (queue_dispatcher_ ? queue_dispatcher_->getBusyThreads():0);
}

int Http2Server::getQueueDispacherThreads() const {
return (queue_dispatcher_ ? queue_dispatcher_->getSize():0);
}

int Http2Server::getQueueDispacherSize() const {
return (queue_dispatcher_ ? queue_dispatcher_->getSize():0);
}

int Http2Server::getMaxQueueDispacherSize() const {
return max_queue_dispatcher_size_;
int Http2Server::getQueueDispacherMaxSize() const {
return queue_dispatcher_max_size_;
}

void Http2Server::enableMetrics(ert::metrics::Metrics *metrics,
Expand Down
2 changes: 1 addition & 1 deletion src/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Stream::appendData(const uint8_t* data, std::size_t len) {
}

void Stream::process(bool busyConsumers, int queueSize) {
reception(server_->getMaxQueueDispacherSize() >= 0 /* congestion control enabled */ && busyConsumers && queueSize > server_->getMaxQueueDispacherSize());
reception(server_->getQueueDispacherMaxSize() >= 0 /* congestion control enabled */ && busyConsumers && queueSize > server_->getQueueDispacherMaxSize());
commit();
}

Expand Down

0 comments on commit 4b550d8

Please sign in to comment.