Esempio n. 1
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);
}
Esempio n. 2
0
	int
meta2_filter_action_deduplicate_container(struct gridd_filter_ctx_s *ctx,
		struct gridd_reply_ctx_s *reply)
{
	GSList* result = NULL;   // list of list
	GSList* common_prefixes = NULL;

	SRVSTUB_PRINTF("packet received...DEDUP");

	void send_result()
	{
		GSList *list_of_lists = NULL;
		list_of_lists = gslist_split(result, 32);
		for (GSList *cursor = list_of_lists; cursor; cursor = cursor->next) {
			reply->add_body(bean_sequence_marshall(cursor->data));
			reply->send_reply(206, "Partial content");
		}
		if (NULL != common_prefixes) {
			char **array = (char **)metautils_list_to_array(common_prefixes);
			reply->add_header("COMMON_PREFIXES", metautils_encode_lines(array));
			g_strfreev(array);
		}

		/* TODO : max-keys, truncated */

		reply->send_reply(200, "OK");

		gslist_chunks_destroy(list_of_lists, NULL);
	}
Esempio n. 3
0
int meta2_filter_action_purge_container(struct gridd_filter_ctx_s *ctx,
		struct gridd_reply_ctx_s *reply)
{
	(void) reply;

	SRVSTUB_PRINTF("packet received...PURGE");

	// M2V2_MODE_DRYRUN, ...
	guint32 flags = 0;
	const char *fstr = NULL;
	if (NULL != fstr)
		flags = (guint32) g_ascii_strtoull(fstr, NULL, 10);

	GSList* del_chunks_list = NULL;

	if (NULL != g_err) {
		GRID_DEBUG("Container purge failed (%d) : %s", g_err->code, g_err->message);
		//meta2_filter_ctx_set_error(ctx, err);
		return FILTER_KO;
	}


	reply->add_body(bean_sequence_marshall(g_responsedata));
	reply->send_reply(200, "OK");
	_bean_cleanl2(del_chunks_list);
	return FILTER_OK;
}
Esempio n. 4
0
GByteArray*
m2v2_remote_pack_PROP_SET(GByteArray *sid, struct hc_url_s *url, guint32 flags,
		GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	return _m2v2_pack_request_with_flags("M2V2_PROP_SET", sid, url, body, flags);
}
Esempio n. 5
0
static GByteArray*
m2v2_remote_pack_PROP_SET(struct oio_url_s *url, guint32 flags,
		GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	return _m2v2_pack_request_with_flags(NAME_MSGNAME_M2V2_PROP_SET, url, body, flags);
}
Esempio n. 6
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);
}
Esempio n. 7
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);
}
Esempio n. 8
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);
}
Esempio n. 9
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);
}
Esempio n. 10
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);
}
Esempio n. 11
0
GByteArray*
m2v2_remote_pack_RAW_DEL(GByteArray *sid, struct hc_url_s *url, GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	return _m2v2_pack_request("M2V2_RAW_DEL", sid, url, body);
}
Esempio n. 12
0
					g_slist_concat(obc->l,
						(GSList*)meta2_filter_ctx_get_input_udata(obc->ctx)),
					(GDestroyNotify) _bean_cleanl2, FALSE);
		}
	} else {
		GRID_TRACE("Events disabled, cleaning beans immediately");
		_bean_cleanl2(obc->l);
	}
}

void
_on_bean_ctx_send_list(struct on_bean_ctx_s *obc, gboolean final)
{
	/* marshall the list, send and clean it */
	if (NULL != obc->l) {
		obc->reply->add_body(bean_sequence_marshall(obc->l));
		_on_bean_ctx_append_udata_list(obc);
	}
	if (final)
		obc->reply->send_reply(200, "OK");
	else
		obc->reply->send_reply(206, "CONTINUE");
	obc->l = NULL;
}

void
_on_bean_ctx_clean(struct on_bean_ctx_s *obc)
{
	if(!obc)
		return;
Esempio n. 13
0
static GByteArray*
m2v2_remote_pack_RAW_ADD(struct oio_url_s *url, GSList *beans)
{
	GByteArray *body = bean_sequence_marshall(beans);
	return _m2v2_pack_request(NAME_MSGNAME_M2V2_RAW_ADD, url, body);
}