static void s_event(s_state *ns, tw_bf *bf, s_msg *m, tw_lp *lp){ assert(m->h.magic == s_magic); switch(m->h.event_type){ case S_KICKOFF: ; msg_header h; msg_set_header(s_magic, S_ALLOC_ACK, lp->gid, &h); resource_lp_get(bsize, 0, lp, CODES_MCTX_DEFAULT, 0, &h, &ns->cb); break; case S_ALLOC_ACK: if (m->c.ret == 0){ ns->mem += bsize; m->mem_max_prev = ns->mem_max; ns->mem_max = maxu64(ns->mem, ns->mem_max); msg_header h; msg_set_header(s_magic, S_ALLOC_ACK, lp->gid, &h); resource_lp_get(bsize, 0, lp, CODES_MCTX_DEFAULT, 0, &h, &ns->cb); break; } /* else fall into the free stmt */ case S_FREE: resource_lp_free(bsize, lp, CODES_MCTX_DEFAULT); ns->mem -= bsize; if (ns->mem > 0){ tw_event *e = codes_event_new(lp->gid, codes_local_latency(lp), lp); s_msg *m = tw_event_data(e); msg_set_header(s_magic, S_FREE, lp->gid, &m->h); tw_event_send(e); } break; } }
/* handle recving ack */ static void handle_ack_event( svr_state * ns, tw_bf * b, svr_msg * m, tw_lp * lp) { (void)b; if (LSM_DEBUG) printf("handle_ack_event(), lp %llu.\n", (unsigned long long)lp->gid); if(ns->msg_sent_count < NUM_REQS) { /* send another request */ msg_header h; msg_set_header(magic, ACK, lp->gid, &h); lsm_io_event("test", 0, 0, PAYLOAD_SZ, LSM_WRITE_REQUEST, 0.0, lp, CODES_MCTX_DEFAULT, 0, &h, &cb_info); ns->msg_sent_count++; m->incremented_flag = 1; // make a parallel dummy request to test out sched h.event_type = LOCAL; lsm_io_event("test", 0, 0, PAYLOAD_SZ, LSM_WRITE_REQUEST, 2.0, lp, CODES_MCTX_DEFAULT, 1, &h, &cb_info); } else { m->incremented_flag = 0; } return; }
/** * Initialize the LPs with BB capacity and cluster flag then kickoff * @Params ns node state * m message * lp LP */ void node_lp_init(node_state * ns, tw_lp * lp) { burst_buffer_capacity = ((long) (burst_buffer_max_capacity)) * 1000000000; //burst_buffer_capacity = ((long) (burst_buffer_max_capacity))*10; //printf("Burst Buffer Capacity:%li\n",burst_buffer_capacity); printf("In node_lp_init\n"); ns->num_processed = 0; // nodes are addressed in their logical id space (0...num_client_nodes-1 and // 0...num_svr_nodes-1, respectively). LPs are computed upon use with // model-net, other events ns->id_clust = codes_mapping_get_lp_relative_id(lp->gid, 1, 0); int id_all = codes_mapping_get_lp_relative_id(lp->gid, 0, 0); // track which cluster we're in ns->is_in_client = (id_all < num_client_nodes); ns->is_in_server = (id_all < (num_svr_nodes + num_client_nodes) && (id_all >= num_client_nodes)); ns->is_in_bb = (id_all < (num_svr_nodes + num_client_nodes + num_burst_buffer_nodes) && (id_all >= num_svr_nodes + num_client_nodes)); printf("is_in_client=%d\nis_in_svr=%d\nis_in_bb=%d\n", ns->is_in_client, ns->is_in_server, ns->is_in_bb); printf("id_all= %d\nnum_client_nodes= %d\n", id_all, num_client_nodes); // send a self kickoff event tw_event *e = codes_event_new(lp->gid, codes_local_latency(lp), lp); node_msg *m = tw_event_data(e); msg_set_header(node_magic, NODE_KICKOFF, lp->gid, &m->h); tw_event_send(e); }
/** * IO node send write request to Burst Buffer * @Params ns node state * m message * lp LP */ void io_node_send_request(node_state * ns, node_msg * m, tw_lp * lp) { printf("In Server send REQ\n"); // check that we received the msg from the expected source // printf("In handle_node_recv_req num_svr_nodes is %d\n",num_svr_nodes); assert(m->id_clust_src % num_svr_nodes == ns->id_clust); // setup the response message through the forwarder forwarder_msg m_fwd; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; m_fwd.dest_node_clust_id = (m->id_clust_src % num_svr_nodes) % num_burst_buffer_nodes; //m_fwd.dest_node_clust_id = m->id_clust_src; m_fwd.node_event_type = NODE_RECV_req; //TO CHANGE WITH BB //m_fwd.node_event_type = NODE_RECV_ack; // compute the dest forwarder index, again using a simple modulus //int dest_fwd_id = ns->id_clust % num_burst_buffer_forwarders; int dest_fwd_id = ns->id_clust % num_svr_forwarders; tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative(dest_fwd_id, "svr_FORWARDERS", "forwarder", NULL, 0); ns->pvfs_ts_remote_write += pvfs_tp_write_local_mu; model_net_event_annotated(net_id_svr, "svr", "req", dest_fwd_lpid, pvfs_file_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); }
/** * Burst Buffer send ACK (read operation) to IO node * @Params ns node state * m message * lp LP */ void burst_buffer_send_ack(node_state * ns, node_msg * m, tw_lp * lp) { printf("In Burst Buffer send ACK\n"); // check that we received the msg from the expected source assert(m->id_clust_src % num_burst_buffer_nodes == ns->id_clust); // setup the response message through the forwarder forwarder_msg m_fwd; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; m_fwd.dest_node_clust_id = (m->id_clust_src % num_burst_buffer_nodes) % num_svr_nodes; m_fwd.node_event_type = NODE_RECV_ack; // compute the dest forwarder index, again using a simple modulus int dest_fwd_id = ns->id_clust % num_svr_forwarders; // as the relative forwarder IDs are with respect to groups, the group // name must be used tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative(dest_fwd_id, "bb_FORWARDERS", "forwarder", NULL, 0); ns->bb_cur_capacity -= pvfs_file_sz; model_net_event_annotated(net_id_svr, "bb", "ack", dest_fwd_lpid, pvfs_file_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); }
/** * Compute node send write request to IO node * @Params ns node state * m message * lp LP */ void compute_node_send_request(node_state * ns, node_msg * m, tw_lp * lp) { printf("In handle_node_next\n"); // we must be in cluster client for this function assert(ns->is_in_client); // generate a message to send to the forwarder forwarder_msg m_fwd; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; // compute the destination in cluster svr to req based on a simple modulo // of the logical indexes //printf("num_svr_nodes is %d\n",num_svr_nodes); m_fwd.dest_node_clust_id = ns->id_clust % num_svr_nodes; //printf("dest_node_clust_id is %d\n",m_fwd.dest_node_clust_id); m_fwd.node_event_type = NODE_RECV_req; // compute the dest forwarder index, again using a simple modulo //printf("num_client_forwarders is %d\n",num_client_forwarders); int dest_fwd_id = ns->id_clust % num_client_forwarders; // printf("dest_node_fwd_id is %d\n",dest_fwd_id); // as the relative forwarder IDs are with respect to groups, the group // name must be used tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative(dest_fwd_id, "client_FORWARDERS", "forwarder", NULL, 0); //printf("dest_fwd_lpid is %d\n",(int)dest_fwd_lpid); // as cluster nodes have only one network type (+ annotation), no need to // use annotation-specific messaging model_net_event_annotated(net_id_client, "client", "req", dest_fwd_lpid, payload_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); }
/* handle initial event */ static void handle_kickoff_event( svr_state * ns, tw_bf * b, svr_msg * m, tw_lp * lp) { assert(ns->server_idx < NUM_SERVERS-1); // same msg header for all svr_msg m_remote; msg_set_header(666, RECV, lp->gid, &m_remote.h); m_remote.src_svr_idx = ns->server_idx; // dest LP is the same - the last server tw_lpid dest = (NUM_SERVERS-1) * 2; MN_START_SEQ(); for (int i = 0; i < NUM_PRIOS; i++){ m_remote.msg_prio = ns->random_order[i]; //printf("%lu: sending message with prio %d to %lu\n", lp->gid, //m_remote.msg_prio, dest); model_net_set_msg_param(MN_MSG_PARAM_SCHED, MN_SCHED_PARAM_PRIO, (void*) &m_remote.msg_prio); model_net_event(net_id, "test", dest, PAYLOAD_SZ, 0.0, sizeof(svr_msg), &m_remote, 0, NULL, lp); } MN_END_SEQ(); }
static void svr_init( svr_state * ns, tw_lp * lp) { ns->server_idx = lp->gid / 2; if (ns->server_idx < NUM_SERVERS-1){ for (int i = 0; i < NUM_PRIOS; i++){ ns->random_order[i] = -1; } for (int i = 0; i < NUM_PRIOS; i++){ for (;;){ int idx = tw_rand_integer(lp->rng, 0, NUM_PRIOS-1); // not sure whether rand_integer is inclusive or not... assert(idx < NUM_PRIOS); if (ns->random_order[idx] == -1){ ns->random_order[idx] = i; break; } } } tw_event *e = codes_event_new(lp->gid, codes_local_latency(lp), lp); svr_msg * m = tw_event_data(e); msg_set_header(666, KICKOFF, lp->gid, &m->h); tw_event_send(e); } else { memset(ns->num_recv, 0, NUM_SERVERS*sizeof(*ns->num_recv)); } }
void handle_forwarder_recv(forwarder_state * ns, forwarder_msg * m, tw_lp * lp) { //printf("In handle_forwarder_recv\n"); // compute the node to relay the message to const char * dest_group; const char * annotation; char * category; int net_id; if (ns->is_in_client) { dest_group = "client_CLUSTER"; annotation = "client"; category = "ack"; net_id = net_id_client; } else if (ns->is_in_server) { if (m->node_event_type == NODE_RECV_req) { dest_group = "svr_CLUSTER"; annotation = "svr"; category = "req"; net_id = net_id_svr; } else if (m->node_event_type == NODE_RECV_ack) { dest_group = "svr_CLUSTER"; annotation = "svr"; category = "ack"; net_id = net_id_svr; } } else if (ns->is_in_bb) { if (m->node_event_type == NODE_RECV_req) { dest_group = "bb_CLUSTER"; annotation = "bb"; category = "req"; net_id = net_id_bb; } else if (m->node_event_type == NODE_RECV_ack) { dest_group = "bb_CLUSTER"; annotation = "bb"; category = "ack"; net_id = net_id_bb; } } else { dest_group = "storage_CLUSTER"; annotation = "str"; category = "req"; net_id = net_id_storage; } tw_lpid dest_lpid = codes_mapping_get_lpid_from_relative( m->dest_node_clust_id, dest_group, "node", NULL, 0); node_msg m_node; msg_set_header(node_magic, m->node_event_type, lp->gid, &m_node.h); m_node.id_clust_src = m->src_node_clust_id; // here, we need to use the client or svr cluster's internal network, so we use // the annotated version of model_net_event model_net_event_annotated(net_id, annotation, category, dest_lpid, payload_sz, 0.0, sizeof(m_node), &m_node, 0, NULL, lp); ns->fwd_forwarder_count++; }
void handle_forwarder_fwd(forwarder_state * ns, forwarder_msg * m, tw_lp * lp) { // printf("In handle_forwarder_fwd\n"); // compute the forwarder lpid to forward to int mod; const char * dest_group; char * category; if (ns->is_in_client) { //printf("Test Client forwarder \n"); mod = num_svr_forwarders; dest_group = "svr_FORWARDERS"; category = "req"; } else if (ns->is_in_server) { if (m->node_event_type == NODE_RECV_ack) { //printf("Test Server forwarder ACK\n"); mod = num_client_forwarders; dest_group = "client_FORWARDERS"; category = "ack"; } else if (m->node_event_type == NODE_RECV_req) { //printf("Test Server forwarder REQ\n"); mod = num_burst_buffer_forwarders; dest_group = "bb_FORWARDERS"; category = "req"; } } else if (ns->is_in_bb) { if (m->node_event_type == NODE_RECV_ack) { //printf("Test Burst Buffer forwarder ACK\n"); mod = num_svr_forwarders; dest_group = "svr_FORWARDERS"; category = "ack"; } else if (m->node_event_type == NODE_RECV_req) { //printf("Test Burst Buffer forwarder REQ\n"); mod = num_storage_forwarders; dest_group = "storage_FORWARDERS"; category = "req"; } } else { //printf("Test Storage forwarder ACK\n"); mod = num_burst_buffer_forwarders; dest_group = "bb_FORWARDERS"; category = "ack"; } // compute the ROSS id corresponding to the dest forwarder //printf("mod is %d\n",mod); tw_lpid dest_lpid = codes_mapping_get_lpid_from_relative(ns->id % mod, dest_group, "forwarder", NULL, 0); forwarder_msg m_fwd = *m; msg_set_header(forwarder_magic, FORWARDER_RECV, lp->gid, &m_fwd.h); // here, we need to use the unannotated forwarding network, so we // use the annotation version of model_net_event model_net_event_annotated(net_id_forwarding, NULL, category, dest_lpid, payload_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); ns->fwd_node_count++; }
static void s_init(s_state *ns, tw_lp *lp){ ns->mem = 0; ns->mem_max = 0; INIT_CODES_CB_INFO(&ns->cb, s_msg, h, tag, c); ns->id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0); tw_event *e = codes_event_new(lp->gid, codes_local_latency(lp), lp); s_msg *m = tw_event_data(e); msg_set_header(s_magic, S_KICKOFF, lp->gid, &m->h); tw_event_send(e); }
/** * IO node send ACK (read operation) to compute node * @Params ns node state * m message * lp LP */ void io_node_send_ack(node_state * ns, node_msg * m, tw_lp * lp) { printf("In Server send ACK\n"); // setup the response message through the forwarder forwarder_msg m_fwd; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; m_fwd.dest_node_clust_id = ns->id_clust % num_client_nodes; m_fwd.node_event_type = NODE_RECV_ack; // compute the dest forwarder index, again using a simple modulus int dest_fwd_id = ns->id_clust % num_svr_forwarders; // as the relative forwarder IDs are with respect to groups, the group // name must be used tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative(dest_fwd_id, "svr_FORWARDERS", "forwarder", NULL, 0); ns->pvfs_ts_remote_write += pvfs_tp_write_local_mu; model_net_event_annotated(net_id_svr, "svr", "ack", dest_fwd_lpid, payload_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); }
/* handle initial event */ static void handle_kickoff_event( svr_state * ns, tw_bf * b, svr_msg * m, tw_lp * lp) { (void)b; (void)m; double rate; double seek; if (LSM_DEBUG) printf("handle_kickoff_event(), lp %llu.\n", (unsigned long long)lp->gid); /* record when transfers started on this server */ ns->start_ts = tw_now(lp); /* these are derived from the config file... */ rate = 50.0; seek = 2000.0; printf("server %llu : disk_rate:%lf disk_seek:%lf\n", (unsigned long long)lp->gid, rate, seek); msg_header h; msg_set_header(magic, ACK, lp->gid, &h); lsm_io_event("test", 0, 0, PAYLOAD_SZ, LSM_WRITE_REQUEST, 1.0, lp, CODES_MCTX_DEFAULT, 0, &h, &cb_info); ns->msg_sent_count++; // make a parallel dummy request to test out sched h.event_type = LOCAL; lsm_io_event("test", 0, 0, PAYLOAD_SZ, LSM_WRITE_REQUEST, 2.0, lp, CODES_MCTX_DEFAULT, 1, &h, &cb_info); }
static void svr_init( svr_state * ns, tw_lp * lp) { tw_event *e; svr_msg *m; tw_stime kickoff_time; memset(ns, 0, sizeof(*ns)); /* each server sends a dummy event to itself that will kick off the real * simulation */ /* skew each kickoff event slightly to help avoid event ties later on */ kickoff_time = g_tw_lookahead + tw_rand_unif(lp->rng); e = tw_event_new(lp->gid, kickoff_time, lp); m = tw_event_data(e); msg_set_header(magic, KICKOFF, lp->gid, &m->h); tw_event_send(e); return; }
int msg_handle_multiple_values (sip_t * sip, char *hname, char *hvalue) { int i; char *ptr; /* current location of the search */ char *comma; /* This is the separator we are elooking for */ char *beg; /* beg of a header */ char *end; /* end of a header */ char *quote1; /* first quote of a pair of quotes */ char *quote2; /* second quuote of a pair of quotes */ beg = hvalue; end = NULL; ptr = hvalue; if (hvalue == NULL) { i = msg_set_header (sip, hname, hvalue); if (i == -1) return -1; return 0; } comma = strchr (ptr, ','); stolowercase (hname); if (comma == NULL || (strncmp (hname, "date", 4) == 0 && strlen (hname) == 4 ) || strncmp (hname, "organization", 12) == 0 || (strncmp (hname, "to", 2) == 0 && strlen (hname) == 2) || (strncmp (hname, "from", 4) == 0 && strlen (hname) == 4) /* AMD: BUG fix */ || strncmp (hname, "call-id", 7) == 0 || (strncmp (hname, "cseq", 4) == 0 && strlen (hname) == 4) /* AMD: BUG fix */ || strncmp (hname, "subject", 7) == 0 || strncmp (hname, "user-agent", 10) == 0 || strncmp (hname, "server", 6) == 0 || strncmp (hname, "www-authenticate", 16) == 0 /* AMD: BUG fix */ || strncmp (hname, "authentication-info", 19) == 0 || strncmp (hname, "proxy-authenticate", 20) == 0 || strncmp (hname, "proxy-authorization", 19) == 0 || strncmp (hname, "proxy-authentication-info", 25) == 0 /* AMD: BUG fix */ || strncmp (hname, "authorization", 13) == 0) /* there is no multiple header! likely */ /* to happen most of the time... */ /* or hname is a TEXT-UTF8-TRIM and may */ /* contain a comma. this is not a separator */ /* THIS DOES NOT WORK FOR UNKNOWN HEADER!!!! */ { i = msg_set_header (sip, hname, hvalue); if (i == -1) return -1; return 0; } quote2 = NULL; while (comma != NULL) { quote1 = quote_find (ptr); if (quote1 != NULL) { quote2 = quote_find (quote1 + 1); if (quote2 == NULL) return -1; /* quotes comes by pair */ ptr = quote2 + 1; } if ((quote1 == NULL) || (quote1 > comma)) { end = comma; comma = strchr (comma + 1, ','); ptr = comma + 1; } else if ((quote1 < comma) && (quote2 < comma)) { /* quotes are located before the comma, */ /* continue the search for next quotes */ ptr = quote2 + 1; } else if ((quote1 < comma) && (comma < quote2)) { /* if comma is inside the quotes... */ /* continue with the next comma. */ ptr = quote2 + 1; comma = strchr (ptr, ','); if (comma == NULL) /* this header last at the end of the line! */ { /* this one does not need an allocation... */ if (strlen (beg) < 2) return 0; /* empty header */ sclrspace (beg); i = msg_set_header (sip, hname, beg); if (i == -1) return -1; return 0; } } if (end != NULL) { char *avalue; if (end - beg + 1 < 2) return -1; avalue = (char *) smalloc (end - beg + 1); sstrncpy (avalue, beg, end - beg); sclrspace (avalue); /* really store the header in the sip structure */ i = msg_set_header (sip, hname, avalue); sfree (avalue); if (i == -1) return -1; beg = end + 1; end = NULL; if (comma == NULL) /* this header last at the end of the line! */ { /* this one does not need an allocation... */ if (strlen (beg) < 2) return 0; /* empty header */ sclrspace (beg); i = msg_set_header (sip, hname, beg); if (i == -1) return -1; return 0; } } } return -1; /* if comma is NULL, we should have already return 0 */ }
/** * Burst Buffer send write request to Storage node if it's full * Otherwise local write + write request to storage later * @Params ns node state * m message * lp LP */ void burst_bufer_send_request(node_state * ns, node_msg * m, tw_lp * lp) { assert(m->id_clust_src % num_burst_buffer_nodes == ns->id_clust); if (ns->bb_cur_capacity + pvfs_file_sz >= burst_buffer_capacity) { // if full send to storage node printf("In Burst Buffer send REQ to storage\n"); // setup the response message through the forwarder forwarder_msg m_fwd; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; m_fwd.dest_node_clust_id = (m->id_clust_src % num_burst_buffer_nodes) % num_storage_nodes; m_fwd.node_event_type = NODE_RECV_req; // compute the dest forwarder index, again using a simple modulus int dest_fwd_id = ns->id_clust % num_burst_buffer_forwarders; // as the relative forwarder IDs are with respect to groups, the group // name must be used tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative( dest_fwd_id, "bb_FORWARDERS", "forwarder", NULL, 0); ns->pvfs_ts_remote_write += pvfs_tp_write_local_mu; model_net_event_annotated(net_id_svr, "bb", "req", dest_fwd_lpid, pvfs_file_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); } else { // if enough room for local write printf("In Burst Buffer send ACK to Server and REQ to storage later\n"); forwarder_msg m_fwd; //send ack msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd.h); m_fwd.src_node_clust_id = ns->id_clust; m_fwd.dest_node_clust_id = (m->id_clust_src % num_burst_buffer_nodes) % num_svr_nodes; m_fwd.node_event_type = NODE_RECV_ack; // compute the dest forwarder index, again using a simple modulus int dest_fwd_id = ns->id_clust % num_svr_forwarders; // as the relative forwarder IDs are with respect to groups, the group // name must be used tw_lpid dest_fwd_lpid = codes_mapping_get_lpid_from_relative( dest_fwd_id, "bb_FORWARDERS", "forwarder", NULL, 0); ns->bb_ts_local_write += burst_buffer_local_mu; ns->bb_cur_capacity += pvfs_file_sz; model_net_event_annotated(net_id_svr, "bb", "ack", dest_fwd_lpid, pvfs_file_sz, 0.0, sizeof(m_fwd), &m_fwd, 0, NULL, lp); forwarder_msg m_fwd2; msg_set_header(forwarder_magic, FORWARDER_FWD, lp->gid, &m_fwd2.h); m_fwd2.src_node_clust_id = ns->id_clust; m_fwd2.dest_node_clust_id = (m->id_clust_src % num_burst_buffer_nodes) % num_storage_nodes; m_fwd2.node_event_type = NODE_RECV_req; // compute the dest forwarder index, again using a simple modulus int dest_fwd_id2 = ns->id_clust % num_burst_buffer_forwarders; tw_lpid dest_fwd_lpid2 = codes_mapping_get_lpid_from_relative( dest_fwd_id2, "bb_FORWARDERS", "forwarder", NULL, 0); ns->pvfs_ts_remote_write += pvfs_tp_write_local_mu; tw_stime offset = tw_rand_integer(lp->rng, 0.0, 5.0); model_net_event_annotated(net_id_svr, "bb", "req", dest_fwd_lpid2, pvfs_file_sz, offset, sizeof(m_fwd2), &m_fwd2, 0, NULL, lp); } }