Esempio n. 1
0
int job_requester(int argc, char* argv[]){
	/**
	   @type simgrid process (run on all tiers)
		Every @timeout checks amount of free (non running) cores.
		If this amount is greater than some N then it sends a job request
		 to scheduler to get new batch of jobs. 

         Simgrid process parameters:
         --------------------------
         None		 
	*/
    std::string host_name = MSG_host_get_name(MSG_host_self());
    std::string CERN = "CERN";
    msg_task_t task = NULL;
    double timeout = 1000;
    long freeCoreAmount;
    int fullCoreAmount = MSG_host_get_core_number(MSG_host_self());
    MSG_process_sleep(0.01);

    while (1){
        freeCoreAmount = fullCoreAmount - xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "activeCore"), "error") -
                xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "corruptedCore"), "error");

        MSG_sem_acquire(sem_requester);
        if (GLOBAL_QUEUE->empty()){
            MSG_sem_release(sem_requester);
            break;
        }

        if (freeCoreAmount > 0){
            JobBatchRequest* jobRequest = new JobBatchRequest;
            jobRequest->coreAmount = freeCoreAmount;

            task = MSG_task_create("request", 0.0, MESSAGES_SIZE, jobRequest);

            plusLinkCounter(host_name, CERN);
            msg_error_t err = MSG_task_send(task, "scheduler");

            switch(err){
                case MSG_OK:
                    minusLinkCounter(host_name, CERN);
                    break;
                case MSG_TRANSFER_FAILURE:
                    minusLinkCounter(host_name, CERN);
                    MSG_task_destroy(task);
                    task = NULL;
                    break;
                case MSG_HOST_FAILURE:
                    MSG_task_destroy(task);
                    task = NULL;
                    break;
            }
        }else MSG_sem_release(sem_requester);

        MSG_process_sleep(timeout);
    }
    return 0;
}
Esempio n. 2
0
/**
 * \brief Returns the value of a host property.
 * \param L a Lua state
 * \return number of values returned to Lua
 *
 * - Argument 1 (host): a host
 * - Argument 2 (string): name of the property to get
 * - Return value (string): the value of this property
 */
static int l_host_get_property_value(lua_State * L)
{
  msg_host_t ht = sglua_check_host(L, 1);
  const char *prop = luaL_checkstring(L, 2);
  lua_pushstring(L,MSG_host_get_property_value(ht,prop));
  return 1;
}
Esempio n. 3
0
static int onoff(int argc, char *argv[]) {
  msg_host_t host1 = MSG_host_by_name("MyHost1");

  XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state"));
  XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_shutdown(host1);
  XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  XBT_INFO("Sleep for 10 seconds");
  MSG_process_sleep(10);
  XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  simulate_bootup(host1);
  XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
     MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1));

  return 0;
}
Esempio n. 4
0
/**
 * Tracker main function
 * @param argc number of arguments
 * @param argv arguments
 */
int tracker(int argc, char *argv[])
{
    int i;

    RngStream stream = (RngStream) MSG_host_get_property_value(MSG_host_self(), "stream");
    //Checking arguments
    xbt_assert(argc == 2, "Wrong number of arguments for the tracker.");
    //Retrieving end time
    double deadline = atof(argv[1]);
    xbt_assert(deadline > 0, "Wrong deadline supplied");
    //Building peers array
    xbt_dynar_t peers_list = xbt_dynar_new(sizeof(int), NULL);

    XBT_INFO("Tracker launched.");

    msg_comm_t comm_received = NULL;
    msg_task_t task_received = NULL;

    while (MSG_get_clock() < deadline) {
        if (comm_received == NULL) {
            comm_received = MSG_task_irecv(&task_received, TRACKER_MAILBOX);
        }
        if (MSG_comm_test(comm_received)) {
            //Check for correct status
            if (MSG_comm_get_status(comm_received) == MSG_OK) {
                //Retrieve the data sent by the peer.
                tracker_task_data_t data = MSG_task_get_data(task_received);
                //Add the peer to our peer list.
                if (!is_in_list(peers_list, data->peer_id)) {
                    xbt_dynar_push_as(peers_list, int, data->peer_id);
                }
                //Sending peers to the peer
                int next_peer;
                int peers_length = xbt_dynar_length(peers_list);
                for (i = 0; i < MAXIMUM_PAIRS && i < peers_length; i++) {
                    do {
                        next_peer =
                            xbt_dynar_get_as(peers_list,
                                             RngStream_RandInt(stream, 0, peers_length - 1),
                                             int);
                    } while (is_in_list(data->peers, next_peer));
                    xbt_dynar_push_as(data->peers, int, next_peer);
                }
                //setting the interval
                data->interval = TRACKER_QUERY_INTERVAL;
                //sending the task back to the peer.
                MSG_task_dsend(task_received, data->mailbox, task_free);
                //destroy the communication.
            }
            MSG_comm_destroy(comm_received);
            comm_received = NULL;
            task_received = NULL;
        } else {
Esempio n. 5
0
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
  msg_host_t host = jhost_get_native(env, jhost);

  if (!host) {
    jxbt_throw_notbound(env, "host", jhost);
    return nullptr;
  }
  const char *name = env->GetStringUTFChars((jstring) jname, 0);

  const char *property = MSG_host_get_property_value(host, name);
  if (!property) {
    return nullptr;
  }

  jobject jproperty = env->NewStringUTF(property);

  env->ReleaseStringUTFChars((jstring) jname, name);

  return jproperty;
}
Esempio n. 6
0
/** \ingroup m_host_management
 *
 * \brief Return the user data of a #msg_host_t.
 *
 * This functions checks whether \a host is a valid pointer or not and return
   the user data associated to \a host if it is possible.
 */
void *MSG_host_get_data(msg_host_t host)
{
  return (void *)MSG_host_get_property_value(host, msg_data);
}