/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
simgrid::xbt::Extension<Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
simgrid::xbt::Extension<Host, FileDescriptorHostExt> FileDescriptorHostExt::EXTENSION_ID;
simgrid::xbt::Extension<Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
simgrid::xbt::Extension<Host, FileDescriptorHostExt> FileDescriptorHostExt::EXTENSION_ID;
-File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
+File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
-File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata)
+File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata)
{
// this cannot fail because we get a xbt_die if the mountpoint does not exist
Storage* st = nullptr;
size_t longest_prefix_length = 0;
{
// this cannot fail because we get a xbt_die if the mountpoint does not exist
Storage* st = nullptr;
size_t longest_prefix_length = 0;
for (auto const& mnt : host->get_mounted_storages()) {
XBT_DEBUG("See '%s'", mnt.first.c_str());
for (auto const& mnt : host->get_mounted_storages()) {
XBT_DEBUG("See '%s'", mnt.first.c_str());
if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
- if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
- mount_point_ = fullpath.substr(0, longest_prefix_length);
- path_ = fullpath.substr(longest_prefix_length, fullpath.length());
+ if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
+ mount_point_ = fullpath_.substr(0, longest_prefix_length);
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
sg_size_t read_size = local_storage_->read(std::min(size, size_ - current_position_));
current_position_ += read_size;
sg_size_t read_size = local_storage_->read(std::min(size, size_ - current_position_));
current_position_ += read_size;
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), read_size);
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), read_size);
- Host* m_host_list[] = {Host::current(), host};
- double* flops_amount = new double[2]{0, 0};
- double* bytes_amount = new double[4]{0, 0, static_cast<double>(read_size), 0};
+ std::vector<Host*> m_host_list = {Host::current(), host};
+ std::vector<double> flops_amount = {0., 0.};
+ std::vector<double> bytes_amount = {0., 0., static_cast<double>(read_size), 0.};
- this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+ this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
- * \param size of the file to write
- * \return the number of bytes successfully write or -1 if an error occurred
+ * @param size of the file to write
+ * @return the number of bytes successfully write or -1 if an error occurred
/* Find the host where the file is physically located (remote or local)*/
Host* host = local_storage_->get_host();
/* Find the host where the file is physically located (remote or local)*/
Host* host = local_storage_->get_host();
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
- Host* m_host_list[] = {Host::current(), host};
- double* flops_amount = new double[2]{0, 0};
- double* bytes_amount = new double[4]{0, static_cast<double>(size), 0, 0};
+ std::vector<Host*> m_host_list = {Host::current(), host};
+ std::vector<double> flops_amount = {0, 0};
+ std::vector<double> bytes_amount = {0, static_cast<double>(size), 0, 0};
- this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+ this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
}
XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", get_path(), local_storage_->get_cname(), size, size_);
}
XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", get_path(), local_storage_->get_cname(), size, size_);
std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
auto sz = content->find(path_);
if (sz != content->end()) { // src file exists
std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
auto sz = content->find(path_);
if (sz != content->end()) { // src file exists
XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
storage_dest->get_host()->get_cname());
XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
storage_dest->get_host()->get_cname());
- Host* m_host_list[] = {src_host, dst_host};
- double* flops_amount = new double[2]{0, 0};
- double* bytes_amount = new double[4]{0, static_cast<double>(read_size), 0, 0};
+ std::vector<Host*> m_host_list = {src_host, dst_host};
+ std::vector<double> flops_amount = {0, 0};
+ std::vector<double> bytes_amount = {0, static_cast<double>(read_size), 0, 0};
- this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+ this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
/* Create file on remote host, write it and close it */
File* fd = new File(fullpath, dst_host, nullptr);
/* Create file on remote host, write it and close it */
File* fd = new File(fullpath, dst_host, nullptr);
- * \param fd : file object that identifies the stream
- * \param offset : number of bytes to offset from origin
- * \param origin : Position used as reference for the offset. It is specified by one of the following constants defined
+ * @param fd : file object that identifies the stream
+ * @param offset : number of bytes to offset from origin
+ * @param origin : Position used as reference for the offset. It is specified by one of the following constants defined
* in \<stdio.h\> exclusively to be used as arguments for this function (SEEK_SET = beginning of file,
* SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
*/
* in \<stdio.h\> exclusively to be used as arguments for this function (SEEK_SET = beginning of file,
* SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
*/
- * \brief Copy a file to another location on a remote host.
- * \param file : the file to move
- * \param host : the remote host where the file has to be copied
- * \param fullpath : the complete path destination on the remote host
- * \return If successful, the function returns 0. Otherwise, it returns -1.
+ * @brief Copy a file to another location on a remote host.
+ * @param file : the file to move
+ * @param host : the remote host where the file has to be copied
+ * @param fullpath : the complete path destination on the remote host
+ * @return If successful, the function returns 0. Otherwise, it returns -1.
- * \brief Move a file to another location on a remote host.
- * \param file : the file to move
- * \param host : the remote host where the file has to be moved
- * \param fullpath : the complete path destination on the remote host
- * \return If successful, the function returns 0. Otherwise, it returns -1.
+ * @brief Move a file to another location on a remote host.
+ * @param file : the file to move
+ * @param host : the remote host where the file has to be moved
+ * @param fullpath : the complete path destination on the remote host
+ * @return If successful, the function returns 0. Otherwise, it returns -1.