static GError* _poll_services(struct grid_lbpool_s *lbp, const gchar *srvtype, struct lb_next_opt_ext_s *opt_ext, GSList **result, gboolean use_beans) { struct grid_lb_iterator_s *iter = NULL; struct service_info_s **psi, **siv = NULL; if (!lbp || !srvtype) return NEWERROR(CODE_INTERNAL_ERROR, "Invalid parameter"); if (!(iter = grid_lbpool_get_iterator(lbp, srvtype))) return NEWERROR(CODE_POLICY_NOT_SATISFIABLE, "No RAWX available"); if (!grid_lb_iterator_next_set2(iter, &siv, opt_ext)) return NEWERROR(CODE_PLATFORM_ERROR, "Cannot get services" " list for the specified storage policy"); if (use_beans) { for(psi=siv; *psi; ++psi) *result = g_slist_prepend(*result, _gen_chunk_bean(*psi)); } else { for(psi=siv; *psi; ++psi) *result = g_slist_prepend(*result, _gen_chunk_info(*psi)); } service_info_cleanv(siv, FALSE); return NULL; }
GError* meta2_backend_poll_service(struct meta2_backend_s *m2, const gchar *type, struct service_info_s **si) { struct grid_lb_iterator_s *iter; EXTRA_ASSERT(m2 != NULL); EXTRA_ASSERT(type != NULL); EXTRA_ASSERT(si != NULL); if (!(iter = grid_lbpool_get_iterator(m2->backend.lb, type))) return NEWERROR(CODE_SRVTYPE_NOTMANAGED, "no such service"); struct lb_next_opt_ext_s opt_ext; memset(&opt_ext, 0, sizeof(opt_ext)); opt_ext.req.distance = 0; opt_ext.req.max = 1; opt_ext.req.duplicates = TRUE; opt_ext.req.stgclass = NULL; opt_ext.req.strict_stgclass = TRUE; struct service_info_s **siv = NULL; if (!grid_lb_iterator_next_set2(iter, &siv, &opt_ext)) return NEWERROR(CODE_SRVTYPE_NOTMANAGED, "no service available"); *si = service_info_dup(siv[0]); service_info_cleanv(siv, FALSE); return NULL; }
static GError* _get_iterator(struct meta1_backend_s *m1, struct compound_type_s *ct, struct grid_lb_iterator_s **result) { struct grid_lb_iterator_s *r = grid_lbpool_get_iterator(m1->lb, ct->baretype); if (!r) { *result = NULL; return NEWERROR(CODE_SRVTYPE_NOTMANAGED, "type [%s] not managed", ct->baretype); } *result = grid_lb_iterator_share(r); return NULL; }