Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

On demand OS connection manager #1645

Merged
merged 4 commits into from
Aug 20, 2018
Merged

Conversation

lebdron
Copy link
Contributor

@lebdron lebdron commented Aug 13, 2018

Description of the Change

Implementation of connection manager component for on demand OS. Manager receives new peers and forwards the requests. Methods are thread safe.
It uses connection factory each time new peers are received, so that required peers are used with each update.
Shared lock is used to allow concurrent method calls and updates of peers.

previous_consumer_ = factory_->create(*peers.previous_consumer);
})) {}

// OdOsNotification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment exists in both header and cpp, maybe you should expand it a bit, because I don't understand, what it's supposed to mean

RoundType round;
boost::optional<OnDemandConnectionManager::ProposalType> oproposal =
OnDemandConnectionManager::ProposalType{};
auto proposal = oproposal.value().get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be better to firstly check optional for ASSERT_TRUE(..)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it is not created from component being tested, but explicitly in two lines above by initializing optional with unique pointer.

// shared lock
std::shared_lock<std::shared_timed_mutex> lock(mutex_);

current_consumer_->onTransactions(transactions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is a guarantee that pointer is not a null? Maybe initiate connections with some stub in ctor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or wrap pointers with the optionals, or apply bind to a pointer.

class OnDemandConnectionManager : public transport::OdOsNotification {
public:
struct CurrentPeers {
std::shared_ptr<shared_model::interface::Peer> issuer, current_consumer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add descriptions to the peers.

std::shared_ptr<transport::OdOsNotificationFactory> factory_;
rxcpp::composite_subscription subscription_;

std::unique_ptr<transport::OdOsNotification> issuer_, current_consumer_,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create a structure similar to CurrentPeers with current connections.
It will lead to the following benefits: * increase testability of the code and explicit initialization in ctor, which will prevent the previous problem with pointers.

@lebdron lebdron changed the base branch from feature/bft-os-transport to trunk/bft-os August 18, 2018 15:49
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
@lebdron lebdron merged commit 273aed0 into trunk/bft-os Aug 20, 2018
@lebdron lebdron deleted the feature/bft-os-conn-mgr branch August 20, 2018 15:34
lebdron added a commit that referenced this pull request Sep 4, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
nickaleks pushed a commit that referenced this pull request Sep 10, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
bakhtin pushed a commit that referenced this pull request Nov 2, 2018
* BFT OS trunk

* On demand OS transport (#1635)

* On demand OS connection manager (#1645)

* On-demand ordering gate and related fixes (#1675)

Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants