BurstFS_Server/burstfs_metadata.c
int meta_init_store() {
	db_opts = malloc(sizeof(struct mdhim_options_t));
	if (!db_opts)
		return -1;

	/* BURSTFS_META_DB_PATH: file that stores the key value pair*/
	char *env = getenv("BURSTFS_META_DB_PATH");
	if (!env) {
		db_opts->db_path = malloc(strlen(DEF_META_PATH) + 1);
		if (!db_opts->db_path)
			return -1;

		strcpy(db_opts->db_path, DEF_META_PATH);
	} else {
		db_opts->db_path = malloc(strlen(env) + 1);
		if (!db_opts->db_path)
			return -1;

		strcpy(db_opts->db_path, env);
	}

	db_opts->manifest_path = NULL;
	db_opts->db_type = LEVELDB;
	db_opts->db_create_new = 1;

	/* META_SERVER_RATIO: number of metadata servers =
		number of processes/META_SERVER_RATIO */

	int ser_ratio;
	env = getenv("BURSTFS_META_SERVER_RATIO");
	if (!env)
		ser_ratio = DEF_SERVER_RATIO;

	ser_ratio = atoi(env);


	db_opts->rserver_factor = ser_ratio;
	db_opts->db_paths = NULL;
	db_opts->num_paths = 0;
	db_opts->num_wthreads = 1;

	int path_len = strlen(db_opts->db_path) + strlen(MANIFEST_FILE_NAME) + 1;


	manifest_path = malloc(path_len);
	if (!manifest_path)
		return -1;

	sprintf(manifest_path, "%s%s", db_opts->db_path, MANIFEST_FILE_NAME);
	db_opts->manifest_path = manifest_path;

	env = getenv("BURSTFS_META_DB_NAME");
	if (!env) {
		db_opts->db_name = malloc(strlen(DEF_DB_NAME) + 1);
		if (!db_opts->db_name)
			return -1;

		strcpy(db_opts->db_name, DEF_DB_NAME);
	} else {
		db_opts->db_name = malloc(strlen(env) + 1);
		if (!db_opts->db_name)
			return -1;

		strcpy(db_opts->db_name, env);
	}

	db_opts->db_key_type = MDHIM_BURSTFS_KEY;
	db_opts->debug_level = MLOG_CRIT;

	/* indices/attributes are striped to servers according
	 * to BurstFS_META_RANGE_SZ.
	 * */
	env = getenv("BURSTFS_META_RANGE_SZ");
	if (!env)
		db_opts->max_recs_per_slice = DEF_RANGE_SZ;
	else
		db_opts->max_recs_per_slice = atol(env);

	max_recs_per_slice = db_opts->max_recs_per_slice;

	MPI_Comm comm = MPI_COMM_WORLD;
	md = mdhimInit(&comm, db_opts);

	/*this index is created for storing index metadata*/
	burstfs_indexes[0] = md->primary_index;

	/*this index is created for storing file attribute metadata*/
	burstfs_indexes[1] = create_global_index(md, ser_ratio, 1,\
			LEVELDB, MDHIM_INT_KEY, "file_attr");

	MPI_Comm_size(md->mdhim_comm, &md_size);

	int rc = meta_init_indices();
	if (rc != 0)
		return -1;

	return 0;

}
/**
* initialize the key-value store
*/
initialize the key-value store
initialize the key - value store
int meta_init_store() {
	db_opts = malloc(sizeof(struct mdhim_options_t));
	if (!db_opts)
		return -1;
	char *env = getenv("BURSTFS_META_DB_PATH");
	if (!env) {
		db_opts->db_path = malloc(strlen(DEF_META_PATH) + 1);
		if (!db_opts->db_path)
			return -1;
		strcpy(db_opts->db_path, DEF_META_PATH);
	} else {
		db_opts->db_path = malloc(strlen(env) + 1);
		if (!db_opts->db_path)
			return -1;
		strcpy(db_opts->db_path, env);
	}
	db_opts->manifest_path = NULL;
	db_opts->db_type = LEVELDB;
	db_opts->db_create_new = 1;
	int ser_ratio;
	env = getenv("BURSTFS_META_SERVER_RATIO");
	if (!env)
		ser_ratio = DEF_SERVER_RATIO;
	ser_ratio = atoi(env);
	db_opts->rserver_factor = ser_ratio;
	db_opts->db_paths = NULL;
	db_opts->num_paths = 0;
	db_opts->num_wthreads = 1;
	int path_len = strlen(db_opts->db_path) + strlen(MANIFEST_FILE_NAME) + 1;
	manifest_path = malloc(path_len);
	if (!manifest_path)
		return -1;
	sprintf(manifest_path, "%s%s", db_opts->db_path, MANIFEST_FILE_NAME);
	db_opts->manifest_path = manifest_path;
	env = getenv("BURSTFS_META_DB_NAME");
	if (!env) {
		db_opts->db_name = malloc(strlen(DEF_DB_NAME) + 1);
		if (!db_opts->db_name)
			return -1;
		strcpy(db_opts->db_name, DEF_DB_NAME);
	} else {
		db_opts->db_name = malloc(strlen(env) + 1);
		if (!db_opts->db_name)
			return -1;
		strcpy(db_opts->db_name, env);
	}
	db_opts->db_key_type = MDHIM_BURSTFS_KEY;
	db_opts->debug_level = MLOG_CRIT;
	env = getenv("BURSTFS_META_RANGE_SZ");
	if (!env)
		db_opts->max_recs_per_slice = DEF_RANGE_SZ;
	else
		db_opts->max_recs_per_slice = atol(env);
	max_recs_per_slice = db_opts->max_recs_per_slice;
	MPI_Comm comm = MPI_COMM_WORLD;
	md = mdhimInit(&comm, db_opts);
	burstfs_indexes[0] = md->primary_index;
	burstfs_indexes[1] = create_global_index(md, ser_ratio, 1,\
			LEVELDB, MDHIM_INT_KEY, "file_attr");
	MPI_Comm_size(md->mdhim_comm, &md_size);
	int rc = meta_init_indices();
	if (rc != 0)
		return -1;
	return 0;
}
int meta_init_store ( ) { db_opts = malloc ( sizeof ( struct mdhim_options_t ) ) ; if ( ! db_opts ) return -1 ; char * env = getenv ( " " ) ; if ( ! env ) { db_opts -> db_path = malloc ( strlen ( DEF_META_PATH ) + 1 ) ; if ( ! db_opts -> db_path ) return -1 ; strcpy ( db_opts -> db_path , DEF_META_PATH ) ; } else { db_opts -> db_path = malloc ( strlen ( env ) + 1 ) ; if ( ! db_opts -> db_path ) return -1 ; strcpy ( db_opts -> db_path , env ) ; } db_opts -> manifest_path = NULL ; db_opts -> db_type = LEVELDB ; db_opts -> db_create_new = 1 ; int ser_ratio ; env = getenv ( " " ) ; if ( ! env ) ser_ratio = DEF_SERVER_RATIO ; ser_ratio = atoi ( env ) ; db_opts -> rserver_factor = ser_ratio ; db_opts -> db_paths = NULL ; db_opts -> num_paths = 0 ; db_opts -> num_wthreads = 1 ; int path_len = strlen ( db_opts -> db_path ) + strlen ( MANIFEST_FILE_NAME ) + 1 ; manifest_path = malloc ( path_len ) ; if ( ! manifest_path ) return -1 ; sprintf ( manifest_path , " " , db_opts -> db_path , MANIFEST_FILE_NAME ) ; db_opts -> manifest_path = manifest_path ; env = getenv ( " " ) ; if ( ! env ) { db_opts -> db_name = malloc ( strlen ( DEF_DB_NAME ) + 1 ) ; if ( ! db_opts -> db_name ) return -1 ; strcpy ( db_opts -> db_name , DEF_DB_NAME ) ; } else { db_opts -> db_name = malloc ( strlen ( env ) + 1 ) ; if ( ! db_opts -> db_name ) return -1 ; strcpy ( db_opts -> db_name , env ) ; } db_opts -> db_key_type = MDHIM_BURSTFS_KEY ; db_opts -> debug_level = MLOG_CRIT ; env = getenv ( " " ) ; if ( ! env ) db_opts -> max_recs_per_slice = DEF_RANGE_SZ ; else db_opts -> max_recs_per_slice = atol ( env ) ; max_recs_per_slice = db_opts -> max_recs_per_slice ; MPI_Comm comm = MPI_COMM_WORLD ; md = mdhimInit ( & comm , db_opts ) ; burstfs_indexes [ 0 ] = md -> primary_index ; burstfs_indexes [ 1 ] = create_global_index ( md , ser_ratio , 1 , LEVELDB , MDHIM_INT_KEY , " " ) ; MPI_Comm_size ( md -> mdhim_comm , & md_size ) ; int rc = meta_init_indices ( ) ; if ( rc != 0 ) return -1 ; return 0 ; }
initialize the key-value store
initialize the key - value store
/* BURSTFS_META_DB_PATH: file that stores the key value pair*/ /* META_SERVER_RATIO: number of metadata servers =
		number of processes/META_SERVER_RATIO */ /* indices/attributes are striped to servers according
	 * to BurstFS_META_RANGE_SZ.
	 * */ /*this index is created for storing index metadata*/ /*this index is created for storing file attribute metadata*/