void sg_host_allocate_attribute(sg_host_t host){ HostAttribute data; data = calloc(1,sizeof(struct _HostAttribute)); data->total_cost = 0; /* Set the hosts to off and idle at the beginning */ data->on_off = 0; data->idle_busy = 0; data->booting=NULL; sg_host_user_set(host, data); }
/* Disable a resource, i.e., act as a VM is terminated on a host. This amounts to: * - setting attributes to 'OFF' * - Resetting the start time of the host to 0 (just in case) * - Do some accounting. The time (in seconds) spent since the last time host/VM was started (state set to ON) is * rounded down (as the first hour is charged on activation) and multiplied by the hour price. * If a provisioning delay is needed before a VM is actually available for executing task, this function destroys the * booting task created by the sg_host_start function. */ void sg_host_terminate(sg_host_t host){ HostAttribute attr = (HostAttribute) sg_host_user(host); double duration = SD_get_clock() - attr->start_time; if (attr->booting) SD_task_destroy(attr->booting); attr->on_off = 0; attr->start_time = 0.0; attr->total_cost += ((((int) duration / 3600)) * attr->price); XBT_DEBUG("VM stopped on %s: Total cost is now $%f for this host", sg_host_get_name(host), attr->total_cost); sg_host_user_set(host, attr); }
/* Activate a resource, i.e., act as if a VM is started on a host. This amounts to : * - setting attributes to 'ON' and 'idle' * - Resetting the start time of the host to the current time * - bill at least the first hour * If a provisioning delay is needed before a VM is actually available for executing task, this function : * - creates a task whose name is "Booting " followed by the host name * - schedules this task on the host * - Ensures that no compute task can be executed before the completion of this booting task. */ void sg_host_start(sg_host_t host){ HostAttribute attr = (HostAttribute) sg_host_user(host); char name[1024]; attr->on_off = 1; attr->idle_busy = 0; attr->start_time = SD_get_clock(); attr->total_cost += attr->price; if (attr->provisioning_delay){ sprintf(name,"Booting %s", sg_host_get_name(host)); attr->booting = SD_task_create_comp_seq(name, NULL, attr->provisioning_delay*sg_host_speed(host)); SD_task_schedulel(attr->booting, 1, host); attr->available_at += attr->provisioning_delay; handle_resource_dependency(host, attr->booting); } XBT_DEBUG("VM started on %s: Total cost is now $%f for this host", sg_host_get_name(host), attr->total_cost); sg_host_user_set(host, attr); }
static void sg_host_set_last_scheduled_task(sg_host_t host, SD_task_t task){ HostAttribute attr = (HostAttribute) sg_host_user(host); attr->last_scheduled_task=task; sg_host_user_set(host, attr); }
static void sg_host_set_available_at(sg_host_t host, double time) { HostAttribute attr = (HostAttribute) sg_host_user(host); attr->available_at = time; sg_host_user_set(host, attr); }
static void sg_host_free_attribute(sg_host_t host) { free(sg_host_user(host)); sg_host_user_set(host, NULL); }
static void sg_host_allocate_attribute(sg_host_t host) { void *data; data = calloc(1, sizeof(struct _HostAttribute)); sg_host_user_set(host, data); }
void sg_host_set_to_busy(sg_host_t host){ HostAttribute attr = (HostAttribute) sg_host_user(host); attr->idle_busy=1; sg_host_user_set(host, attr); }
void sg_host_set_provisioning_delay(sg_host_t host, double delay){ HostAttribute attr = (HostAttribute) sg_host_user(host); attr->provisioning_delay= delay; sg_host_user_set(host, attr); }
void sg_host_set_price(sg_host_t host, double price){ HostAttribute attr = (HostAttribute) sg_host_user(host); attr->price = price; sg_host_user_set(host, attr); }
/** \ingroup m_host_management * * \brief Set the user data of a #msg_host_t. * * This functions attach \a data to \a host if it is possible. */ msg_error_t MSG_host_set_data(msg_host_t host, void *data) { sg_host_user_set(host, data); return MSG_OK; }