They are simply the negation of is_on() and, when the two forms are defined,
we may wonder if there is some kind of intermediate state neither on(), nor
off().
26 files changed:
XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
XBT_PUBLIC int sg_host_is_on(sg_host_t host);
XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
XBT_PUBLIC int sg_host_is_on(sg_host_t host);
-XBT_PUBLIC int sg_host_is_off(sg_host_t host);
+XBT_ATTRIB_DEPRECATED_v325("Please use !sg_host_is_on()") XBT_PUBLIC int sg_host_is_off(sg_host_t host);
/** @ingroup m_host_management
* @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
/** @ingroup m_host_management
* @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
/** @brief Check if the current Resource is active */
virtual bool is_on() const;
/** @brief Check if the current Resource is shut down */
/** @brief Check if the current Resource is active */
virtual bool is_on() const;
/** @brief Check if the current Resource is shut down */
- virtual bool is_off() const;
+ XBT_ATTRIB_DEPRECATED_v325("Please use !is_on()") virtual bool is_off() const;
/** @brief Turn on the current Resource */
virtual void turn_on();
/** @brief Turn off the current Resource */
/** @brief Turn on the current Resource */
virtual void turn_on();
/** @brief Turn off the current Resource */
XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
/** @brief Start the host if it is off
*
XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
/** @brief Start the host if it is off
*
- * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy
+ * See also #MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
* for more info on DVFS.
*/
XBT_PUBLIC void MSG_host_on(sg_host_t h);
/** @brief Stop the host if it is on
*
* for more info on DVFS.
*/
XBT_PUBLIC void MSG_host_on(sg_host_t h);
/** @brief Stop the host if it is on
*
- * See also MSG_host_is_on() and MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy
+ * See also MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
* for more info on DVFS.
*/
XBT_PUBLIC void MSG_host_off(sg_host_t h);
XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
* for more info on DVFS.
*/
XBT_PUBLIC void MSG_host_off(sg_host_t h);
XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
-XBT_PUBLIC int MSG_host_is_off(sg_host_t h);
+XBT_ATTRIB_DEPRECATED_v325("Please use !MSG_host_is_on()") XBT_PUBLIC int MSG_host_is_off(sg_host_t h);
XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
/** Returns if that host is currently up and running */
bool is_on() const;
/** Returns if that host is currently down and offline */
/** Returns if that host is currently up and running */
bool is_on() const;
/** Returns if that host is currently down and offline */
- bool is_off() const { return not is_on(); }
+ XBT_ATTRIB_DEPRECATED_v325("Please use !is_on()") bool is_off() const { return not is_on(); }
const char* get_property(std::string key) const;
void set_property(std::string key, std::string value);
const char* get_property(std::string key) const;
void set_property(std::string key, std::string value);
/** @deprecated See Host::is_on() */
XBT_ATTRIB_DEPRECATED_v323("Please use Host::is_on()") bool isOn() { return is_on(); }
/** @deprecated See Host::is_off() */
/** @deprecated See Host::is_on() */
XBT_ATTRIB_DEPRECATED_v323("Please use Host::is_on()") bool isOn() { return is_on(); }
/** @deprecated See Host::is_off() */
- XBT_ATTRIB_DEPRECATED_v323("Please use Host::is_off()") bool isOff() { return is_off(); }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Host::is_off()") bool isOff() { return not is_on(); }
/** @deprecated See Host::get_property() */
XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_property()") const char* getProperty(const char* key)
{
/** @deprecated See Host::get_property() */
XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_property()") const char* getProperty(const char* key)
{
void turn_on();
bool is_on() const;
void turn_off();
void turn_on();
bool is_on() const;
void turn_off();
void* get_data(); /** Should be used only from the C interface. Prefer extensions in C++ */
void set_data(void* d);
void* get_data(); /** Should be used only from the C interface. Prefer extensions in C++ */
void set_data(void* d);
- if (host_ && host_->is_off()) { /* FIXME: handle resource failure for parallel tasks too */
+ if (host_ && not host_->is_on()) { /* FIXME: handle resource failure for parallel tasks too */
/* If the host running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
state_ = SIMIX_FAILED;
/* If the host running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
state_ = SIMIX_FAILED;
smx_simcall_t simcall = simcalls_.front();
simcalls_.pop_front();
e_smx_state_t result;
smx_simcall_t simcall = simcalls_.front();
simcalls_.pop_front();
e_smx_state_t result;
- if (host_ && host_->is_off()) {
+ if (host_ && not host_->is_on()) {
/* If the host running the synchro failed, notice it. This way, the asking
* actor can be killed if it runs on that host itself */
result = SIMIX_SRC_HOST_FAILURE;
/* If the host running the synchro failed, notice it. This way, the asking
* actor can be killed if it runs on that host itself */
result = SIMIX_SRC_HOST_FAILURE;
THROW_IMPOSSIBLE;
break;
}
THROW_IMPOSSIBLE;
break;
}
- if (simcall->issuer->host_->is_off()) {
+ if (not simcall->issuer->host_->is_on()) {
simcall->issuer->context_->iwannadie = true;
}
simcall_process_sleep__set__result(simcall, result);
simcall->issuer->context_->iwannadie = true;
}
simcall_process_sleep__set__result(simcall, result);
{
actor_->finished_ = true;
{
actor_->finished_ = true;
- if (actor_->auto_restart_ && actor_->host_->is_off()) {
+ if (actor_->auto_restart_ && not actor_->host_->is_on()) {
XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
actor_->get_cname());
watched_hosts.insert(actor_->host_->get_cname());
XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
actor_->get_cname());
watched_hosts.insert(actor_->host_->get_cname());
-bool Resource::is_off() const
+bool Resource::is_off() const // deprecated
{
return sg_host_is_on(h);
}
{
return sg_host_is_on(h);
}
-int MSG_host_is_off(sg_host_t h)
+int MSG_host_is_off(sg_host_t h) // deprecated
- return sg_host_is_off(h);
+ return not sg_host_is_on(h);
}
xbt_dict_t MSG_host_get_properties(sg_host_t host)
{
}
xbt_dict_t MSG_host_get_properties(sg_host_t host)
{
static void hostStateChange(s4u::Host& host)
{
static void hostStateChange(s4u::Host& host)
{
- if (host.is_off()) { // just turned off.
+ if (not host.is_on()) { // just turned off.
std::vector<s4u::VirtualMachine*> trash;
/* Find all VMs living on that host */
for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
std::vector<s4u::VirtualMachine*> trash;
/* Find all VMs living on that host */
for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_)
{
simgrid::s4u::Host* src_pm = vm->get_pm();
{
simgrid::s4u::Host* src_pm = vm->get_pm();
+ if (not src_pm->is_on())
THROWF(vm_error, 0, "Cannot migrate VM '%s' from host '%s', which is offline.", vm->get_cname(),
src_pm->get_cname());
THROWF(vm_error, 0, "Cannot migrate VM '%s' from host '%s', which is offline.", vm->get_cname(),
src_pm->get_cname());
+ if (not dst_pm->is_on())
THROWF(vm_error, 0, "Cannot migrate VM '%s' to host '%s', which is offline.", vm->get_cname(), dst_pm->get_cname());
if (vm->get_state() != simgrid::s4u::VirtualMachine::state::RUNNING)
THROWF(vm_error, 0, "Cannot migrate VM '%s' that is not running yet.", vm->get_cname());
THROWF(vm_error, 0, "Cannot migrate VM '%s' to host '%s', which is offline.", vm->get_cname(), dst_pm->get_cname());
if (vm->get_state() != simgrid::s4u::VirtualMachine::state::RUNNING)
THROWF(vm_error, 0, "Cannot migrate VM '%s' that is not running yet.", vm->get_cname());
simgrid::simix::simcall([this] {
this->pimpl_cpu->turn_on();
this->pimpl_->turn_on();
simgrid::simix::simcall([this] {
this->pimpl_cpu->turn_on();
this->pimpl_->turn_on();
*
* @brief Start the host if it is off
*
*
* @brief Start the host if it is off
*
- * See also #sg_host_is_on() and #sg_host_is_off() to test the current state of the host and @ref plugin_energy
+ * See also #sg_host_is_on() to test the current state of the host and @ref plugin_energy
* for more info on DVFS.
*/
void sg_host_turn_on(sg_host_t host)
* for more info on DVFS.
*/
void sg_host_turn_on(sg_host_t host)
*
* @brief Stop the host if it is on
*
*
* @brief Stop the host if it is on
*
- * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref plugin_energy
+ * See also #MSG_host_is_on() to test the current state of the host and @ref plugin_energy
* for more info on DVFS.
*/
void sg_host_turn_off(sg_host_t host)
* for more info on DVFS.
*/
void sg_host_turn_off(sg_host_t host)
-/** @ingroup m_host_management
- * @brief Determine if a host is currently off.
- *
- * See also #sg_host_turn_on() and #sg_host_turn_off() to switch the host ON and OFF and @ref plugin_energy for more
- * info on DVFS.
- */
int sg_host_is_off(sg_host_t host)
{
int sg_host_is_off(sg_host_t host)
{
+ return not host->is_on();
}
/** @brief Get the properties of a host */
}
/** @brief Get the properties of a host */
{
return this->pimpl_->is_on();
}
{
return this->pimpl_->is_on();
}
-bool Link::is_off() const
-{
- return this->pimpl_->is_off();
-}
exception = nullptr;
// Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that
exception = nullptr;
// Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that
+ if (not host_->is_on())
this->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
/* destroy the blocking synchro if any */
this->throw_exception(std::make_exception_ptr(simgrid::kernel::context::StopRequest("host failed")));
/* destroy the blocking synchro if any */
smx_activity_t ActorImpl::sleep(double duration)
{
smx_activity_t ActorImpl::sleep(double duration)
{
+ if (not host_->is_on())
throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
+ if (not host->is_on()) {
XBT_WARN("Cannot launch actor '%s' on failed host '%s'", name.c_str(), host->get_cname());
return nullptr;
}
XBT_WARN("Cannot launch actor '%s' on failed host '%s'", name.c_str(), host->get_cname());
return nullptr;
}
sg_host_t host = sg_host_by_name(hostname);
XBT_DEBUG("Attach process %s on host '%s'", name, hostname);
sg_host_t host = sg_host_by_name(hostname);
XBT_DEBUG("Attach process %s on host '%s'", name, hostname);
+ if (not host->is_on()) {
XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname);
return nullptr;
}
XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname);
return nullptr;
}
simcall_execution_wait__set__result(simcall, exec->state_);
/* Fail the process if the host is down */
simcall_execution_wait__set__result(simcall, exec->state_);
/* Fail the process if the host is down */
- if (simcall->issuer->host_->is_off())
- simcall->issuer->context_->iwannadie = true;
- else
+ if (simcall->issuer->host_->is_on())
SIMIX_simcall_answer(simcall);
SIMIX_simcall_answer(simcall);
+ else
+ simcall->issuer->context_->iwannadie = true;
}
simcall->issuer->waiting_synchro = nullptr;
}
simcall->issuer->waiting_synchro = nullptr;
- if (simcall->issuer->host_->is_off())
- simcall->issuer->context_->iwannadie = true;
- else
+ if (simcall->issuer->host_->is_on())
SIMIX_simcall_answer(simcall);
SIMIX_simcall_answer(simcall);
+ else
+ simcall->issuer->context_->iwannadie = true;
/* Check out for errors */
/* Check out for errors */
- if (simcall->issuer->host_->is_off()) {
+ if (not simcall->issuer->host_->is_on()) {
simcall->issuer->context_->iwannadie = true;
simcall->issuer->exception =
std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
simcall->issuer->context_->iwannadie = true;
simcall->issuer->exception =
std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
- if (simcall->issuer->host_->is_off())
- simcall->issuer->context_->iwannadie = true;
- else
+ if (simcall->issuer->host_->is_on())
SIMIX_simcall_answer(simcall);
SIMIX_simcall_answer(simcall);
+ else
+ simcall->issuer->context_->iwannadie = true;
void LoadBalancer::run()
{
simgrid::s4u::Engine* engine = simgrid::s4u::Engine::get_instance();
void LoadBalancer::run()
{
simgrid::s4u::Engine* engine = simgrid::s4u::Engine::get_instance();
- std::vector<simgrid::s4u::Host*> available_hosts = engine->get_filtered_hosts([](simgrid::s4u::Host* host) {
- return not host->is_off();
- });
+ std::vector<simgrid::s4u::Host*> available_hosts =
+ engine->get_filtered_hosts([](simgrid::s4u::Host* host) { return host->is_on(); });
xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
// TODO: Account for daemon background load (-> use especially the availability file)
xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
// TODO: Account for daemon background load (-> use especially the availability file)
void StorageImpl::turn_on()
{
void StorageImpl::turn_on()
{
Resource::turn_on();
s4u::Storage::on_state_change(this->piface_);
}
Resource::turn_on();
s4u::Storage::on_state_change(this->piface_);
}
xbt_assert(get_core_count() == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
xbt_assert(get_core_count() == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
/** @brief Start a new execution on this CPU lasting @param size flops and using one core */
CpuAction* CpuCas01::execution_start(double size)
{
/** @brief Start a new execution on this CPU lasting @param size flops and using one core */
CpuAction* CpuCas01::execution_start(double size)
{
- return new CpuCas01Action(get_model(), size, is_off(), speed_.scale * speed_.peak, get_constraint());
+ return new CpuCas01Action(get_model(), size, not is_on(), speed_.scale * speed_.peak, get_constraint());
}
CpuAction* CpuCas01::execution_start(double size, int requested_cores)
{
}
CpuAction* CpuCas01::execution_start(double size, int requested_cores)
{
- return new CpuCas01Action(get_model(), size, is_off(), speed_.scale * speed_.peak, get_constraint(), requested_cores);
+ return new CpuCas01Action(get_model(), size, not is_on(), speed_.scale * speed_.peak, get_constraint(),
+ requested_cores);
}
CpuAction* CpuCas01::sleep(double duration)
}
CpuAction* CpuCas01::sleep(double duration)
duration = std::max(duration, sg_surf_precision);
XBT_IN("(%s,%g)", get_cname(), duration);
duration = std::max(duration, sg_surf_precision);
XBT_IN("(%s,%g)", get_cname(), duration);
- CpuCas01Action* action = new CpuCas01Action(get_model(), 1.0, is_off(), speed_.scale * speed_.peak, get_constraint());
+ CpuCas01Action* action =
+ new CpuCas01Action(get_model(), 1.0, not is_on(), speed_.scale * speed_.peak, get_constraint());
// FIXME: sleep variables should not consume 1.0 in System::expand()
action->set_max_duration(duration);
// FIXME: sleep variables should not consume 1.0 in System::expand()
action->set_max_duration(duration);
} else if (event == state_event_) {
if (value > 0) {
} else if (event == state_event_) {
if (value > 0) {
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
-CpuTiAction::CpuTiAction(CpuTi* cpu, double cost) : CpuAction(cpu->get_model(), cost, cpu->is_off()), cpu_(cpu)
+CpuTiAction::CpuTiAction(CpuTi* cpu, double cost) : CpuAction(cpu->get_model(), cost, not cpu->is_on()), cpu_(cpu)
{
cpu_->set_modified(true);
}
{
cpu_->set_modified(true);
}
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->get_cname(), dst->get_cname());
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->get_cname(), dst->get_cname());
- bool failed = std::any_of(route.begin(), route.end(), [](const LinkImpl* link) { return link->is_off(); });
+ bool failed = std::any_of(route.begin(), route.end(), [](const LinkImpl* link) { return not link->is_on(); });
if (cfg_crosstraffic) {
dst->route_to(src, back_route, nullptr);
if (not failed)
if (cfg_crosstraffic) {
dst->route_to(src, back_route, nullptr);
if (not failed)
- failed = std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return link->is_off(); });
+ failed =
+ std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return not link->is_on(); });
}
NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);
}
NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);
void LinkImpl::turn_on()
{
void LinkImpl::turn_on()
{
Resource::turn_on();
s4u::Link::on_state_change(this->piface_);
}
Resource::turn_on();
s4u::Link::on_state_change(this->piface_);
}
while (cnst != nullptr) {
i++;
void* constraint_id = cnst->get_id();
while (cnst != nullptr) {
i++;
void* constraint_id = cnst->get_id();
- if (static_cast<simgrid::kernel::resource::Resource*>(constraint_id)->is_off()) {
+ if (not static_cast<simgrid::kernel::resource::Resource*>(constraint_id)->is_on()) {
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(kernel::resource::Action::State::FAILED);
break;
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(kernel::resource::Action::State::FAILED);
break;
} else if (triggered == state_event_) {
if (value > 0) {
} else if (triggered == state_event_) {
if (value > 0) {
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
XBT_VERB("Restart processes on host %s", get_host()->get_cname());
get_host()->turn_on();
}
StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
{
StorageAction* StorageN11::io_start(sg_size_t size, s4u::Io::OpType type)
{
- return new StorageN11Action(get_model(), size, is_off(), this, type);
+ return new StorageN11Action(get_model(), size, not is_on(), this, type);
}
StorageAction* StorageN11::read(sg_size_t size)
{
}
StorageAction* StorageN11::read(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, is_off(), this, s4u::Io::OpType::READ);
+ return new StorageN11Action(get_model(), size, not is_on(), this, s4u::Io::OpType::READ);
}
StorageAction* StorageN11::write(sg_size_t size)
{
}
StorageAction* StorageN11::write(sg_size_t size)
{
- return new StorageN11Action(get_model(), size, is_off(), this, s4u::Io::OpType::WRITE);
+ return new StorageN11Action(get_model(), size, not is_on(), this, s4u::Io::OpType::WRITE);