forked from faasm/faabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalised point-to-point messaging (faasm#151)
* Skeleton for point to point messaging setup * More groundwork for point to point * Tidy up * formatting * Test for registry * Mocked test for sending mappings * Mappings tests * Fleshing out rest of implementation * Test for point to point messaging * Rename and tidy * Sleep to enforce asyncness * Caching sockets * Naming and general tidy * Formatting * Mock tests for broadcast mappings * Test for send back and forth * Stop ptp server * Add failing dist test * Fix up point-to-point dist test * Formatting * Tidy-up * Review comments
- Loading branch information
Showing
33 changed files
with
1,138 additions
and
7 deletions.
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,52 @@ | ||
#pragma once | ||
|
||
#include <faabric/scheduler/Scheduler.h> | ||
#include <faabric/transport/PointToPointClient.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; | ||
|
||
std::shared_ptr<PointToPointClient> getClient(const std::string& host); | ||
|
||
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,29 @@ | ||
#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; | ||
|
||
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.