コード例 #1
0
GError *
peer_restore(const gchar *target, struct sqlx_name_s *name,
		GByteArray *dump)
{
	GError *err = NULL;

	if (!target) {
		g_byte_array_unref(dump);
		return NULL;
	}

	GByteArray *encoded = _pack_RESTORE(name, dump);
	struct gridd_client_s *client = gridd_client_create(target, encoded, NULL, NULL);
	g_byte_array_unref(encoded);

	if (!client)
		return NEWERROR(CODE_INTERNAL_ERROR, "Failed to create client to [%s], bad address?", target);

	gridd_client_set_timeout(client, SQLX_RESYNC_TIMEOUT);
	gridd_client_start(client);
	if (!(err = gridd_client_loop(client)))
		err = gridd_client_error(client);
	gridd_client_free(client);
	return err;
}
コード例 #2
0
ファイル: sqlx_client.c プロジェクト: rootfs/oio-sds
static gint
do_queryv(struct meta1_service_url_s *surl)
{
	gint rc;
	gchar **pq;
	struct gridd_client_s *client;

	GRID_DEBUG("Contacting SHARD[%"G_GINT64_FORMAT"] at [%s][%s]",
			surl->seq, surl->host, surl->args);

	client = gridd_client_create_idle(surl->host);
	gridd_client_set_keepalive(client, TRUE);
	gridd_client_start(client);

	rc = 1;
	for (pq=query; *pq ;pq++) {
		if (!do_query(client, surl, *pq)) {
			rc = 0;
			break;
		}
	}

	gridd_client_free(client);
	return rc;
}
コード例 #3
0
GError*
sqlx_remote_execute_ADMGET(const gchar *target, GByteArray *sid,
		struct sqlx_name_s *name, const gchar *k, gchar **v)
{
	(void) sid;
	GError *err = NULL;
	GByteArray *encoded = sqlx_pack_ADMGET(name, k);
	GByteArray *gba_buf = g_byte_array_new();
	struct client_s *client = gridd_client_create(target, encoded,
			gba_buf, on_reply_gba);
	g_byte_array_unref(encoded);

	gridd_client_start(client);
	if (!(err = gridd_client_loop(client))) {
		if (!(err = gridd_client_error(client))) {
			gchar *buf = g_malloc0(gba_buf->len + 1);
			metautils_gba_data_to_string(gba_buf, buf, gba_buf->len + 1);
			*v = buf;
		}
	}

	gridd_client_free(client);
	metautils_gba_unref(gba_buf);
	return err;
}
コード例 #4
0
ファイル: gridd_client_pool.c プロジェクト: korween/oio-sds
static void
_manage_requests(struct gridd_client_pool_s *pool)
{
	struct event_client_s *ec;

	EXTRA_ASSERT(pool != NULL);

	while (pool->active_count < pool->active_max) {
		ec = g_async_queue_try_pop(pool->pending_clients);
		if (NULL == ec)
			return;
		EXTRA_ASSERT(ec->client != NULL);

		if (!gridd_client_start(ec->client)) {
			GError *err = gridd_client_error(ec->client);
			if (NULL != err) {
				GRID_WARN("STARTUP Client fd=%d [%s] : (%d) %s",
						gridd_client_fd(ec->client), gridd_client_url(ec->client),
						err->code, err->message);
				g_clear_error(&err);
			}
			else {
				GRID_WARN("STARTUP Client fd=%d [%s] : already started",
						gridd_client_fd(ec->client), gridd_client_url(ec->client));
				EXTRA_ASSERT(err != NULL);
			}
			event_client_free(ec);
		}
		else if (!event_client_monitor(pool, ec))
			event_client_free(ec);
	}
}
コード例 #5
0
GError *
gridd_client_run (struct gridd_client_s *self)
{
	if (!self)
		return NEWERROR(CODE_INTERNAL_ERROR, "creation error");
	if (!gridd_client_start(self))
		return NEWERROR(CODE_INTERNAL_ERROR, "starting error");
	GError *err;
	if (NULL != (err = gridd_client_loop (self)))
		return err;
	if (NULL != (err = gridd_client_error (self)))
		return err;
	return NULL;
}
コード例 #6
0
GError*
sqlx_remote_execute_ADMSET(const gchar *target, GByteArray *sid,
		struct sqlx_name_s *name, const gchar *k, const gchar *v)
{
	(void) sid;
	GError *err = NULL;
	GByteArray *encoded = sqlx_pack_ADMSET(name, k, v);
	struct client_s *client = gridd_client_create(target, encoded, NULL, NULL);
	g_byte_array_unref(encoded);
	gridd_client_start(client);
	if (!(err = gridd_client_loop(client)))
		err = gridd_client_error(client);
	gridd_client_free(client);
	return err;
}
コード例 #7
0
ファイル: gridd_client_ext.c プロジェクト: amogrid/redcurrant
void
gridd_clients_start(struct client_s **clients)
{
	if (unlikely(NULL == clients))
		return;
	for (; *clients ;++clients) {
		if (gridd_client_start(*clients))
			continue;
		GError *err = gridd_client_error(*clients);
		GRID_WARN("STARTUP failed fd=%d [%s] : (%d) %s",
					gridd_client_fd(*clients),
					gridd_client_url(*clients),
					err ? err->code : 0,
					err ? err->message : "?");
		if (err)
			g_clear_error(&err);
	}
}
コード例 #8
0
GError*
sqlx_remote_execute_DESTROY(const gchar *target, GByteArray *sid,
		struct sqlx_name_s *name, gboolean local)
{
	(void) sid;
	GError *err = NULL;
	GByteArray *req = sqlx_pack_DESTROY(name, local);

	struct gridd_client_s *client = gridd_client_create(target, req, NULL, NULL);
	g_byte_array_unref(req);

	gridd_client_start(client);
	if (!(err = gridd_client_loop(client))) {
		err = gridd_client_error(client);
	}

	gridd_client_free(client);
	return err;
}