Beispiel #1
0
static void
_dump_chunks_xml_NORMAL(const struct loc_context_s *lc, GString **s)
{
	chunk_pair_t *current = NULL;

	for(guint i=0; i < lc->rc->pairs->len; i++) {
		current = &g_array_index(lc->rc->pairs, chunk_pair_t, i);
		GByteArray *hash = CHUNKS_get_hash(current->chunk);
		char str_hash[1 + sizeof(chunk_hash_t) * 2];
		oio_str_bin2hex(hash->data, hash->len, str_hash, sizeof(str_hash));
		char *loc = _chunk_location_row_xml(lc,
			CHUNKS_get_id(current->chunk)->str, "");
		g_string_append_printf(*s, 
				"   <chunk>\n"
				"    <locations>\n"
				"%s"
				"    </locations>\n"
				"    <position>%d</position>\n"
				"    <size>%"G_GINT64_FORMAT"</size>\n"
				"    <md5>%s</md5>\n"
				"   </chunk>\n",
				loc,
				current->position.meta,
				CHUNKS_get_size(current->chunk),
				str_hash);
		g_free(loc);
	}
}
Beispiel #2
0
static void
encode_chunk (GString *g, gpointer bean)
{
	g_string_append_printf(g, "\"id\":\"%s\",\"hash\":\"",
			CHUNKS_get_id(bean)->str);
	metautils_gba_to_hexgstr(g, CHUNKS_get_hash(bean));
	g_string_append_printf(g, "\",\"size\":%"G_GINT64_FORMAT,
			CHUNKS_get_size(bean));
}
Beispiel #3
0
/**
 * Extract host, port and chunk hexadecimal id from a bean.
 *
 * @param bean A pointer to a bean_CHUNKS_s or bean_CONTENTS_s
 * @param[out] host
 * @param[out] port
 * @param[out] chunk_hexid The chunk hexadecimal id (with leading '/')
 * @param[out] err
 */
static void extract_chunk_url(gpointer bean,
		gchar **host, gint *port, gchar **chunk_hexid, GError **err)
{
	gchar *cid_url = NULL;
	if (DESCR(bean) == &descr_struct_CHUNKS) {
		cid_url = CHUNKS_get_id((struct bean_CHUNKS_s*)bean)->str;
	} else if (DESCR(bean) == &descr_struct_CONTENTS) {
		cid_url = CONTENTS_get_chunk_id((struct bean_CONTENTS_s*)bean)->str;
	} else {
		if (err)
			*err = NEWERROR(0, "Invalid 'bean' argument, must be "
					"(struct bean_CHUNKS_s*) or (struct bean_CONTENTS_s*)");
		else
			return;
	}
	return split_chunk_url(cid_url, host, port, chunk_hexid, err);
}
static GSList *
convert_chunks_to_srvinfo(struct grid_lbpool_s *lbp, GSList *src)
{
	GSList *result = NULL;

	for (GSList *l=src; l ;l=l->next) {
		if (!l->data || DESCR(l->data) != &descr_struct_CHUNKS)
			continue;

		struct service_info_s *si = NULL;
		GError *e = service_info_from_chunk_id(lbp, CHUNKS_get_id(l->data)->str, &si);
		if (NULL != e) {
			GRID_WARN("CHUNK -> ServiceInfo conversion error : (%d) %s",
					e->code, e->message);
			g_clear_error(&e);
			continue;
		}
		result = g_slist_prepend(result, si);
	}

	return result;
}
Beispiel #5
0
	void _append_loc(chunk_pair_t *pair) {
		char *loc = _chunk_location_row_xml(lc,
				CHUNKS_get_id(pair->chunk)->str, "");
		urls = g_string_append(urls, loc);
		g_free(loc);
	}