-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
IGNITE-16755 C++ Thin: Add user threadpool size to public configuration #9960
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
43fc70e
IGNITE-16755 Add test
isapego 8e5a87a
IGNITE-16755 Add GetThreadsCount for Windows
isapego bf54f74
IGNITE-16755 Add methods to IgniteClientConfiguration
isapego a65cfcd
IGNITE-16755 Implemented. Fixed test
isapego b4af724
IGNITE-16755 Linux test. Untested
isapego 302e5eb
IGNITE-16755 Fix for Linux
isapego File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -743,6 +743,13 @@ namespace ignite | |||||
* @return Number of logical processors. | ||||||
*/ | ||||||
IGNITE_IMPORT_EXPORT uint32_t GetNumberOfProcessors(); | ||||||
|
||||||
/** | ||||||
* Get current processor thread count. | ||||||
* | ||||||
* @return Current processor thread count. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
IGNITE_IMPORT_EXPORT int32_t GetThreadsCount(); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,6 +24,7 @@ | |||||
#include <map> | ||||||
|
||||||
#include <windows.h> | ||||||
#include <tlhelp32.h> | ||||||
|
||||||
#include "ignite/common/common.h" | ||||||
namespace ignite | ||||||
|
@@ -652,6 +653,13 @@ namespace ignite | |||||
* @return Number of logical processors. | ||||||
*/ | ||||||
IGNITE_IMPORT_EXPORT uint32_t GetNumberOfProcessors(); | ||||||
|
||||||
/** | ||||||
* Get current processor thread count. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @return Current processor thread count. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
IGNITE_IMPORT_EXPORT int32_t GetThreadsCount(); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 213 additions & 0 deletions
213
modules/platforms/cpp/thin-client-test/include/test_server.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef _IGNITE_THIN_CLIENT_TEST_TEST_SERVER | ||
#define _IGNITE_THIN_CLIENT_TEST_TEST_SERVER | ||
|
||
#include <stdint.h> | ||
|
||
#include <vector> | ||
|
||
#ifndef _WIN32_WINNT | ||
#define _WIN32_WINNT 0x0601 | ||
#endif // _WIN32_WINNT | ||
|
||
#include <ignite/impl/binary/binary_common.h> | ||
|
||
#include <boost/asio.hpp> | ||
#include <boost/thread.hpp> | ||
|
||
namespace ignite | ||
{ | ||
|
||
/** | ||
* Test Server Session. | ||
*/ | ||
class TestServerSession | ||
{ | ||
public: | ||
/** | ||
* Construct new instance of class. | ||
* @param service Asio service. | ||
* @param responses Responses to provide to requests. | ||
*/ | ||
TestServerSession(boost::asio::io_service& service, const std::vector< std::vector<int8_t> >& responses); | ||
|
||
/** | ||
* Get socket. | ||
*/ | ||
boost::asio::ip::tcp::socket& GetSocket() | ||
{ | ||
return socket; | ||
} | ||
|
||
/** | ||
* Start session. | ||
*/ | ||
void Start(); | ||
|
||
/** | ||
* Get response at index. | ||
* @param idx Index. | ||
* @return Response. | ||
*/ | ||
const std::vector<int8_t>& GetResponse(size_t idx) const | ||
{ | ||
return responses.at(idx); | ||
} | ||
|
||
private: | ||
/** | ||
* Receive next request. | ||
*/ | ||
void ReadNextRequest(); | ||
|
||
/** | ||
* Handle received request size. | ||
* @param error Error. | ||
* @param bytesTransferred Bytes transferred. | ||
*/ | ||
void HandleRequestSizeReceived(const boost::system::error_code& error, size_t bytesTransferred); | ||
|
||
/** | ||
* Handle received request. | ||
* @param error Error. | ||
* @param bytesTransferred Bytes transferred. | ||
*/ | ||
void HandleRequestReceived(const boost::system::error_code& error, size_t bytesTransferred); | ||
|
||
/** | ||
* Handle received request. | ||
* @param error Error. | ||
* @param bytesTransferred Bytes transferred. | ||
*/ | ||
void HandleResponseSent(const boost::system::error_code& error, size_t bytesTransferred); | ||
|
||
// The socket used to communicate with the client. | ||
boost::asio::ip::tcp::socket socket; | ||
|
||
// Received requests. | ||
std::vector< std::vector<int8_t> > requests; | ||
|
||
// Responses to provide. | ||
const std::vector< std::vector<int8_t> > responses; | ||
|
||
// Number of requests answered. | ||
size_t requestsResponded; | ||
}; | ||
|
||
/** | ||
* Test Server. | ||
*/ | ||
class TestServer | ||
{ | ||
public: | ||
/** | ||
* Constructor. | ||
* @param port TCP port to listen. | ||
*/ | ||
TestServer(uint16_t port = 11110); | ||
|
||
/** | ||
* Destructor. | ||
*/ | ||
~TestServer(); | ||
|
||
/** | ||
* Push new handshake response to send. | ||
* @param accept Accept or reject response. | ||
*/ | ||
void PushHandshakeResponse(bool accept) | ||
{ | ||
std::vector<int8_t> rsp(4 + 1 + 4 + 1 + 4 + 17); | ||
// Size | ||
rsp[0] = 1 + 4 + 1 + 4 + 17; | ||
|
||
// Accept flag | ||
rsp[4] = accept ? 1 : 0; | ||
|
||
// Bitmask (array header) | ||
rsp[5] = impl::binary::IGNITE_TYPE_ARRAY_BYTE; | ||
|
||
// Guid (just random data so it won't be all zeroes) | ||
rsp[10] = impl::binary::IGNITE_TYPE_UUID; | ||
rsp[12] = 123; | ||
|
||
PushResponse(rsp); | ||
} | ||
|
||
/** | ||
* Push new response to send. | ||
* @param resp Response to push. | ||
*/ | ||
void PushResponse(const std::vector<int8_t>& resp) | ||
{ | ||
responses.push_back(resp); | ||
} | ||
|
||
/** | ||
* Get specified session. | ||
* @param idx Index. | ||
* @return Specified session. | ||
*/ | ||
TestServerSession& GetSession(size_t idx = 0) | ||
{ | ||
return *sessions.at(idx); | ||
} | ||
|
||
/** | ||
* Start server. | ||
*/ | ||
void Start(); | ||
|
||
/** | ||
* Stop server. | ||
*/ | ||
void Stop(); | ||
|
||
private: | ||
/** | ||
* Start accepting connections. | ||
*/ | ||
void StartAccept(); | ||
|
||
/** | ||
* Handle accepted connection. | ||
* @param session Accepted session. | ||
* @param error Error. | ||
*/ | ||
void HandleAccept(boost::shared_ptr<TestServerSession> session, const boost::system::error_code& error); | ||
|
||
// Service. | ||
boost::asio::io_service service; | ||
|
||
// Acceptor. | ||
boost::asio::ip::tcp::acceptor acceptor; | ||
|
||
// Responses. | ||
std::vector< std::vector<int8_t> > responses; | ||
|
||
// Sessions. | ||
std::vector< boost::shared_ptr<TestServerSession> > sessions; | ||
|
||
// Server Thread. | ||
boost::shared_ptr<boost::thread> serverThread; | ||
}; | ||
|
||
} // namespace ignite | ||
|
||
#endif //_IGNITE_THIN_CLIENT_TEST_TEST_SERVER |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.