/* 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. */
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_host);
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
read_size = simcall_file_read(file_priv->simdata->smx_file, size, attached_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.", storage_priv_src->hostname, 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.", storage_priv_src->hostname, read_size);
- msg_host_t *m_host_list = NULL;
- m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t));
+ msg_host_t *m_host_list = nullptr;
+ m_host_list = xbt_new0(msg_host_t, 2);
- double flops_amount[] = { 0, 0 };
- double bytes_amount[] = { 0, 0, (double)read_size, 0 };
+ double flops_amount[] = { 0, 0};
+ double bytes_amount[] = { 0, 0, static_cast<double>(read_size), 0 };
msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount,
msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount,
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
{
msg_file_priv_t file_priv = MSG_file_priv(fd);
sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
{
msg_file_priv_t file_priv = MSG_file_priv(fd);
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
/* 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.", storage_priv_src->hostname, 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.", storage_priv_src->hostname, size);
- msg_host_t *m_host_list = NULL;
- m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t));
+ msg_host_t *m_host_list = nullptr;
+ m_host_list = xbt_new0(msg_host_t, 2);
m_host_list[0] = MSG_host_self();
m_host_list[1] = attached_host;
double flops_amount[] = { 0, 0 };
m_host_list[0] = MSG_host_self();
m_host_list[1] = attached_host;
double flops_amount[] = { 0, 0 };
- double bytes_amount[] = { 0, (double)size, 0, 0 };
+ double bytes_amount[] = { 0, static_cast<double>(size), 0, 0 };
msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount,
msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount,
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
- offset = simcall_file_tell(file_priv->simdata->smx_file);
- write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host);
+ sg_size_t offset = simcall_file_tell(file_priv->simdata->smx_file);
+ sg_size_t write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host);
priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
priv->desc_id = __MSG_host_get_file_descriptor_id(MSG_host_self());
priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
priv->desc_id = __MSG_host_get_file_descriptor_id(MSG_host_self());
- name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id);
+ name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
- name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id);
+ name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_self()->cname(), priv->desc_id);
__MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id);
xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
xbt_free(name);
__MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id);
xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
xbt_free(name);
{
msg_file_priv_t file_priv = MSG_file_priv(fd);
/* Find the host where the file is physically located (remote or local)*/
{
msg_file_priv_t file_priv = MSG_file_priv(fd);
/* Find the host where the file is physically located (remote or local)*/
- msg_storage_t storage_src =
- (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
+ msg_storage_t storage_src = static_cast<msg_storage_t>(xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId));
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host);
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host);
msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin)
{
msg_file_priv_t priv = MSG_file_priv(fd);
msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin)
{
msg_file_priv_t priv = MSG_file_priv(fd);
msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
{
msg_file_priv_t priv = MSG_file_priv(fd);
msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
{
msg_file_priv_t priv = MSG_file_priv(fd);
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
MSG_file_seek(file, 0, SEEK_SET);
read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host);
/* Find the real host destination where the file will be physically stored */
msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname);
MSG_file_seek(file, 0, SEEK_SET);
read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host);
/* Find the real host destination where the file will be physically stored */
- xbt_dict_cursor_t cursor = NULL;
- char *mount_name, *storage_name, *file_mount_name, *host_name_dest;
- msg_storage_t storage_dest = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
+ msg_storage_t storage_dest = nullptr;
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
file_mount_name[strlen(mount_name)] = '\0';
strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
file_mount_name[strlen(mount_name)] = '\0';
longest_prefix_length = strlen(mount_name);
storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
}
longest_prefix_length = strlen(mount_name);
storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
}
if(longest_prefix_length>0){
/* Mount point found, retrieve the host the storage is attached to */
msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
host_name_dest = (char*)storage_dest_priv->hostname;
host_dest = MSG_host_by_name(host_name_dest);
if(longest_prefix_length>0){
/* Mount point found, retrieve the host the storage is attached to */
msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
host_name_dest = (char*)storage_dest_priv->hostname;
host_dest = MSG_host_by_name(host_name_dest);
- XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, sg_host_get_name(host));
+ XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->cname());
return MSG_TASK_CANCELED;
}
XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname,
host_name_dest);
return MSG_TASK_CANCELED;
}
XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname,
host_name_dest);
- msg_host_t *m_host_list = NULL;
- m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t));
+ msg_host_t *m_host_list = nullptr;
+ m_host_list = xbt_new0(msg_host_t, 2);
m_host_list[0] = attached_host;
m_host_list[1] = host_dest;
double flops_amount[] = { 0, 0 };
m_host_list[0] = attached_host;
m_host_list[1] = host_dest;
double flops_amount[] = { 0, 0 };
- double bytes_amount[] = { 0, (double)read_size, 0, 0 };
+ double bytes_amount[] = { 0, static_cast<double>(read_size), 0, 0 };
- MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL);
+ MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, nullptr);
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
if (transfer == MSG_TASK_CANCELED)
XBT_WARN("Transfer error, task has been canceled!");
* This functions checks whether a storage is a valid pointer or not and return its name.
*/
const char *MSG_storage_get_name(msg_storage_t storage) {
* This functions checks whether a storage is a valid pointer or not and return its name.
*/
const char *MSG_storage_get_name(msg_storage_t storage) {
* \param storage a storage
* \param name a property name
* \param value what to change the property to
* \param storage a storage
* \param name a property name
* \param value what to change the property to
-void MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn) {
- xbt_dict_set(MSG_storage_get_properties(storage), name, value,free_ctn);
+void MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value)
+{
+ xbt_dict_set(MSG_storage_get_properties(storage), name, value, nullptr);
}
/** \ingroup msg_storage_management
* \brief Returns a dynar containing all the storage elements declared at a given point of time
*/
}
/** \ingroup msg_storage_management
* \brief Returns a dynar containing all the storage elements declared at a given point of time
*/
xbt_lib_foreach(storage_lib, cursor, key, data) {
xbt_lib_foreach(storage_lib, cursor, key, data) {
xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
xbt_dynar_push(res, &elm);
}
xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor);
xbt_dynar_push(res, &elm);
}
* This functions checks whether a storage is a valid pointer or not and return its name.
*/
const char *MSG_storage_get_host(msg_storage_t storage) {
* This functions checks whether a storage is a valid pointer or not and return its name.
*/
const char *MSG_storage_get_host(msg_storage_t storage) {