-
Notifications
You must be signed in to change notification settings - Fork 16
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
Generalised point-to-point messaging #151
Merged
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4c576a4
Skeleton for point to point messaging setup
Shillaker f609fcf
Merge branch 'master' into p2p-broker
Shillaker ec1db97
More groundwork for point to point
Shillaker 901667a
Tidy up
Shillaker 7b61ec6
formatting
Shillaker afbf588
Test for registry
Shillaker 12df273
Mocked test for sending mappings
Shillaker 236e83c
Mappings tests
Shillaker 61b063d
Fleshing out rest of implementation
Shillaker 61d1d11
Test for point to point messaging
Shillaker d5e572c
Rename and tidy
Shillaker a2d8a4f
Sleep to enforce asyncness
Shillaker bed0dac
Caching sockets
Shillaker 8ec98c4
Naming and general tidy
Shillaker 564bfc6
Formatting
Shillaker 0f0ee6c
Mock tests for broadcast mappings
Shillaker 01cbaed
Test for send back and forth
Shillaker 6a68e2f
Stop ptp server
Shillaker a74d6f7
Add failing dist test
Shillaker f3e86cc
Fix up point-to-point dist test
Shillaker fb5aaec
Formatting
Shillaker cf6dabe
Tidy-up
Shillaker 8697736
Review comments
Shillaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <faabric/scheduler/Scheduler.h> | ||
|
||
#include <set> | ||
#include <shared_mutex> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace faabric::transport { | ||
class PointToPointBroker | ||
{ | ||
public: | ||
PointToPointBroker(); | ||
|
||
std::string getHostForReceiver(int appId, int recvIdx); | ||
|
||
void setHostForReceiver(int appId, int recvIdx, const std::string& host); | ||
|
||
void broadcastMappings(int appId); | ||
|
||
void sendMappings(int appId, const std::string& host); | ||
|
||
std::set<int> getIdxsRegisteredForApp(int appId); | ||
|
||
void sendMessage(int appId, | ||
int sendIdx, | ||
int recvIdx, | ||
const uint8_t* buffer, | ||
size_t bufferSize); | ||
|
||
std::vector<uint8_t> recvMessage(int appId, int sendIdx, int recvIdx); | ||
|
||
void clear(); | ||
|
||
void resetThreadLocalCache(); | ||
|
||
private: | ||
std::shared_mutex brokerMutex; | ||
|
||
std::unordered_map<int, std::set<int>> appIdxs; | ||
std::unordered_map<std::string, std::string> mappings; | ||
|
||
faabric::scheduler::Scheduler& sch; | ||
}; | ||
|
||
PointToPointBroker& getPointToPointBroker(); | ||
} |
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,10 @@ | ||
#pragma once | ||
|
||
namespace faabric::transport { | ||
|
||
enum PointToPointCall | ||
{ | ||
MAPPING = 0, | ||
MESSAGE = 1 | ||
}; | ||
} |
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,25 @@ | ||
#pragma once | ||
|
||
#include <faabric/proto/faabric.pb.h> | ||
#include <faabric/transport/MessageEndpointClient.h> | ||
|
||
namespace faabric::transport { | ||
|
||
std::vector<std::pair<std::string, faabric::PointToPointMappings>> | ||
getSentMappings(); | ||
|
||
std::vector<std::pair<std::string, faabric::PointToPointMessage>> | ||
getSentPointToPointMessages(); | ||
|
||
void clearSentMessages(); | ||
|
||
class PointToPointClient : public faabric::transport::MessageEndpointClient | ||
{ | ||
public: | ||
PointToPointClient(const std::string& hostIn); | ||
|
||
void sendMappings(faabric::PointToPointMappings& mappings); | ||
|
||
void sendMessage(faabric::PointToPointMessage& msg); | ||
}; | ||
} |
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,31 @@ | ||
#pragma once | ||
|
||
#include <faabric/transport/MessageEndpointServer.h> | ||
#include <faabric/transport/PointToPointBroker.h> | ||
|
||
namespace faabric::transport { | ||
|
||
class PointToPointServer final : public MessageEndpointServer | ||
{ | ||
public: | ||
PointToPointServer(); | ||
|
||
private: | ||
PointToPointBroker& reg; | ||
|
||
void doAsyncRecv(int header, | ||
const uint8_t* buffer, | ||
size_t bufferSize) override; | ||
|
||
std::unique_ptr<google::protobuf::Message> | ||
doSyncRecv(int header, const uint8_t* buffer, size_t bufferSize) override; | ||
|
||
void onWorkerStop() override; | ||
|
||
void doSendMessage(const uint8_t* buffer, size_t bufferSize); | ||
|
||
std::unique_ptr<google::protobuf::Message> doRecvMappings( | ||
const uint8_t* buffer, | ||
size_t bufferSize); | ||
}; | ||
} |
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
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
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
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
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.
This hook allows servers to perform custom shutdown when workers stop.