sapling/eden/fs/takeover/TakeoverData.h

224 lines
6.3 KiB
C
Raw Normal View History

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/File.h>
#include <folly/futures/Promise.h>
#include <memory>
#include <optional>
#include <vector>
#include "eden/fs/takeover/gen-cpp2/takeover_types.h"
#include "eden/fs/utils/PathFuncs.h"
#ifndef _WIN32
#include "eden/fs/fuse/FuseTypes.h"
#endif
namespace folly {
class IOBuf;
class exception_wrapper;
} // namespace folly
namespace facebook {
namespace eden {
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
// Holds the versions supported by this build.
extern const std::set<int32_t> kSupportedTakeoverVersions;
/**
* TakeoverData contains the data exchanged between processes during
* graceful mount point takeover.
*/
class TakeoverData {
public:
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
enum : int32_t {
// The list of possible versions supported by the client
// and server in this build of the code. If/when we
// bump the version we will retain support for the prior
// version in both the client and server in order to
// allow rolling back a new build.
// This is a protocol version that we will never support.
// It is included in this enum to reserve it and so that
// we can use it in tests
kTakeoverProtocolVersionNeverSupported = 0,
// This is the protocol version supported by eden just prior
// to this protocol versioning code being written
kTakeoverProtocolVersionOne = 1,
// This version introduced thrift encoding of the takeover structures.
// It is nominally version 2 but named 3 here because VersionOne
// responses don't include a version header, but do always respond
// with either a word set to either 1 or 2. To disambiguate things
// we want to use word value 3 to indicate this new protocol, but
// naming the symbol Version3 and assigning it the value 3 seemed
// like too much of a headache, so we simply skip over using
// version 2 to describe this next one.
kTakeoverProtocolVersionThree = 3,
add additional takeover "ready" handshake Summary: For graceful restart takeovers, we would like to implement an additional handshake. This handshake will occur right after the takeover data is ready to be sent to the client, but before actually sending it. This is to make sure the old daemon can recover in case of the client not being responsive (the client replies back to the server, and if no response is recieved in 5 seconds, the server will recover). There are a few cases here: * **Server sends ping (two cases discussed below)** I introduced a new ProtocolVersion. Daemons with this change will now have ProtocolVersion4. The Server checks the max version of the client, and if this version is ProtocolVersion4, we know the client can listen for pings. So we will send the ping. Otherwise, we don't send a ping. With this, we will only send pings if we know the client will be listening for one. The case in which a client isn't listening is if we adopt this change and we downgrade past the change. * **Server does not send ping and Client knows to listen for ping** This will be a common case immediately after this change. The client will parse the sent data and check if it matches the "ready" ping, and if it doesn't, the client assumes the server simply sent the Takeover Data. * **Server does not sends ping and Client doesn't know to listen for ping** This is the case before this change. Reviewed By: simpkins Differential Revision: D20290271 fbshipit-source-id: b68e4df6264fb071d770671a80e28c90ddb0d3f2
2020-04-07 19:50:06 +03:00
// This version introduced an additonal handshake before taking over
// that is sent after the TakeoverData is ready but before actually
// sending it. This is in order to make sure we only send the data if
// the new process is healthy and able to receive, because otherwise
// we would want to recover ourselves. While this does not change
// the actual data format of the TakeoverData, it does change the
// number of sends/receives, and this additional handshake would
// break a server with this extra handshake talking to a client
// without it
kTakeoverProtocolVersionFour = 4,
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
};
// Given a set of versions provided by a client, find the largest
// version that is also present in the provided set of supported
// versions.
static std::optional<int32_t> computeCompatibleVersion(
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
const std::set<int32_t>& versions,
const std::set<int32_t>& supported = kSupportedTakeoverVersions);
struct MountInfo {
MountInfo(
AbsolutePathPiece mountPath,
AbsolutePathPiece stateDirectory,
const std::vector<AbsolutePath>& bindMountPaths,
folly::File fd,
#ifndef _WIN32
fuse_init_out connInfo,
#endif
SerializedInodeMap&& inodeMap)
: mountPath{mountPath},
stateDirectory{stateDirectory},
bindMounts{bindMountPaths},
fuseFD{std::move(fd)},
#ifndef _WIN32
connInfo{connInfo},
#endif
inodeMap{std::move(inodeMap)} {
}
AbsolutePath mountPath;
AbsolutePath stateDirectory;
std::vector<AbsolutePath> bindMounts;
folly::File fuseFD;
#ifndef _WIN32
fuse_init_out connInfo;
#endif
SerializedInodeMap inodeMap;
};
/**
* Serialize the TakeoverData into a buffer that can be sent to a remote
* process.
*
* This includes all data except for file descriptors. The file descriptors
* must be sent separately.
*/
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
folly::IOBuf serialize(int32_t protocolVersion);
/**
* Serialize an exception.
*/
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
static folly::IOBuf serializeError(
int32_t protocolVersion,
const folly::exception_wrapper& ew);
add additional takeover "ready" handshake Summary: For graceful restart takeovers, we would like to implement an additional handshake. This handshake will occur right after the takeover data is ready to be sent to the client, but before actually sending it. This is to make sure the old daemon can recover in case of the client not being responsive (the client replies back to the server, and if no response is recieved in 5 seconds, the server will recover). There are a few cases here: * **Server sends ping (two cases discussed below)** I introduced a new ProtocolVersion. Daemons with this change will now have ProtocolVersion4. The Server checks the max version of the client, and if this version is ProtocolVersion4, we know the client can listen for pings. So we will send the ping. Otherwise, we don't send a ping. With this, we will only send pings if we know the client will be listening for one. The case in which a client isn't listening is if we adopt this change and we downgrade past the change. * **Server does not send ping and Client knows to listen for ping** This will be a common case immediately after this change. The client will parse the sent data and check if it matches the "ready" ping, and if it doesn't, the client assumes the server simply sent the Takeover Data. * **Server does not sends ping and Client doesn't know to listen for ping** This is the case before this change. Reviewed By: simpkins Differential Revision: D20290271 fbshipit-source-id: b68e4df6264fb071d770671a80e28c90ddb0d3f2
2020-04-07 19:50:06 +03:00
/**
* Create a ping to send.
*/
static folly::IOBuf serializePing();
/**
* Deserialize the TakeoverData from a buffer.
*/
static TakeoverData deserialize(folly::IOBuf* buf);
add additional takeover "ready" handshake Summary: For graceful restart takeovers, we would like to implement an additional handshake. This handshake will occur right after the takeover data is ready to be sent to the client, but before actually sending it. This is to make sure the old daemon can recover in case of the client not being responsive (the client replies back to the server, and if no response is recieved in 5 seconds, the server will recover). There are a few cases here: * **Server sends ping (two cases discussed below)** I introduced a new ProtocolVersion. Daemons with this change will now have ProtocolVersion4. The Server checks the max version of the client, and if this version is ProtocolVersion4, we know the client can listen for pings. So we will send the ping. Otherwise, we don't send a ping. With this, we will only send pings if we know the client will be listening for one. The case in which a client isn't listening is if we adopt this change and we downgrade past the change. * **Server does not send ping and Client knows to listen for ping** This will be a common case immediately after this change. The client will parse the sent data and check if it matches the "ready" ping, and if it doesn't, the client assumes the server simply sent the Takeover Data. * **Server does not sends ping and Client doesn't know to listen for ping** This is the case before this change. Reviewed By: simpkins Differential Revision: D20290271 fbshipit-source-id: b68e4df6264fb071d770671a80e28c90ddb0d3f2
2020-04-07 19:50:06 +03:00
/**
* Checks to see if a message is of type PING
*/
static bool isPing(const folly::IOBuf* buf);
/**
* The main eden lock file that prevents two edenfs processes from running at
* the same time.
*/
folly::File lockFile;
/**
* The thrift server socket.
*/
folly::File thriftSocket;
/**
* The list of mount points.
*/
std::vector<MountInfo> mountPoints;
/**
* The takeoverComplete promise will be fulfilled by the TakeoverServer code
* once the TakeoverData has been sent to the remote process.
*/
folly::Promise<std::optional<TakeoverData>> takeoverComplete;
private:
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
/**
* Serialize data using version 1 of the takeover protocol.
*/
folly::IOBuf serializeVersion1();
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
/**
* Serialize an exception using version 1 of the takeover protocol.
*/
static folly::IOBuf serializeErrorVersion1(
const folly::exception_wrapper& ew);
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
/**
* Deserialize the TakeoverData from a buffer using version 1 of the takeover
* protocol.
*/
static TakeoverData deserializeVersion1(folly::IOBuf* buf);
/**
* Serialize data using version 2 of the takeover protocol.
*/
folly::IOBuf serializeVersion3();
/**
* Serialize an exception using version 2 of the takeover protocol.
*/
static folly::IOBuf serializeErrorVersion3(
const folly::exception_wrapper& ew);
/**
* Deserialize the TakeoverData from a buffer using version 2 of the takeover
* protocol.
*/
static TakeoverData deserializeVersion3(folly::IOBuf* buf);
add version handshake to takeover protocol Summary: Whilst chatting with simpkins we realized that we lost the handshake portion of the takeover protocol during a refactor. The handshake is important for a couple of reasons: 1. It prevents unmounting and loosing all the mounts in the case that sometime decides to netcat or otherwise connect to the socket 2. It gives us an opportunity to short circuit any heavy lifting if we know that it will be impossible to succeed. 3. It allows us to rollback to earlier builds with older versions of the takeover protocol. This diff adds a little bit of machinery to enable passing a set of supported takeover protocol version numbers. The intent is to retain support for the two of these at a time; any time we change the encoding/protocol for takeover we'll bump the version number and add supporting code to handle the new format, retaining support for the prior version. Retaining the ability to handle the prior version allows us to downgrade to an earlier build gracefully if/when the need arises. I opted to do this here rather than by bumping the `kProtocolID` constant in `UnixSocket.h` becase we're not really changing the lowest level of the protocol; just the takeover specific portions. I haven't actually changed the takeover serialization in this diff, but do have some work on that happening in D6733406; that diff will be amended to take advantage and demonstrate how this versioning scheme works. A key thing to note about the implementation of this diff is that the client sends the version number to the server, but doesn't add any explicit version encoding in the response we receive. This is deliberate and allows us to upgrade prior builds to this new scheme. I'll add a more definitive check for this situation when I actually rev the format in the following diff. Reviewed By: simpkins Differential Revision: D6743065 fbshipit-source-id: c991cebfee918daad098105ca6bcfef76374c0ff
2018-01-31 01:16:05 +03:00
/**
* Message type values.
* If we ever need to include more information in the takeover data in the
* future we can do so by adding new message types here, and deprecating the
* older formats once we have upgraded all servers to use the new format.
*/
enum MessageType : uint32_t {
ERROR = 1,
MOUNTS = 2,
add additional takeover "ready" handshake Summary: For graceful restart takeovers, we would like to implement an additional handshake. This handshake will occur right after the takeover data is ready to be sent to the client, but before actually sending it. This is to make sure the old daemon can recover in case of the client not being responsive (the client replies back to the server, and if no response is recieved in 5 seconds, the server will recover). There are a few cases here: * **Server sends ping (two cases discussed below)** I introduced a new ProtocolVersion. Daemons with this change will now have ProtocolVersion4. The Server checks the max version of the client, and if this version is ProtocolVersion4, we know the client can listen for pings. So we will send the ping. Otherwise, we don't send a ping. With this, we will only send pings if we know the client will be listening for one. The case in which a client isn't listening is if we adopt this change and we downgrade past the change. * **Server does not send ping and Client knows to listen for ping** This will be a common case immediately after this change. The client will parse the sent data and check if it matches the "ready" ping, and if it doesn't, the client assumes the server simply sent the Takeover Data. * **Server does not sends ping and Client doesn't know to listen for ping** This is the case before this change. Reviewed By: simpkins Differential Revision: D20290271 fbshipit-source-id: b68e4df6264fb071d770671a80e28c90ddb0d3f2
2020-04-07 19:50:06 +03:00
PING = 3,
};
/**
* The length of the serialized header.
* This is just a 4-byte message type field.
*/
static constexpr uint32_t kHeaderLength = sizeof(uint32_t);
};
} // namespace eden
} // namespace facebook