Start/stop schedulers within nano::scheduler::component.
This commit is contained in:
parent
afa344efb1
commit
d5abebb83e
8 changed files with 65 additions and 29 deletions
|
@ -576,7 +576,7 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (no
|
|||
composite->add_component (collect_container_info (node.confirmation_height_processor, "confirmation_height_processor"));
|
||||
composite->add_component (collect_container_info (node.distributed_work, "distributed_work"));
|
||||
composite->add_component (collect_container_info (node.aggregator, "request_aggregator"));
|
||||
composite->add_component (node.scheduler.priority.collect_container_info ("priority_scheduler"));
|
||||
composite->add_component (node.scheduler.collect_container_info ("scheduler"));
|
||||
composite->add_component (node.inactive_vote_cache.collect_container_info ("inactive_vote_cache"));
|
||||
composite->add_component (collect_container_info (node.generator, "vote_generator"));
|
||||
composite->add_component (collect_container_info (node.final_generator, "vote_generator_final"));
|
||||
|
@ -688,10 +688,8 @@ void nano::node::start ()
|
|||
active.start ();
|
||||
generator.start ();
|
||||
final_generator.start ();
|
||||
scheduler.optimistic.start ();
|
||||
scheduler.priority.start ();
|
||||
scheduler.start ();
|
||||
backlog.start ();
|
||||
scheduler.hinted.start ();
|
||||
bootstrap_server.start ();
|
||||
if (!flags.disable_ascending_bootstrap)
|
||||
{
|
||||
|
@ -723,9 +721,7 @@ void nano::node::stop ()
|
|||
block_processor.stop ();
|
||||
aggregator.stop ();
|
||||
vote_processor.stop ();
|
||||
scheduler.priority.stop ();
|
||||
scheduler.optimistic.stop ();
|
||||
scheduler.hinted.stop ();
|
||||
scheduler.stop ();
|
||||
active.stop ();
|
||||
generator.stop ();
|
||||
final_generator.stop ();
|
||||
|
|
|
@ -5,11 +5,40 @@
|
|||
#include <nano/node/scheduler/priority.hpp>
|
||||
|
||||
nano::scheduler::component::component (nano::node & node) :
|
||||
hinted_impl{ std::make_unique<nano::scheduler::hinted> (nano::scheduler::hinted::config{ node.config }, node, node.inactive_vote_cache, node.active, node.online_reps, node.stats) },
|
||||
optimistic_impl{ std::make_unique<nano::scheduler::optimistic> (node.config.optimistic_scheduler, node, node.ledger, node.active, node.network_params.network, node.stats) },
|
||||
priority_impl{ std::make_unique<nano::scheduler::priority> (node, node.stats) },
|
||||
hinted_impl{ std::make_unique<nano::scheduler::hinted> (nano::scheduler::hinted::config{ node.config }, node, node.inactive_vote_cache, node.active, node.online_reps, node.stats) },
|
||||
priority{ *priority_impl },
|
||||
hinted{ *hinted_impl },
|
||||
optimistic{ *optimistic_impl }
|
||||
optimistic{ *optimistic_impl },
|
||||
priority{ *priority_impl }
|
||||
{
|
||||
}
|
||||
|
||||
nano::scheduler::component::~component ()
|
||||
{
|
||||
}
|
||||
|
||||
void nano::scheduler::component::start ()
|
||||
{
|
||||
hinted.start ();
|
||||
optimistic.start ();
|
||||
priority.start ();
|
||||
}
|
||||
|
||||
void nano::scheduler::component::stop ()
|
||||
{
|
||||
hinted.stop ();
|
||||
optimistic.stop ();
|
||||
priority.stop ();
|
||||
}
|
||||
|
||||
std::unique_ptr<nano::container_info_component> nano::scheduler::component::collect_container_info (std::string const & name)
|
||||
{
|
||||
nano::unique_lock<nano::mutex> lock{ mutex };
|
||||
|
||||
auto composite = std::make_unique<container_info_composite> (name);
|
||||
//composite->add_component (hinted.collect_container_info ("hinted"));
|
||||
//composite->add_component (optimistic.collect_container_info ("optimistic"));
|
||||
composite->add_component (priority.collect_container_info ("priority"));
|
||||
return composite;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/locks.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
class container_info_component;
|
||||
class node;
|
||||
}
|
||||
namespace nano::scheduler
|
||||
|
@ -14,15 +18,24 @@ class priority;
|
|||
|
||||
class component
|
||||
{
|
||||
std::unique_ptr<nano::scheduler::hinted> hinted_impl;
|
||||
std::unique_ptr<nano::scheduler::optimistic> optimistic_impl;
|
||||
std::unique_ptr<nano::scheduler::priority> priority_impl;
|
||||
std::unique_ptr<nano::scheduler::hinted> hinted_impl;
|
||||
nano::mutex mutex;
|
||||
|
||||
public:
|
||||
explicit component (nano::node & node);
|
||||
~component ();
|
||||
|
||||
// Starts all schedulers
|
||||
void start ();
|
||||
// Stops all schedulers
|
||||
void stop ();
|
||||
|
||||
std::unique_ptr<container_info_component> collect_container_info (std::string const & name);
|
||||
|
||||
nano::scheduler::priority & priority;
|
||||
nano::scheduler::hinted & hinted;
|
||||
nano::scheduler::optimistic & optimistic;
|
||||
nano::scheduler::priority & priority;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ namespace nano::scheduler
|
|||
*/
|
||||
class hinted final
|
||||
{
|
||||
friend class component;
|
||||
void start ();
|
||||
void stop ();
|
||||
|
||||
public: // Config
|
||||
struct config final
|
||||
{
|
||||
|
@ -34,9 +38,6 @@ public:
|
|||
hinted (config const &, nano::node &, nano::vote_cache &, nano::active_transactions &, nano::online_reps &, nano::stats &);
|
||||
~hinted ();
|
||||
|
||||
void start ();
|
||||
void stop ();
|
||||
|
||||
/*
|
||||
* Notify about changes in AEC vacancy
|
||||
*/
|
||||
|
|
|
@ -46,15 +46,15 @@ public:
|
|||
};
|
||||
class optimistic final
|
||||
{
|
||||
friend class component;
|
||||
void start ();
|
||||
void stop ();
|
||||
struct entry;
|
||||
|
||||
public:
|
||||
optimistic (optimistic_config const &, nano::node &, nano::ledger &, nano::active_transactions &, nano::network_constants const & network_constants, nano::stats &);
|
||||
~optimistic ();
|
||||
|
||||
void start ();
|
||||
void stop ();
|
||||
|
||||
/**
|
||||
* Called from backlog population to process accounts with unconfirmed blocks
|
||||
*/
|
||||
|
|
|
@ -93,11 +93,6 @@ bool nano::scheduler::priority::empty () const
|
|||
return empty_locked ();
|
||||
}
|
||||
|
||||
std::size_t nano::scheduler::priority::priority_queue_size () const
|
||||
{
|
||||
return buckets->size ();
|
||||
}
|
||||
|
||||
bool nano::scheduler::priority::priority_queue_predicate () const
|
||||
{
|
||||
return node.active.vacancy () > 0 && !buckets->empty ();
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
class block;
|
||||
class container_info_component;
|
||||
class node;
|
||||
}
|
||||
|
||||
|
@ -21,13 +23,15 @@ namespace nano::scheduler
|
|||
class buckets;
|
||||
class priority final
|
||||
{
|
||||
friend class component;
|
||||
void start ();
|
||||
void stop ();
|
||||
std::unique_ptr<container_info_component> collect_container_info (std::string const & name);
|
||||
|
||||
public:
|
||||
priority (nano::node &, nano::stats &);
|
||||
~priority ();
|
||||
|
||||
void start ();
|
||||
void stop ();
|
||||
|
||||
// Manualy start an election for a block
|
||||
// Call action with confirmed block, may be different than what we started with
|
||||
void manual (std::shared_ptr<nano::block> const &, boost::optional<nano::uint128_t> const & = boost::none, nano::election_behavior = nano::election_behavior::normal);
|
||||
|
@ -39,8 +43,6 @@ public:
|
|||
void notify ();
|
||||
std::size_t size () const;
|
||||
bool empty () const;
|
||||
std::size_t priority_queue_size () const;
|
||||
std::unique_ptr<container_info_component> collect_container_info (std::string const &);
|
||||
|
||||
private: // Dependencies
|
||||
nano::node & node;
|
||||
|
|
|
@ -6968,5 +6968,5 @@ TEST (node, election_scheduler_container_info)
|
|||
request.put ("action", "stats");
|
||||
request.put ("type", "objects");
|
||||
auto response = wait_response (system, rpc_ctx, request);
|
||||
auto es = response.get_child ("node").get_child ("priority_scheduler");
|
||||
auto es = response.get_child ("node").get_child ("scheduler");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue