BurstFS_Server/burstfs_metadata.c
int meta_batch_get(int app_id, int client_id,\
		int thrd_id, int dbg_rank, char *shm_reqbuf, int num,\
			msg_meta_t* del_req_set) {
	cli_req_t *tmp_cli_req = (cli_req_t *) shm_reqbuf;

	int i, rc = 0;
	for (i = 0; i < num; i++) {
		burstfs_keys[2 * i]->fid = tmp_cli_req[i].fid;
		burstfs_keys[2 * i]->offset = tmp_cli_req[i].offset;
		burstfs_key_lens[2 * i] = sizeof(burstfs_key_t);
		burstfs_keys[2 * i + 1]->fid = tmp_cli_req[i].fid;
		burstfs_keys[2 * i + 1]->offset =\
				tmp_cli_req[i].offset + tmp_cli_req[i].length - 1;
		burstfs_key_lens[2 * i + 1] = sizeof(burstfs_key_t);

	}

	md->primary_index = burstfs_indexes[0];
	bgrm = mdhimBGet(md, md->primary_index, burstfs_keys, burstfs_key_lens, \
			2 * num, MDHIM_RANGE_BGET);

	int tot_num = 0;
    int dest_client, dest_app;
    burstfs_key_t *tmp_key;
    burstfs_val_t *tmp_val;

	bgrmp = bgrm;
	while (bgrmp) {
	  if (bgrmp->error < 0) {
		  	 rc = ULFS_ERROR_MDHIM;
	  }

	  for (i = 0; i < bgrmp->num_keys; i++) {
		  tmp_key = (burstfs_key_t *)bgrm->keys[i];
		  tmp_val = (burstfs_val_t *)bgrm->values[i];

		  memcpy(&dest_app, (char *)&(tmp_val->app_rank_id), sizeof(int));
		  memcpy(&dest_client, (char *)&(tmp_val->app_rank_id)\
				  + sizeof(int), sizeof(int));
		  /* physical offset of the requested file segment on the log file*/
		  del_req_set->msg_meta[tot_num].dest_offset = tmp_val->addr;

		  /* rank of the remote delegator*/
		  del_req_set->msg_meta[tot_num].dest_delegator_rank = tmp_val->delegator_id;

		  /* dest_client_id and dest_app_id uniquely identifies the remote physical
		   * log file that contains the requested segments*/
		  del_req_set->msg_meta[tot_num].dest_client_id = dest_client;
		  del_req_set->msg_meta[tot_num].dest_app_id = dest_app;
		  del_req_set->msg_meta[tot_num].length = tmp_val->len;

		  /* src_app_id and src_cli_id identifies the requested client*/
		  del_req_set->msg_meta[tot_num].src_app_id = app_id;
		  del_req_set->msg_meta[tot_num].src_cli_id = client_id;

		  /* src_offset is the logical offset of the shared file*/
		  del_req_set->msg_meta[tot_num].src_offset = tmp_key->offset;
		  del_req_set->msg_meta[tot_num].src_delegator_rank = glb_rank;
		  del_req_set->msg_meta[tot_num].src_fid = tmp_key->fid;
		  del_req_set->msg_meta[tot_num].src_dbg_rank = dbg_rank;
		  del_req_set->msg_meta[tot_num].src_thrd = thrd_id;
		  tot_num++;
	  	}
		  bgrmp = bgrmp->next;
		  mdhim_full_release_msg(bgrm);
		  bgrm = bgrmp;
    }

	del_req_set->num = tot_num;
//    print_bget_indices(app_id, client_id, del_req_set->msg_meta, tot_num);

	return rc;
}
/* get the locations of all the requested file segments from
 * the key-value store.
* @param app_id: client's application id
* @param client_id: client-side process id
* @param del_req_set: the set of read requests to be
* @param thrd_id: the thread created for processing
* its client's read requests.
* @param dbg_rank: the client process's rank in its
* own application, used for debug purpose
* @param shm_reqbuf: the shared request memory that
* contains all the client's read requests
* @del_req_set: contains metadata information for all
* the read requests, such as the locations of the
* requested segments
* @return success/error code
*/
get the locations of all the requested file segments from
the key-value store.
get the locations of all the requested file segments from the key - value store .
int meta_batch_get(int app_id, int client_id,\
		int thrd_id, int dbg_rank, char *shm_reqbuf, int num,\
			msg_meta_t* del_req_set) {
	cli_req_t *tmp_cli_req = (cli_req_t *) shm_reqbuf;
	int i, rc = 0;
	for (i = 0; i < num; i++) {
		burstfs_keys[2 * i]->fid = tmp_cli_req[i].fid;
		burstfs_keys[2 * i]->offset = tmp_cli_req[i].offset;
		burstfs_key_lens[2 * i] = sizeof(burstfs_key_t);
		burstfs_keys[2 * i + 1]->fid = tmp_cli_req[i].fid;
		burstfs_keys[2 * i + 1]->offset =\
				tmp_cli_req[i].offset + tmp_cli_req[i].length - 1;
		burstfs_key_lens[2 * i + 1] = sizeof(burstfs_key_t);
	}
	md->primary_index = burstfs_indexes[0];
	bgrm = mdhimBGet(md, md->primary_index, burstfs_keys, burstfs_key_lens, \
			2 * num, MDHIM_RANGE_BGET);
	int tot_num = 0;
    int dest_client, dest_app;
    burstfs_key_t *tmp_key;
    burstfs_val_t *tmp_val;
	bgrmp = bgrm;
	while (bgrmp) {
	  if (bgrmp->error < 0) {
		  	 rc = ULFS_ERROR_MDHIM;
	  }
	  for (i = 0; i < bgrmp->num_keys; i++) {
		  tmp_key = (burstfs_key_t *)bgrm->keys[i];
		  tmp_val = (burstfs_val_t *)bgrm->values[i];
		  memcpy(&dest_app, (char *)&(tmp_val->app_rank_id), sizeof(int));
		  memcpy(&dest_client, (char *)&(tmp_val->app_rank_id)\
				  + sizeof(int), sizeof(int));
		  del_req_set->msg_meta[tot_num].dest_offset = tmp_val->addr;
		  del_req_set->msg_meta[tot_num].dest_delegator_rank = tmp_val->delegator_id;
		  del_req_set->msg_meta[tot_num].dest_client_id = dest_client;
		  del_req_set->msg_meta[tot_num].dest_app_id = dest_app;
		  del_req_set->msg_meta[tot_num].length = tmp_val->len;
		  del_req_set->msg_meta[tot_num].src_app_id = app_id;
		  del_req_set->msg_meta[tot_num].src_cli_id = client_id;
		  del_req_set->msg_meta[tot_num].src_offset = tmp_key->offset;
		  del_req_set->msg_meta[tot_num].src_delegator_rank = glb_rank;
		  del_req_set->msg_meta[tot_num].src_fid = tmp_key->fid;
		  del_req_set->msg_meta[tot_num].src_dbg_rank = dbg_rank;
		  del_req_set->msg_meta[tot_num].src_thrd = thrd_id;
		  tot_num++;
	  	}
		  bgrmp = bgrmp->next;
		  mdhim_full_release_msg(bgrm);
		  bgrm = bgrmp;
    }
	del_req_set->num = tot_num;
	return rc;
}
int meta_batch_get ( int app_id , int client_id , int thrd_id , int dbg_rank , char * shm_reqbuf , int num , msg_meta_t * del_req_set ) { cli_req_t * tmp_cli_req = ( cli_req_t * ) shm_reqbuf ; int i , rc = 0 ; for ( i = 0 ; i < num ; i ++ ) { burstfs_keys [ 2 * i ] -> fid = tmp_cli_req [ i ] . fid ; burstfs_keys [ 2 * i ] -> offset = tmp_cli_req [ i ] . offset ; burstfs_key_lens [ 2 * i ] = sizeof ( burstfs_key_t ) ; burstfs_keys [ 2 * i + 1 ] -> fid = tmp_cli_req [ i ] . fid ; burstfs_keys [ 2 * i + 1 ] -> offset = tmp_cli_req [ i ] . offset + tmp_cli_req [ i ] . length - 1 ; burstfs_key_lens [ 2 * i + 1 ] = sizeof ( burstfs_key_t ) ; } md -> primary_index = burstfs_indexes [ 0 ] ; bgrm = mdhimBGet ( md , md -> primary_index , burstfs_keys , burstfs_key_lens , 2 * num , MDHIM_RANGE_BGET ) ; int tot_num = 0 ; int dest_client , dest_app ; burstfs_key_t * tmp_key ; burstfs_val_t * tmp_val ; bgrmp = bgrm ; while ( bgrmp ) { if ( bgrmp -> error < 0 ) { rc = ULFS_ERROR_MDHIM ; } for ( i = 0 ; i < bgrmp -> num_keys ; i ++ ) { tmp_key = ( burstfs_key_t * ) bgrm -> keys [ i ] ; tmp_val = ( burstfs_val_t * ) bgrm -> values [ i ] ; memcpy ( & dest_app , ( char * ) & ( tmp_val -> app_rank_id ) , sizeof ( int ) ) ; memcpy ( & dest_client , ( char * ) & ( tmp_val -> app_rank_id ) + sizeof ( int ) , sizeof ( int ) ) ; del_req_set -> msg_meta [ tot_num ] . dest_offset = tmp_val -> addr ; del_req_set -> msg_meta [ tot_num ] . dest_delegator_rank = tmp_val -> delegator_id ; del_req_set -> msg_meta [ tot_num ] . dest_client_id = dest_client ; del_req_set -> msg_meta [ tot_num ] . dest_app_id = dest_app ; del_req_set -> msg_meta [ tot_num ] . length = tmp_val -> len ; del_req_set -> msg_meta [ tot_num ] . src_app_id = app_id ; del_req_set -> msg_meta [ tot_num ] . src_cli_id = client_id ; del_req_set -> msg_meta [ tot_num ] . src_offset = tmp_key -> offset ; del_req_set -> msg_meta [ tot_num ] . src_delegator_rank = glb_rank ; del_req_set -> msg_meta [ tot_num ] . src_fid = tmp_key -> fid ; del_req_set -> msg_meta [ tot_num ] . src_dbg_rank = dbg_rank ; del_req_set -> msg_meta [ tot_num ] . src_thrd = thrd_id ; tot_num ++ ; } bgrmp = bgrmp -> next ; mdhim_full_release_msg ( bgrm ) ; bgrm = bgrmp ; } del_req_set -> num = tot_num ; return rc ; }
get the locations of all the requested file segments from
 the key-value store.
get the locations of all the requested file segments from the key - value store .
/* physical offset of the requested file segment on the log file*/ /* rank of the remote delegator*/ /* dest_client_id and dest_app_id uniquely identifies the remote physical
		   * log file that contains the requested segments*/ /* src_app_id and src_cli_id identifies the requested client*/ /* src_offset is the logical offset of the shared file*/ //    print_bget_indices(app_id, client_id, del_req_set->msg_meta, tot_num);
