static void test_data(struct test_data_s *pdata) { gs_error_t *gse = NULL; struct gs_grid_storage_s *gs = NULL; struct gs_container_s *container = NULL; gs = gs_grid_storage_init_flags(pdata->ns, GSCLIENT_NOINIT, 60, 60, &gse); g_assert((gs != NULL) ^ (gse != NULL)); if (!gs) g_debug("gs_grid_storage_init_flags failed : (%d) %s\n", gse->code, gse->msg); g_assert(gse == NULL); check_strings(pdata->pns, gs->ni.name); check_strings(pdata->ns, gs->full_vns); check_strings(pdata->pns, gs->physical_namespace); check_strings(pdata->vns, gs_get_virtual_namespace(gs)); container = gs_init_container(gs, pdata->refname, 0, &gse); g_assert((container != NULL) ^ (gse != NULL)); if (!container) g_debug("gs_init_container failed : (%d) %s\n", gse->code, gse->msg); g_assert(gse == NULL); check_strings(pdata->refname, container->info.name); check_strings(pdata->refhexa, container->str_cID); gs_container_free(container); gs_grid_storage_free(gs); }
static gs_error_t* _m1policy_update(gchar *action, gchar *ns,gboolean isprefix, container_id_t cid, gchar *type, gchar *exludesrv, gboolean checkonly, gchar ***result ) { GError *err=NULL; gs_error_t *hc_error = NULL; GSList *exclude = NULL; addr_info_t *m1addr; gs_grid_storage_t *hc; gchar ** hc_result = NULL; hc = gs_grid_storage_init(ns, &hc_error); if (!hc) return hc_error; m1addr = gs_resolve_meta1v2(hc,cid,NULL,0,exclude,&err); while (m1addr) { hc_result = meta1v2_remote_update_m1_policy(m1addr, &err, ns, ( isprefix ? cid : NULL), ( isprefix ? NULL: cid), type, action, checkonly, exludesrv, 300, 300); if ( err ) { if ( err->code < 100 || err->code > 500 ) { exclude=g_slist_prepend(exclude,m1addr); m1addr = gs_resolve_meta1v2(hc,cid,NULL,0,exclude,&err); } else { GRID_WARN("META1 request error (%d) : %s", err->code, err->message); GSERRORCAUSE(&hc_error, err, "Failed to apply Meta1 policy\n"); m1addr=NULL; } g_clear_error(&err); } else { break; } } gs_grid_storage_free(hc); if(exclude) { g_slist_foreach(exclude, addr_info_gclean, NULL); g_slist_free(exclude); } if(m1addr) g_free(m1addr); *result = hc_result; return hc_error; }
static gs_error_t* _m2_touch(struct hc_url_s *hcurl, guint32 flags) { GError* err = NULL; gs_error_t* gserr = NULL; gs_container_t* cid = NULL; gs_grid_storage_t* hc = NULL; GSList* m2list = NULL; addr_info_t* m2addr = NULL; char str_addr[STRLEN_ADDRINFO] = ""; const char* ns = NULL; const char* content = NULL; const char* container_name = NULL; ns = hc_url_get(hcurl, HCURL_NS); container_name = hc_url_get(hcurl, HCURL_REFERENCE); content = hc_url_get(hcurl, HCURL_PATH); /* init grid client */ if ((ns==NULL) || (strlen(ns)==0)) { GSERRORCODE(&gserr, -1, "Invalid namespace"); return gserr; } hc = gs_grid_storage_init(ns, &gserr); if (!hc) { return gserr; } /* init container_id */ if ((container_name==NULL) || (strlen(container_name)==0)) { GSERRORCODE(&gserr, -1, "Invalid container_name"); return gserr; } cid = gs_init_container(hc, container_name, FALSE, &gserr); if (!gserr) { if (!cid) { gs_grid_storage_free(hc); GSERRORCODE(&gserr, -1, "Invalid container_name %s/%s", ns, container_name); return gserr; } } else return gserr; /* search meta2 master */ m2list = gs_resolve_meta2(hc, C0_ID(cid), &err); if (!m2list) { GSERRORCODE(&gserr, -1, "Meta2 Resolution error for NAME=[%s] ID=[%s]", C0_NAME(cid), C0_IDSTR(cid)); if (cid) gs_container_free (cid); gs_grid_storage_free(hc); return gserr; } m2addr = (addr_info_t*) m2list->data; addr_info_to_string (m2addr, str_addr, sizeof(str_addr)); /* execute touch command */ if (content && strlen(content)>0) err = m2v2_remote_touch_content(str_addr, NULL, hcurl); else err = m2v2_remote_touch_container_ex(str_addr, NULL, hcurl, flags); /* an error occurs ? */ if (err) { GSERRORCAUSE(&gserr, err, "Failed to execute touch command"); g_clear_error(&err); } gs_grid_storage_free(hc); if (cid) gs_container_free (cid); return gserr; }
int main(int argc, char **args) { int rc; gs_error_t *err = NULL; gs_grid_storage_t *gs = NULL; gs_container_t *container = NULL; signal(SIGPIPE, sig_pipe); if (argc <= 1) { help(); return 1; } if (!parse_opt(argc, args)) { PRINT_ERROR("Cannot parse the arguments\n"); help(); return 1; } if (!conf_check()) { PRINT_ERROR("Missing parameters\n"); help(); return 1; } /*open the connection to the META0 */ gs = gs_grid_storage_init(meta0_url, &err); if (!gs) { PRINT_ERROR("grid storage error : cannot init the namespace configuration from %s\n", meta0_url); return -1; } PRINT_DEBUG("Connected to the GridStorage namespace %s\n", meta0_url); /*find the container */ container = gs_get_container(gs, container_name, 0, &err); if (!container) { PRINT_ERROR("grid storage error : cannot find the container %s : %s\n", container_name, err->msg); gs_grid_storage_free(gs); return -1; } PRINT_DEBUG("container %s found\n", container_name); switch (action) { case A_CONTAINER_GET: rc = get_service_for_container(container,&err); if (rc != 0) PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n", container_name, gs_error_get_message(err)); break; case A_CONTAINER_LIST: rc = list_services_used_by_container(container,&err); if (rc != 0) PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n", container_name, gs_error_get_message(err)); break; case A_LISTSRV: rc = list_services_used(container,&err); if (rc != 0) PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n", container_name, gs_error_get_message(err)); break; case A_LISTCONTENT: rc = list_services_for_path(container,&err, remote_path); if (rc != 0) PRINT_ERROR("Failed to list the index services used in container [%s] for path [%s] : %s\n", container_name, remote_path, gs_error_get_message(err)); break; default: PRINT_ERROR("Action not set, please provide at least '-l' or '-c'\n"); rc = -1; break; } gs_container_free(container); gs_grid_storage_free(gs); return 0; }
int main(int argc, char **args) { int rc = ~0; gs_error_t *err = NULL; gs_grid_storage_t *gs = NULL; close(0); if (!parse_opt(argc, args)) { PRINT_ERROR("cannot parse the options, see the help section (--help option)\n"); return ~0; } if (flag_help) { help(); return 0; } if (!conf_check()) { PRINT_ERROR("invalid configuration, see the help section (--help option)\n"); help(); return ~0; } if (0 > chdir(base_dir)) { PRINT_ERROR("Failed to change the working directory : %s\n", strerror(errno)); return ~0; } gs = gs_grid_storage_init(meta0_url, &err); if (gs == NULL) { if (optind<argc){ free(meta0_url); meta0_url=strtok(args[optind],"/"); free(container_name); container_name=strtok(NULL,"/"); if(container_name!=NULL){ gs = gs_grid_storage_init(meta0_url, &err); if(!gs){ PRINT_ERROR("cannot init the GridStorage client\n"); goto error_gs; } } else{ PRINT_ERROR("missing options\n"); help(); return 0; } } else{ PRINT_ERROR("missing options\n"); help(); return 0; } } if (0 > list_container(gs, container_name)) { PRINT_ERROR("cannot list %s in namespace %s\n", container_name, meta0_url); goto error_list; } rc = 0; error_list: gs_grid_storage_free(gs); error_gs: if (err) gs_error_free(err); return rc; }
int main (int argc, char ** args) { int rc = -1; gs_error_t *err = NULL; gs_grid_storage_t *hc; gs_container_t *container; char *ns; char cname[60]; srand(time(NULL)); if (argc != 2) { g_error("Usage: %s NS\n", args[0]); return rc; } ns = args[1]; bzero(cname, sizeof(cname)); g_snprintf(cname, sizeof(cname), "SOLR%d", rand()); printf("Working with container [%s]\n", cname); hc = gs_grid_storage_init( ns, &err ); if(!hc) { printf("failed to init hc\n"); return rc; } container = gs_get_container(hc, cname, 1, &err); if(!container) { printf("Failed to resolve container\n"); goto end_label; } gs_service_t **srv_array = NULL; srv_array = gs_container_service_get_available(container, "meta0", &err); char url[256]; bzero(url, sizeof(url)); gs_service_get_url(srv_array[0], url, sizeof(url)); printf("New service linked\n"); printf("service url = [%s]\n", url); if(srv_array) gs_service_free_array(srv_array); srv_array = gs_container_service_get_all(container, "meta0", &err); bzero(url, sizeof(url)); gs_service_get_url(srv_array[0], url, sizeof(url)); printf("Already linked service :\n"); printf("service url = [%s]\n", url); if(srv_array) gs_service_free_array(srv_array); end_label: if(container) { gs_container_free(container); container = NULL; } if(hc) { gs_grid_storage_free(hc); hc = NULL; } if(err) { gs_error_free(err); err= NULL; } }
int main(int argc, char **argv) { int i = init_file(); if (!i) { HC_TEST_INIT(argc, argv); const char *ns = "NS"; gs_error_t *err = NULL; gs_grid_storage_t *gs = gs_grid_storage_init(ns, &err); if (!gs) { fprintf(stderr, "OIO init error : (%d) %s\n", err->code, err->msg); _gs_error_clear(&err); abort(); } g_test_set_nonfatal_assertions(); g_test_add_data_func("/client/lib/prop/set_ref_prop", gs, (GTestDataFunc) test_set_reference_property); g_test_add_data_func("/client/lib/prop/get_ref_prop", gs, (GTestDataFunc) test_get_reference_property); g_test_add_data_func("/client/lib/prop/get_ref_prop_v", gs, (GTestDataFunc) test_get_reference_property_void); g_test_add_data_func("/client/lib/prop/get_ref_prop_w", gs, (GTestDataFunc) test_get_reference_property_wrong_key); g_test_add_data_func("/client/lib/prop/del_ref_prop", gs, (GTestDataFunc) test_delete_reference_property); g_test_add_data_func("/client/lib/prop/set_cont_strpol", gs, (GTestDataFunc) test_set_container_storage_policy); g_test_add_data_func("/client/lib/prop/set_cont_strpol_wrong", gs, (GTestDataFunc) test_set_container_storage_policy_wrong); g_test_add_data_func("/client/lib/prop/set_cont_quot", gs, (GTestDataFunc) test_set_container_quota); g_test_add_data_func("/client/lib/prop/set_cont_vers", gs, (GTestDataFunc) test_set_container_versioning); g_test_add_data_func("/client/lib/prop/del_cont_vers", gs, (GTestDataFunc) test_del_container_versioning); g_test_add_data_func("/client/lib/prop/del_cont_vers_v", gs, (GTestDataFunc) test_del_container_versioning_void); g_test_add_data_func("/client/lib/prop/set_content_strpol", gs, (GTestDataFunc) test_set_content_storage_policy); g_test_add_data_func("/client/lib/prop/set_content_strpol_w_path", gs, (GTestDataFunc) test_set_content_storage_policy_bad_path); g_test_add_data_func("/client/lib/prop/set_content_strpol_w", gs, (GTestDataFunc) test_set_content_storage_policy_wrong); g_test_add_data_func("/client/lib/prop/get_content_prop", gs, (GTestDataFunc) test_get_content_properties); g_test_add_data_func("/client/lib/prop/set_content_prop", gs, (GTestDataFunc) test_set_content_property); g_test_add_data_func("/client/lib/prop/set_content_prop_w", gs, (GTestDataFunc) test_set_content_property_wrong); g_test_add_data_func("/client/lib/prop/set_content_prop_again", gs, (GTestDataFunc) test_set_content_property_again); //g_test_add_data_func("/client/lib/prop/del_content_prop", gs, // (GTestDataFunc) test_delete_content_property); g_test_add_data_func("/client/lib/prop/copy_content", gs, (GTestDataFunc) test_copy_content); int success = g_test_run(); remove("file_test.txt"); gs_grid_storage_free(gs); gs = NULL; return success; } else return 0; }