Exemplo n.º 1
0
	void queue_peek(ioremap::elliptics::session client, int req_unique_id, int arg)
	{
		client.set_exceptions_policy(ioremap::elliptics::session::no_exceptions);

		std::string queue_key = std::to_string(req_unique_id) + std::to_string(rand());

		auto req = std::make_shared<request>(req_unique_id);
		client.transform(queue_key, req->id);

		client.exec(&req->id, req->src_key, "queue@peek-multi", std::to_string(arg))
			.connect(
				std::bind(&queue_pump::data_received, this, req, std::placeholders::_1),
				std::bind(&queue_pump::request_complete, this, req, std::placeholders::_1)
			);
	}
Exemplo n.º 2
0
void Key::transform(ioremap::elliptics::session &sess)
{
        struct dnet_id id;
        memset(&id, 0, sizeof(id));

        sess.transform(filename_, id);

        id_ = ID(id);
        byId_ = true;
}
Exemplo n.º 3
0
	void queue_ack(ioremap::elliptics::session client,
			std::shared_ptr<request> req,
			ioremap::elliptics::exec_context context,
			const std::vector<ioremap::grape::entry_id> &ids)
	{
		client.set_exceptions_policy(ioremap::elliptics::session::no_exceptions);

		size_t count = ids.size();
		client.exec(context, "queue@ack-multi", ioremap::grape::serialize(ids))
			.connect(
				ioremap::elliptics::async_result<ioremap::elliptics::exec_result_entry>::result_function(),
				[req, count] (const ioremap::elliptics::error_info &error) {
					if (error) {
						fprintf(stderr, "%s %d, %ld entries not acked: %s\n", dnet_dump_id(&req->id), req->src_key, count, error.message().c_str());
					} else {
						fprintf(stderr, "%s %d, %ld entries acked\n", dnet_dump_id(&req->id), req->src_key, count);
					}
				}
			);
	}
Exemplo n.º 4
0
bool elliptics_base::prepare_session(const rapidjson::Value &config, ioremap::elliptics::session &session)
{
	if (!config.HasMember("groups")) {
		m_logger.log(swarm::LOG_ERROR, "\"groups\" field is missed");
		return false;
	}

	std::vector<int> groups;

	auto &groupsArray = config["groups"];
	std::transform(groupsArray.Begin(), groupsArray.End(),
		std::back_inserter(groups),
		std::bind(&rapidjson::Value::GetInt, std::placeholders::_1));

	session.set_groups(groups);

	return true;
}
Exemplo n.º 5
0
ioremap::swarm::http_response::status_type elliptics_base::process(const swarm::http_request &request, ioremap::elliptics::key &key, ioremap::elliptics::session &session) const
{
	const auto &query = request.url().query();

	if (auto name = query.item_value("name")) {
		key = *name;
	} else if (auto sid = query.item_value("id")) {
		struct dnet_id id;
		memset(&id, 0, sizeof(struct dnet_id));

		dnet_parse_numeric_id(sid->c_str(), id.id);

		key = id;
	} else {
		return ioremap::swarm::http_response::bad_request;
	}

	session.transform(key);

	(void) session;

	return ioremap::swarm::http_response::ok;
}