static void dump_platform_storages(void){ unsigned int cursor; xbt_dynar_t storages = MSG_storages_as_dynar(); msg_storage_t storage; xbt_dynar_foreach(storages, cursor, storage){ XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage)); MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs")); }
static void display_storage_properties(msg_storage_t storage){ xbt_dict_cursor_t cursor = NULL; char *key, *data; xbt_dict_t props = MSG_storage_get_properties(storage); if (xbt_dict_length(props) > 0){ XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage)); xbt_dict_foreach(props, cursor, key, data) XBT_INFO("\t\t'%s' -> '%s'", key, data); }else{ XBT_INFO("\tNo property attached."); } }
static void display_storage_content(msg_storage_t storage){ XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage)); xbt_dict_cursor_t cursor = NULL; char *file; sg_size_t *psize; xbt_dict_t content = MSG_storage_get_content(storage); if (content){ xbt_dict_foreach(content, cursor, file, psize) XBT_INFO("\t%s size: %llu bytes", file, *psize); } else { XBT_INFO("\tNo content."); } xbt_dict_free(&content); }
int main(int argc, char **argv) { int res; unsigned int cur; xbt_dynar_t storages; msg_storage_t st; MSG_init(&argc, argv); MSG_create_environment(argv[1]); MSG_function_register("host", host); MSG_launch_application(argv[2]); storages = MSG_storages_as_dynar(); xbt_dynar_foreach(storages, cur, st){ XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); }
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jclass cls_arg) { int index; jobjectArray jtable; jobject jstorage; jstring jname; msg_storage_t storage; xbt_dynar_t table = MSG_storages_as_dynar(); int count = xbt_dynar_length(table); jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage"); if (!cls) { return NULL; } jtable = (*env)->NewObjectArray(env, (jsize) count, cls, NULL); if (!jtable) { jxbt_throw_jni(env, "Storages table allocation failed"); return NULL; } for (index = 0; index < count; index++) { storage = xbt_dynar_get_as(table,index,msg_storage_t); jstorage = (jobject) (xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL)); if (!jstorage) { jname = (*env)->NewStringUTF(env, MSG_storage_get_name(storage)); jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname); } (*env)->SetObjectArrayElement(env, jtable, index, jstorage); } xbt_dynar_free(&table); return jtable; }
xbt_dynar_foreach(storages, cur, st){ XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); }
const char *jstorage_get_name(jobject jstorage, JNIEnv * env) { msg_storage_t storage = jstorage_get_native(env, jstorage); return MSG_storage_get_name(storage); }