void join_channel_done_illegal(struct dht_rpc * rpc, struct dht_group_msg_reply *reply, void * arg) { struct dht_group *group = arg; char *channel_name; unsigned int error_code; char *error_reason; if (reply == NULL) return; EVTAG_GET(reply, channel_name, &channel_name); EVTAG_GET(reply, error_code, &error_code); EVTAG_GET(reply, error_reason, &error_reason); fprintf(stderr, "%s: channel: %s -> %d - %s\n", dht_node_id_ascii(dht_myid(group->dht)), channel_name, error_code, error_reason); assert(error_code = ERR_ILLEGALNAME); event_loopexit(NULL); }
void privmsg_done(struct dht_rpc * rpc, struct dht_group_msg_reply *reply, void * arg) { struct dht_group *group = arg; char *channel_name; unsigned int error_code; char *error_reason; struct timeval tv; if (reply == NULL) return; CU_ASSERT(!EVTAG_GET(reply, channel_name, &channel_name)); CU_ASSERT(!EVTAG_GET(reply, error_code, &error_code)); CU_ASSERT(!EVTAG_GET(reply, error_reason, &error_reason)); fprintf(stderr, "%s: channel: %s -> %d - %s\n", dht_node_id_ascii(dht_myid(group->dht)), channel_name, error_code, error_reason); timerclear(&tv); tv.tv_usec = 500000L; event_once(-1, EV_TIMEOUT, part_cb, arg, &tv); }
void part_cb_done(struct dht_rpc * rpc, struct dht_group_msg_reply *reply, void * arg) { static int count; struct dht_group *group = arg; char *channel_name; unsigned int error_code; char *error_reason; CU_ASSERT(reply != NULL); EVTAG_GET(reply, channel_name, &channel_name); EVTAG_GET(reply, error_code, &error_code); EVTAG_GET(reply, error_reason, &error_reason); fprintf(stderr, "%s: channel: %s -> %d - %s\n", dht_node_id_ascii(dht_myid(group->dht)), channel_name, error_code, error_reason); if (++count == 2) { struct timeval tv; /* We have just two parts - so quit shortly after they * are done */ timerclear(&tv); tv.tv_sec = 5; /* exit the loop after 5 second */ event_loopexit(&tv); } }
int symlink_send_request(char *ip, int port, uint64_t parent_ino, uint64_t ino, const char *name, const char *path, struct file_stat *o_stat) { DBG(); struct symlink_request *req = symlink_request_new(); struct symlink_response *response = symlink_response_new(); EVTAG_ASSIGN(req, parent_ino, parent_ino); EVTAG_ASSIGN(req, ino, ino); EVTAG_ASSIGN(req, name, name); EVTAG_ASSIGN(req, path, path); /*int mid = get_mid_of_ino(parent_ino); */ /*struct machine * m = cluster_get_machine_by_mid(mid); */ rpc_grneral_request(ip, port, "/.rpc.rpc_symlink", req, (marshal_func) symlink_request_marshal, response, (unmarshal_func) symlink_response_unmarshal); int rst = response->rst_code; if (rst!=0){ logging(LOG_WARN, "symlink_send_request return rst != 0"); goto done; } struct file_stat *stat; EVTAG_GET(response, stat, &stat); file_stat_copy(o_stat, stat); done: symlink_request_free(req); symlink_response_free(response); return rst; }
void join_channel_done(struct dht_rpc * rpc, struct dht_group_msg_reply *reply, void * arg) { static int count; struct dht_group *group = arg; char *channel_name; unsigned int error_code; char *error_reason; if (reply == NULL) return; EVTAG_GET(reply, channel_name, &channel_name); EVTAG_GET(reply, error_code, &error_code); EVTAG_GET(reply, error_reason, &error_reason); fprintf(stderr, "%s: channel: %s -> %d - %s\n", dht_node_id_ascii(dht_myid(group->dht)), channel_name, error_code, error_reason); if (++count == 3) { char *message_one = "hello how are you? we have not seen you."; char *message_two = "do you know rlorp? but you are just here"; char *message_three = "i am not subscribed"; /* Time to sent a private message */ dht_group_privmsg(node[1], "niels", message_one, strlen(message_one) + 1, privmsg_done, node[1]); dht_group_privmsg(node[0], "niels", message_two, strlen(message_two) + 1, privmsg_done, node[0]); dht_group_privmsg(node[3], "niels", message_three, strlen(message_three) + 1, privmsg_done, node[3]); } }
int statfs_send_request(char *ip, int port, int *total_space, int *avail_space, int *inode_cnt) { DBG(); struct statfs_request *req = statfs_request_new(); struct statfs_response *response = statfs_response_new(); EVTAG_ASSIGN(req, nothing, 1); /*cluster_get_mds_arr(&mds, &mds_cnt); */ /*struct machine * m = cluster_get_machine_by_mid(mds[0]); // TODO: currently it's a random one */ rpc_grneral_request(ip, port, "/.rpc.rpc_statfs", req, (marshal_func) statfs_request_marshal, response, (unmarshal_func) statfs_response_unmarshal); EVTAG_GET(response, total_space, total_space); EVTAG_GET(response, avail_space, avail_space); EVTAG_GET(response, inode_cnt, inode_cnt); statfs_request_free(req); statfs_response_free(response); return 0; }