-/* Copyright (c) 2012. The SimGrid Team.
+/* Copyright (c) 2012-2015. The SimGrid Team.
* All rights reserved. */
/* 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. */
+
#include "tracker.h"
-#include <msg/msg.h>
+#include <simgrid/msg.h>
#include <xbt/RngStream.h>
static void task_free(void *data);
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_tracker,
- "Messages specific for the tracker");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_tracker, "Messages specific for the tracker");
/**
* Tracker main function
* @param argc number of arguments
{
int i;
- RngStream stream = MSG_host_get_data(MSG_host_self());
-
+ 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]);
+ double deadline = xbt_str_parse_double(argv[1],"Invalid deadline: %s");
xbt_assert(deadline > 0, "Wrong deadline supplied");
//Building peers array
xbt_dynar_t peers_list = xbt_dynar_new(sizeof(int), NULL);
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.
+ //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;
* @param issuer_host_name Hostname of the issuer. For debugging purposes
*/
tracker_task_data_t tracker_task_data_new(const char *issuer_host_name,
- const char *mailbox, int peer_id,
- int uploaded, int downloaded,
- int left)
+ const char *mailbox, int peer_id,
+ int uploaded, int downloaded,
+ int left)
{
tracker_task_data_t task = xbt_new(s_tracker_task_data_t, 1);