Esempio n. 1
0
gboolean
update_rawx_conf(apr_pool_t* p, rawx_conf_t **rawx_conf, const gchar* ns_name)
{
	rawx_conf_t* new_conf = NULL;
        namespace_info_t* ns_info;
        GError *local_error = NULL;

        ns_info = get_namespace_info(ns_name, &local_error);
        if (!ns_info)
                return FALSE;

	new_conf = apr_palloc(p, sizeof(rawx_conf_t));
	char * stgpol = NULL;
	stgpol = namespace_storage_policy(ns_info, ns_info->name);
	if(NULL != stgpol) {
		new_conf->sp = storage_policy_init(ns_info, stgpol);
	}

	new_conf->ni = ns_info;
	new_conf->acl = _get_acl(p, ns_info);
        new_conf->last_update = time(0);

	*rawx_conf = new_conf;
	return TRUE;
}
Esempio n. 2
0
static const char *
dav_rainx_cmd_gridconfig_namespace(cmd_parms *cmd, void *config, const char *arg1)
{
	dav_rainx_server_conf *conf;
	(void) config;

	DAV_XDEBUG_POOL(cmd->pool, 0, "%s()", __FUNCTION__);

	conf = ap_get_module_config(cmd->server->module_config, &dav_rainx_module);
	memset(conf->ns_name, 0x00, sizeof(conf->ns_name));
	apr_cpystrn(conf->ns_name, arg1, sizeof(conf->ns_name));


	DAV_DEBUG_POOL(cmd->pool, 0, "NS=[%s]", conf->ns_name);

	/* Prepare COMPRESSION / ACL CONF when we get ns name */
	namespace_info_t* ns_info;
	GError *local_error = NULL;
	ns_info = get_namespace_info(conf->ns_name, &local_error);
	if (!ns_info) {
		DAV_DEBUG_POOL(cmd->temp_pool, 0, "Failed to get namespace info from ns [%s]", conf->ns_name);
		return apr_pstrcat(cmd->temp_pool, "Failed to get namespace info from ns: ",
				conf->ns_name, " ", local_error->message, NULL);
	}

	if (!conf->rainx_conf_lock) {
		apr_thread_mutex_create(&(conf->rainx_conf_lock),
				APR_THREAD_MUTEX_DEFAULT, conf->pool);
	}

	apr_thread_mutex_lock(conf->rainx_conf_lock);
	conf->rainx_conf = apr_palloc(cmd->pool, sizeof(rawx_conf_t));

	char * stgpol = NULL;
	stgpol = namespace_storage_policy(ns_info, ns_info->name);
	if(NULL != stgpol) {
		conf->rainx_conf->sp = storage_policy_init(ns_info, stgpol);
	} else {
		conf->rainx_conf->sp = NULL;
	}

	conf->rainx_conf->ni = ns_info;

	conf->rainx_conf->acl = _get_acl(cmd->pool, ns_info);
	conf->rainx_conf->last_update = time(0);
	apr_thread_mutex_unlock(conf->rainx_conf_lock);

	if(local_error)
		g_clear_error(&local_error);
	return NULL;
}
Esempio n. 3
0
static gs_error_t *
_dl_nocache(gs_container_t *c, struct hc_url_s *url,
		gs_download_info_t *dlinfo, gchar *stgpol)
{
	gs_error_t *e = NULL;
	GError *err = NULL;
	gs_content_t *content = NULL;
	namespace_info_t *ni = NULL;
	GSList *filtered = NULL, *beans = NULL;

	/*find the content*/
	content  = gs_get_content_from_path_full(c, hc_url_get(url, HCURL_PATH),
			hc_url_get(url, HCURL_SNAPORVERS), &filtered, &beans, &e);

	if(NULL != content) {
		GRID_DEBUG("Content %s found in container %s\n",
				hc_url_get(url, HCURL_PATH), hc_url_get(url, HCURL_REFERENCE));

		ni = get_namespace_info(hc_url_get(url, HCURL_NS), &err);
		if (!ni) {
			GSERRORCAUSE(&e, err, "Cannot get namespace info for NS [%s]",
					hc_url_get(url, HCURL_NS));
			g_clear_error(&err);
			return e;
		}

		namespace_info_copy(ni, &(content->info.container->info.gs->ni), &err);

		/*download the content*/
		(void) gs_download_content_full (content, dlinfo, stgpol, filtered,
				beans, &e);
		namespace_info_clear(ni);
		g_free(ni);
		gs_content_free (content);
		g_slist_free(filtered);
		_bean_cleanl2(beans);
		return e;
	}

	g_printerr("'%s' not found in '%s'\n", hc_url_get(url, HCURL_PATH),
			hc_url_get(url, HCURL_REFERENCE));
	return e;
}
Esempio n. 4
0
static struct storage_policy_s *
_init_storage_policy(const char *ns, const char *polname)
{
	namespace_info_t *ni = NULL;
	GError *e = NULL;
	struct storage_policy_s *sp =NULL;

	ni = get_namespace_info(ns, &e);
	if(NULL != e) {
		GRID_ERROR("Failed to get namespace info : %s", e->message);
		g_clear_error(&e);
		return NULL;
	}

	sp = storage_policy_init(ni, polname);

	namespace_info_clear(ni);
	g_free(ni);
	return sp;
}
Esempio n. 5
0
gs_grid_storage_t*
gs_grid_storage_init_flags(const gchar *ns, uint32_t flags,
		int to_cnx, int to_req, gs_error_t **err)
{
	gs_grid_storage_t *gs=NULL;
	register const gchar *sep;
	namespace_info_t *ni;

	env_init();

	/*parse the arguments*/
	if (!ns || !*ns) {
		GSERRORSET(err,"Invalid parameter");
		return NULL;
	}

	DEBUG("Creating a new GridStorage client for namespace [%s]", ns);

	/*inits a new gs_grid_storage_t*/
	gs = calloc (1, sizeof(gs_grid_storage_t));
	if (!gs) {
		GSERRORSET(err,"Memory allocation failure");
		return NULL;
	}

	if (!(flags & GSCLIENT_NOINIT)) {
		GError *gErr = NULL;
		ni = get_namespace_info(ns, &gErr);
		if (!ni) {
			GSERRORCAUSE(err,gErr,"Cannot get namespace info");
			if (gErr)
				g_clear_error(&gErr);
			free(gs);
			return NULL;
		}
		namespace_info_copy(ni, &(gs->ni), &gErr);
		namespace_info_free(ni);
		if (gErr != NULL) {
			GSERRORCAUSE(err, gErr, "Failed to copy namespace info");
			g_clear_error(&gErr);
			free(gs);
			return NULL;
		}
	}

	if (NULL != (sep = strchr(ns, '.'))) {
		gs->physical_namespace = g_strndup(ns, sep-ns);
	}
	else {
		gs->physical_namespace = g_strdup(ns);
	}
	gs->full_vns = g_strdup(ns);

	if (!(flags & GSCLIENT_NOINIT)) {
		GError *gErr = NULL;
		gs->metacd_resolver = resolver_metacd_create (ns, &gErr);
		if (!gs->metacd_resolver) {
			GSERRORCAUSE(err,gErr,"Cannot init the metacd");
			if (gErr)
				g_clear_error(&gErr);
			free(gs);
			return NULL;
		}

		gs->direct_resolver = resolver_direct_create_with_metacd (ns,
				gs->metacd_resolver, to_cnx, to_req, &gErr);
		if (!gs->direct_resolver) {
			GSERRORCAUSE(err,gErr,"Cannot init the direct resolver");
			if (gErr)
				g_clear_error(&gErr);
			resolver_metacd_free(gs->metacd_resolver);
			free(gs);
			return NULL;
		}
	}

	gs->timeout.rawx.op =  RAWX_TOREQ_DEFAULT;
	gs->timeout.rawx.cnx = RAWX_TOCNX_DEFAULT;
	gs->timeout.m2.op =   M2_TOREQ_DEFAULT;
	gs->timeout.m2.cnx =  M2_TOCNX_DEFAULT;
	g_strlcpy(gs->ni.name, ns, sizeof(gs->ni.name));

	if (NULL != strchr(gs->ni.name, '.'))
		* (strchr(gs->ni.name, '.')) = '\0';

	return gs;
}