Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architectural changes to use boost thread_pool, boost::future, std::promise, std::nested_exception, connection local invocation and event handler maps #584

Merged
merged 18 commits into from
Apr 20, 2020

Conversation

ihsandemir
Copy link
Collaborator

Changed the event processing executor usage to use asio::thread_pool.

Changed the ResponseThread to ResponseProcessor and it now processes the response message directly by default and will use a thread_pool if the newly introduced parameter hazelcast.client.response.executor.thread.count is set to a positive value.

Removed custom Thread, Future implementations and used std::thread, boost::asio::thread_pool and boost::future/boost::promise.

boost::future supports continuation (.then support).

Changed the invocation and event handler map design. Using an unordered_map which which only being accessed from the same io thread for the connection. This eliminated the need for using sync maps for invocations and events. If any other thread needs to access the invocations, it passes this request to io thread. This is only needed when closing the socket for notifying the outstanding invocations. If an invocation can not be queued into the connection (i.e. no connection exists for the invocation and it is being retried), then it is registered in a sync map at the invocation service only for the first retry and cleared from the service when a response is finally received. This ensures that the user thread is always being notified.

Exception architecture is compeletely changed so that we use std exception_ptr capabilities. Also integrated std::nested exceptions for exceptions which has a cause exception. The cause is obtained by using std::rethrow_if_nested method.

The project now depends on boost::thread for boost::future. Changed cmake so that the boost installation is user's responsibility. Also using the boost Thread library version latest which is version 5.

Changed the ResponseThread to ResponseProcessor and it now processes the response message directly by default and will use a thread_pool if the newly introduced parameter `hazelcast.client.response.executor.thread.count` is set to a positive value.

Removed custom Thread, Future implementations and used std::thread, boost::asio::thread_pool and boost::future/boost::promise.

boost::future supports continuation (`.then` support).

Changed the invocation and event handler map design. Using an `unordered_map` which which only being accessed from the same `io` thread for the connection. This eliminated the need for using sync maps for invocations and events. If any other thread needs to access the invocations, it passes this request to io thread. This is only needed when closing the socket for notifying the outstanding invocations. If an invocation can not be queued into the connection (i.e. no connection exists for the invocation and it is being retried), then it is registered in a sync map at the invocation service only for the first retry and cleared from the service when a response is finally received. This ensures that the user thread is always being notified.

Exception architecture is compeletely changed so that we use std exception_ptr capabilities. Also integrated std::nested exceptions for exceptions which has a cause exception. The cause is obtained by using `std::rethrow_if_nested` method.

The project now depends on boost::thread for boost::future. Changed cmake so that the boost installation is user's responsibility. Also using the boost Thread library version latest which is version 5.
@ihsandemir ihsandemir added this to the 4.0 milestone Apr 13, 2020
@ihsandemir ihsandemir requested a review from sancar April 13, 2020 07:53
@ihsandemir ihsandemir self-assigned this Apr 13, 2020
@devOpsHazelcast
Copy link
Contributor

devOpsHazelcast commented Apr 13, 2020

CLA assistant check
All committers have signed the CLA.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@@ -190,7 +190,7 @@ namespace hazelcast {
* @return an {@link ICompletableFuture} with the current value
* @since cluster version 3.7
*/
std::shared_ptr<ICompletableFuture<int64_t> > getAsync();
future<std::shared_ptr<int64_t>> getAsync();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not these be future<int64_t> ? Do we need shared ptr's for primitives ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, we don't but I wıll change it when I change SerializationService to not use shared_ptr, this pointer is due to current serializationservice toObject method.

@@ -1034,7 +1033,7 @@ namespace hazelcast {
* @see ICompletableFuture
* @see #setAsync(Object, Object)
*/
std::shared_ptr<ICompletableFuture<V> > putAsync(const K &key, const V &value) {
future<std::shared_ptr<V>> putAsync(const K &key, const V &value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to use shared_future here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I try not to use shared_future where future is enough. the user can convert it to shared_future using future::share() method anyway.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

…ConditionVariable`. Replaced them with standard and boost based implementations.

Changed required boost version to 1.72.
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

Removed unneded include for windows (`WinSock2.h`) which causes error in compilation.
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

… invocation service.

Changed the CallIdSequence to use std::array of atomic integers.
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

… for compiling successfully at Windows (fails due to `ambiguous symbol` error which can be both from std or boost namespaces).
@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

1 similar comment
@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

Corrected the time string print utility.

Replaced some of the time usages with std::chrono related ones.

Made the timer cancel operations non-exception throwing.

Replaced the system_clock usages with steady_clock usages.

Warning fixes for windows for unused exceptions.
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@ihsandemir ihsandemir requested a review from sancar April 17, 2020 12:33
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

Some fixes so that the exceptions do not abort the io threads. Also, destroying the timer and pools upon shutdown so that no associated resource is left (which may happen for windows).
@devOpsHazelcast
Copy link
Contributor

Windows test PASSed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants