s_finger_t *fingers; // finger table, of size nb_bits (fingers[0] is my successor)
int pred_id; // predecessor id
s_finger_t *fingers; // finger table, of size nb_bits (fingers[0] is my successor)
int pred_id; // predecessor id
int next_finger_to_fix; // index of the next finger to fix in fix_fingers()
msg_comm_t comm_receive; // current communication to receive
xbt_dynar_t comms; // current communications being sent
int next_finger_to_fix; // index of the next finger to fix in fix_fingers()
msg_comm_t comm_receive; // current communication to receive
xbt_dynar_t comms; // current communications being sent
int request_id; // id paramater (used by some types of tasks)
int request_finger; // finger parameter (used by some types of tasks)
int answer_id; // answer (used by some types of tasks)
int request_id; // id paramater (used by some types of tasks)
int request_finger; // finger parameter (used by some types of tasks)
int answer_id; // answer (used by some types of tasks)
const char* issuer_host_name; // used for logging
} s_task_data_t, *task_data_t;
const char* issuer_host_name; // used for logging
} s_task_data_t, *task_data_t;
static void chord_initialize(void);
static int normalize(int id);
static int is_in_interval(int id, int start, int end);
static void chord_initialize(void);
static int normalize(int id);
static int is_in_interval(int id, int start, int end);
static void task_data_destroy(task_data_t task_data);
static void print_finger_table(node_t node);
static void set_finger(node_t node, int finger_index, int id);
static void task_data_destroy(task_data_t task_data);
static void print_finger_table(node_t node);
static void set_finger(node_t node, int finger_index, int id);
node->last_change_date = MSG_get_clock();
DEBUG2("My new finger #%d is %d", finger_index, id);
}
node->last_change_date = MSG_get_clock();
DEBUG2("My new finger #%d is %d", finger_index, id);
}
node.next_finger_to_fix = 0;
node.comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
node.fingers = xbt_new0(s_finger_t, nb_bits);
node.last_change_date = init_time;
for (i = 0; i < nb_bits; i++) {
node.next_finger_to_fix = 0;
node.comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
node.fingers = xbt_new0(s_finger_t, nb_bits);
node.last_change_date = init_time;
for (i = 0; i < nb_bits; i++) {
int closest = closest_preceding_node(node, task_data->request_id);
DEBUG2("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
task_data->request_id, closest);
int closest = closest_preceding_node(node, task_data->request_id);
DEBUG2("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
task_data->request_id, closest);
comm = MSG_task_isend(task, mailbox);
xbt_dynar_push(node->comms, &comm);
xbt_free(mailbox);
comm = MSG_task_isend(task, mailbox);
xbt_dynar_push(node->comms, &comm);
xbt_free(mailbox);
task_data_t req_data = xbt_new0(s_task_data_t, 1);
req_data->type = TASK_FIND_SUCCESSOR;
req_data->request_id = id;
task_data_t req_data = xbt_new0(s_task_data_t, 1);
req_data->type = TASK_FIND_SUCCESSOR;
req_data->request_id = id;
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
// send a "Find Successor" request to ask_to_id
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
// send a "Find Successor" request to ask_to_id
task_data_t req_data = xbt_new0(s_task_data_t, 1);
req_data->type = TASK_GET_PREDECESSOR;
task_data_t req_data = xbt_new0(s_task_data_t, 1);
req_data->type = TASK_GET_PREDECESSOR;
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
// send a "Get Predecessor" request to ask_to_id
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
// send a "Get Predecessor" request to ask_to_id
req_data->type = TASK_NOTIFY;
req_data->request_id = predecessor_candidate_id;
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
req_data->type = TASK_NOTIFY;
req_data->request_id = predecessor_candidate_id;
req_data->issuer_host_name = MSG_host_get_name(MSG_host_self());
// send a "Notify" request to notify_id
m_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, req_data);
DEBUG2("Sending a 'Notify' request (task %p) to %d", task, notify_id);
// send a "Notify" request to notify_id
m_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, req_data);
DEBUG2("Sending a 'Notify' request (task %p) to %d", task, notify_id);
msg_comm_t comm = MSG_task_isend(task, mailbox);
xbt_dynar_push(node->comms, &comm);
msg_comm_t comm = MSG_task_isend(task, mailbox);
xbt_dynar_push(node->comms, &comm);