2#include <boost/algorithm/string/trim.hpp>
3#include <boost/uuid/name_generator.hpp>
4#include <boost/uuid/string_generator.hpp>
5#include <boost/uuid/uuid_io.hpp>
25 boost::uuids::string_generator ns_gen;
26 auto ns = ns_gen(
"af7ce8f2-a9ee-46cb-38ee-71c318aa3580");
28 boost::uuids::name_generator gen{ns};
29 return boost::uuids::to_string(gen(s.
data(), s.
size()));
39 constexpr int firstLevelLen = 2;
53 auto p =
fs::path(addressDirectory.
begin(), addressDirectory.
end()) /
"precice-run" / directional;
86 "Unable to establish connection as the connection file \"{}\" couldn't be opened.",
91 "Unable to establish connection as the connection file \"{}\" is empty. "
92 "Please report this bug to the preCICE developers.",
94 boost::algorithm::trim_right(addressData);
102 PRECICE_WARN(
"Cannot clean-up the connection file \"{}\" as it doesn't exist. "
103 "In case of connection problems, please report this to the preCICE developers.",
112 "The connection file \"{}\" wasn't properly removed. "
113 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
116 PRECICE_WARN(
"Unable to clean-up connection file due to error: {}. "
117 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
128 auto message =
"Unable to establish connection as a {}connection file already exists at \"{}\". "
129 "This is likely a leftover of a previous crash or stop during communication build-up. "
130 "Please remove the \"precice-run\" directory and restart the simulation.";
135 PRECICE_DEBUG(
"Writing temporary connection file \"{}\"", tmp.generic_string());
139 PRECICE_CHECK(ofs,
"Unable to establish connection as the temporary connection file \"{}\" couldn't be opened.", tmp.generic_string());
141 "{}\nAcceptor: {}, Requester: {}, Tag: {}, Rank: {}",
145 "Unable to establish connection as the temporary connection file \"{}\" was written, but doesn't exist on disk. "
146 "Please report this bug to the preCICE developers.",
147 tmp.generic_string());
153 "The temporary connection file \"{}\" wasn't properly removed. "
154 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
155 tmp.generic_string());
157 "Unable to establish connection as the connection file \"{}\" doesn't exist on disk. "
158 "Please report this bug to the preCICE developers.",
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
std::string const addressDirectory
std::string const acceptorName
std::string getLocalDirectory() const
Returns the local directory which is used to store the hashed part.
std::string const requesterName
std::string getFilename() const
Returns the full path to the hashed filename.
std::string read() const
Reads the info from the connection info file. Will block, if the the file is not present.
void write(std::string_view info) const
Write the string info, e.g. IP:port to the connection info file.
~ConnectionInfoWriter()
Removes the connection info file and the directories ./precice-run/[hash], is empty.
T create_directories(T... args)
T generic_string(T... args)
std::string hashedFilePath(std::string_view acceptorName, std::string_view requesterName, std::string_view meshName, Rank rank)
Returns the file name for the connection information.
std::string localDirectory(std::string_view acceptorName, std::string_view requesterName, std::string_view addressDirectory)
contains the data communication abstraction layer.