예제 #1
0
static GByteArray*
m2v2_remote_pack_STGPOL(struct oio_url_s *url, const char *pol)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_STGPOL, url, NULL);
	metautils_message_add_field_str(msg, NAME_MSGKEY_STGPOLICY, pol);
	return message_marshall_gba_and_clean(msg);
}
예제 #2
0
static GByteArray*
m2v2_remote_pack_LIST(struct oio_url_s *url, struct list_params_s *p)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_LIST, url, NULL);
	_pack_list_params (msg, p);
	return message_marshall_gba_and_clean(msg);
}
예제 #3
0
static GByteArray *
_m2v2_pack_request(const gchar *name, GByteArray *sid,
		struct hc_url_s *url, GByteArray *body)
{
	return message_marshall_gba_and_clean(
			_m2v2_build_request(name, sid, url, body));
}
예제 #4
0
static GByteArray*
m2v2_remote_pack_PUT(struct oio_url_s *url, GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	MESSAGE msg = _m2v2_build_request (NAME_MSGNAME_M2V2_PUT, url, body);
	return message_marshall_gba_and_clean(msg);
}
예제 #5
0
static GByteArray*
m2v2_remote_pack_OVERWRITE(struct oio_url_s *url, GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_PUT, url, body);
	metautils_message_add_field_str(msg, NAME_MSGKEY_OVERWRITE, "1");
	return message_marshall_gba_and_clean(msg);
}
예제 #6
0
static GByteArray *
_m2v2_pack_request_with_flags(const char *name, struct oio_url_s *url,
		GByteArray *body, guint32 flags)
{
	MESSAGE msg = _m2v2_build_request(name, url, body);
	flags = g_htonl(flags);
	metautils_message_add_field(msg, NAME_MSGKEY_FLAGS, &flags, sizeof(flags));
	return message_marshall_gba_and_clean(msg);
}
예제 #7
0
static GByteArray*
m2v2_remote_pack_LIST_BY_CHUNKID(struct oio_url_s *url, struct list_params_s *p,
		const char *chunk)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_LCHUNK, url, NULL);
	_pack_list_params (msg, p);
	metautils_message_add_field_str (msg, NAME_MSGKEY_KEY, chunk);
	return message_marshall_gba_and_clean(msg);
}
예제 #8
0
GByteArray*
m2v2_remote_pack_STGPOL(GByteArray *sid, struct hc_url_s *url,
		const gchar *pol)
{
	struct message_s *msg;

	msg = _m2v2_build_request("M2V2_STGPOL", sid, url, NULL);
	message_add_fields_str(msg, "STORAGE_POLICY", pol, NULL);
	return message_marshall_gba_and_clean(msg);
}
예제 #9
0
static GByteArray*
m2v2_remote_pack_LIST_BY_HEADERID(struct oio_url_s *url, struct list_params_s *p,
		GBytes *h)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_LHID, url, NULL);
	_pack_list_params (msg, p);
	metautils_message_add_field (msg, NAME_MSGKEY_KEY,
			g_bytes_get_data(h,NULL), g_bytes_get_size(h));
	return message_marshall_gba_and_clean(msg);
}
예제 #10
0
GByteArray*
m2v2_remote_pack_SNAP_RESTORE(GByteArray *sid, struct hc_url_s *url,
		gboolean hard_restore)
{
	struct message_s *msg;
	msg = _m2v2_build_request("M2V2_SNAP_RESTORE", sid, url, NULL);
	message_add_field(msg,
			M2_KEY_SNAPSHOT_HARDRESTORE, sizeof(M2_KEY_SNAPSHOT_HARDRESTORE),
			(guint8*)&hard_restore, sizeof(guint8), NULL);
	return message_marshall_gba_and_clean(msg);
}
예제 #11
0
static GByteArray *
_m2v2_pack_request_with_flags(const gchar *name, GByteArray *sid,
		struct hc_url_s *url, GByteArray *body, guint32 flags)
{
	struct message_s *msg;

	msg = _m2v2_build_request(name, sid, url, body);
	flags = g_htonl(flags);
	(void) message_add_field(msg, "FLAGS", sizeof("FLAGS")-1,
			&flags, sizeof(flags), NULL);
	return message_marshall_gba_and_clean(msg);
}
예제 #12
0
GByteArray*
m2v2_remote_pack_COPY(GByteArray *sid, struct hc_url_s *url, const gchar *src)
{
	struct message_s *msg;

	msg = _m2v2_build_request("M2V2_PUT", sid, url, NULL);
	(void) message_add_field(msg,
				M2_KEY_COPY_SOURCE, sizeof(M2_KEY_COPY_SOURCE)-1,
				src, strlen(src),
				NULL);
	return message_marshall_gba_and_clean(msg);
}
예제 #13
0
GByteArray*
m2v2_remote_pack_OVERWRITE(GByteArray *sid, struct hc_url_s *url, GSList *beans)
{
	struct message_s *msg;
	GByteArray *body = bean_sequence_marshall(beans);
	msg = _m2v2_build_request("M2V2_PUT", sid, url, body);
	(void) message_add_field(msg,
				M2_KEY_OVERWRITE, sizeof(M2_KEY_OVERWRITE)-1,
				"1", 1,
				NULL);
	return message_marshall_gba_and_clean(msg);
}
예제 #14
0
static GByteArray*
m2v2_remote_pack_BEANS(struct oio_url_s *url, const char *pol, gint64 size, gboolean append)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_BEANS, url, NULL);
	metautils_message_add_field_strint64 (msg, NAME_MSGKEY_CONTENTLENGTH, size);
	metautils_message_add_field_str (msg, NAME_MSGKEY_STGPOLICY, pol);
	if (append)
		metautils_message_add_field_str (msg, NAME_MSGKEY_APPEND, "true");

	/* si policy est NULL, le paramètre ne sera pas ajouté. On profite que
	 * ce soit ldernier argument de la liste */
	return message_marshall_gba_and_clean(msg);
}
예제 #15
0
GByteArray*
m2v2_remote_pack_GET_BY_CHUNK(GByteArray *sid, struct hc_url_s *url,
		const gchar *chunk_id, gint64 limit)
{
	struct message_s *msg;
	gchar limit_str[16];
	g_snprintf(limit_str, 16, "%"G_GINT64_FORMAT, limit);
	msg = _m2v2_build_request("M2V2_GET", sid, url, NULL);
	message_add_fields_str(msg,
			M2_KEY_CHUNK_ID, chunk_id,
			M2_KEY_MAX_KEYS, limit_str,
			NULL);
    return message_marshall_gba_and_clean(msg);
}
예제 #16
0
static GByteArray*
m2v2_remote_pack_RAW_SUBST(struct oio_url_s *url,
		GSList *new_chunks, GSList *old_chunks)
{
	GByteArray *new_chunks_gba = bean_sequence_marshall(new_chunks);
	GByteArray *old_chunks_gba = bean_sequence_marshall(old_chunks);
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_RAW_SUBST, url, NULL);
	metautils_message_add_fields_gba(msg,
			NAME_MSGKEY_NEW, new_chunks_gba,
			NAME_MSGKEY_OLD, old_chunks_gba,
			NULL);
	g_byte_array_unref (new_chunks_gba);
	g_byte_array_unref (old_chunks_gba);
	return message_marshall_gba_and_clean(msg);
}
예제 #17
0
static GByteArray*
m2v2_remote_pack_DESTROY(struct oio_url_s *url, guint32 flags)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_DESTROY, url, NULL);
	if (flags & M2V2_DESTROY_FORCE)
		metautils_message_add_field_str(msg, NAME_MSGKEY_FORCE, "1");
	if (flags & M2V2_DESTROY_FLUSH)
		metautils_message_add_field_str(msg, NAME_MSGKEY_FLUSH, "1");
	if (flags & M2V2_DESTROY_PURGE)
		metautils_message_add_field_str(msg, NAME_MSGKEY_PURGE, "1");
	if (flags & M2V2_DESTROY_LOCAL)
		metautils_message_add_field_str(msg, NAME_MSGKEY_LOCAL, "1");

	return message_marshall_gba_and_clean(msg);
}
예제 #18
0
GByteArray*
m2v2_remote_pack_DESTROY(GByteArray *sid, struct hc_url_s *url, guint32 flags)
{
	struct message_s *msg;
	msg = _m2v2_build_request("M2V2_DESTROY", sid, url, NULL);
	if (flags & M2V2_DESTROY_FORCE)
		message_add_fields_str(msg, "FORCE", "1", NULL);
	if (flags & M2V2_DESTROY_FLUSH)
		message_add_fields_str(msg, "FLUSH", "1", NULL);
	if (flags & M2V2_DESTROY_PURGE)
		message_add_fields_str(msg, "PURGE", "1", NULL);
	if (flags & M2V2_DESTROY_LOCAL)
		message_add_fields_str(msg, "LOCAL", "1", NULL);

	return message_marshall_gba_and_clean(msg);
}
예제 #19
0
static GByteArray*
m2v2_remote_pack_CREATE(struct oio_url_s *url, struct m2v2_create_params_s *pols)
{
	MESSAGE msg = _m2v2_build_request(NAME_MSGNAME_M2V2_CREATE, url, NULL);
	if (pols && pols->storage_policy)
		metautils_message_add_field_str(msg, NAME_MSGKEY_STGPOLICY, pols->storage_policy);
	if (pols && pols->version_policy)
		metautils_message_add_field_str(msg, NAME_MSGKEY_VERPOLICY, pols->version_policy);
	if (pols && pols->properties) {
		for (gchar **p=pols->properties; *p && *(p+1) ;p+=2) {
			gchar *k = g_strconcat (NAME_MSGKEY_PREFIX_PROPERTY, *p, NULL);
			metautils_message_add_field_str (msg, k, *(p+1));
			g_free (k);
		}
	}

	return message_marshall_gba_and_clean(msg);
}
예제 #20
0
GByteArray*
m2v2_remote_pack_SPARE(GByteArray *sid, struct hc_url_s *url,
		const gchar *pol, GSList *notin_list, GSList *broken_list)
{
	struct message_s *msg;
	gchar *spare_type = M2V2_SPARE_BY_STGPOL;
	GByteArray *body = NULL;
	GSList *beans = NULL;

	if (notin_list != NULL) {
		spare_type = M2V2_SPARE_BY_BLACKLIST;
		for (GSList *l = notin_list; l != NULL; l = l->next) {
			if (DESCR(l->data) != &descr_struct_CHUNKS)
				continue;
			beans = g_slist_prepend(beans, _bean_dup(l->data));
		}
	}

	for (GSList *l = broken_list; l != NULL; l = l->next) {
		if (DESCR(l->data) != &descr_struct_CHUNKS)
			continue;
		struct bean_CHUNKS_s *chunk = _bean_dup(l->data);
		// This makes difference between valid and broken chunks
		CHUNKS_set_size(chunk, -1);
		beans = g_slist_prepend(beans, chunk);
	}

	/* body is only mandatory for M2V2_SPARE_BY_BLACKLIST so when
	 * notin_list != NULL. If not_in_list != NULL, beans is always
	 * != NULL so body is sent.
	 */
	if (beans != NULL)
		body = bean_sequence_marshall(beans);

	msg = _m2v2_build_request("M2V2_BEANS", sid, url, body);
	message_add_fields_str(msg,
			M2_KEY_STORAGE_POLICY, pol,
			M2_KEY_SPARE, spare_type,
			NULL);

	_bean_cleanl2(beans);
	return message_marshall_gba_and_clean(msg);
}
예제 #21
0
GByteArray*
m2v2_remote_pack_CREATE(GByteArray *sid, struct hc_url_s *url,
		struct m2v2_create_params_s *pols)
{
	struct message_s *msg;

	msg = _m2v2_build_request("M2V2_CREATE", sid, url, NULL);
	if (pols && pols->storage_policy) {
		(void) message_add_field(msg,
				M2_KEY_STORAGE_POLICY, sizeof(M2_KEY_STORAGE_POLICY)-1,
				pols->storage_policy, strlen(pols->storage_policy),
				NULL);
	}
	if (pols && pols->version_policy) {
		(void) message_add_field(msg,
				M2_KEY_VERSION_POLICY, sizeof(M2_KEY_VERSION_POLICY)-1,
				pols->version_policy, strlen(pols->version_policy),
				NULL);
	}
	return message_marshall_gba_and_clean(msg);
}
예제 #22
0
GByteArray*
m2v2_remote_pack_SUBST_CHUNKS(GByteArray *sid, struct hc_url_s *url,
		GSList *new_chunks, GSList *old_chunks, gboolean restrict_to_alias)
{
	struct message_s *msg;
	GByteArray *new_chunks_gba = bean_sequence_marshall(new_chunks);
	GByteArray *old_chunks_gba = bean_sequence_marshall(old_chunks);
	msg = _m2v2_build_request("M2V2_SUBST_CHUNKS", sid, url, NULL);
	if (restrict_to_alias) {
		(void) message_add_field(msg,
				M2_KEY_RESTRICT_TO_ALIAS, sizeof(M2_KEY_RESTRICT_TO_ALIAS)-1,
				"TRUE", 5, NULL);
	}
	message_add_fields_gba(msg,
			M2_KEY_NEW_CHUNKS, new_chunks_gba,
			M2_KEY_OLD_CHUNKS, old_chunks_gba,
			NULL);
	g_byte_array_unref(new_chunks_gba);
	g_byte_array_unref(old_chunks_gba);
	return message_marshall_gba_and_clean(msg);
}
예제 #23
0
GByteArray*
m2v2_remote_pack_BEANS(GByteArray *sid, struct hc_url_s *url,
		const gchar *pol, gint64 size, gboolean append)
{
	gchar strsize[128];
	struct message_s *msg;

	g_snprintf(strsize, sizeof(strsize), "%"G_GINT64_FORMAT, size);

	msg = _m2v2_build_request("M2V2_BEANS", sid, url, NULL);
	if(!append) {
		message_add_fields_str(msg,
				NAME_MSGKEY_CONTENTLENGTH, strsize,
				"STORAGE_POLICY", pol, NULL);
	} else {
		message_add_fields_str(msg,
				NAME_MSGKEY_CONTENTLENGTH, strsize,
				"APPEND", "true",
				"STORAGE_POLICY", pol, NULL);
	}
	/* si policy est NULL, le paramètre ne sera pas ajouté. On profite que
	 * ce soit ldernier argument de la liste */
	return message_marshall_gba_and_clean(msg);
}
예제 #24
0
static GByteArray*
m2v2_remote_pack_LINK(struct oio_url_s *url)
{
	return message_marshall_gba_and_clean(_m2v2_build_request(NAME_MSGNAME_M2V2_LINK, url, NULL));
}