Пример #1
0
static GError *
__notify_services(struct meta1_backend_s *m1, struct sqlx_sqlite3_s *sq3,
                  struct oio_url_s *url)
{
    if (!m1->notifier)
        return NULL;

    struct meta1_service_url_s **services = NULL;
    GError *err = __get_container_all_services(sq3, url, NULL, &services);
    if (!err) {
        struct meta1_service_url_s **services2 = expand_urlv(services);
        GString *notif = g_string_sized_new(128);
        g_string_append (notif, "{\"event\":\""NAME_SRVTYPE_META1".account.services\"");
        g_string_append_printf (notif, ",\"when\":%"G_GINT64_FORMAT, oio_ext_real_time());
        g_string_append (notif, ",\"data\":{");
        g_string_append_printf (notif, "\"url\":\"%s\"", oio_url_get(url, OIOURL_WHOLE));
        g_string_append (notif, ",\"services\":[");
        if (services2) {
            for (struct meta1_service_url_s **svc = services2; *svc ; svc++) {
                if (svc != services2) // not at the beginning
                    g_string_append(notif, ",");
                meta1_service_url_encode_json(notif, *svc);
            }
        }
        g_string_append(notif, "]}}");

        oio_events_queue__send (m1->notifier, g_string_free(notif, FALSE));

        meta1_service_url_cleanv(services2);
        meta1_service_url_cleanv(services);
    }
    return err;
}
Пример #2
0
static GError *
__notify_services(struct meta1_backend_s *m1, struct sqlx_sqlite3_s *sq3,
		struct oio_url_s *url)
{
	if (!m1->notifier)
		return NULL;

	struct meta1_service_url_s **services = NULL;
	GError *err = __get_container_all_services(sq3, url, NULL, &services);
	if (!err) {
		struct meta1_service_url_s **services2 = expand_urlv(services);
		GString *notif = oio_event__create ("account.services", url);
		g_string_append (notif, ",\"data\":[");
		if (services2) {
			for (struct meta1_service_url_s **svc = services2; *svc ; svc++) {
				if (svc != services2) // not at the beginning
					g_string_append(notif, ",");
				meta1_service_url_encode_json(notif, *svc);
			}
		}
		g_string_append(notif, "]}");

		oio_events_queue__send (m1->notifier, g_string_free(notif, FALSE));

		meta1_service_url_cleanv(services2);
		meta1_service_url_cleanv(services);
	}
	return err;
}
Пример #3
0
GError *
rawx_event_send (const char *event_type, GString *data_json)
{
	EXTRA_ASSERT(q != NULL);

	GString *json = oio_event__create (event_type, NULL);
	g_string_append_printf(json, ",\"data\":%.*s}",
			(int) data_json->len, data_json->str);
	g_string_free (data_json, TRUE);
	oio_events_queue__send (q, g_string_free (json, FALSE));

	return NULL;
}
static void
_notify_beans (struct meta2_backend_s *m2b, struct oio_url_s *url,
		GSList *beans, const char *name)
{
	void forward (GSList *list_of_beans) {
		gchar tmp[256];
		g_snprintf (tmp, sizeof(tmp), "%s.%s", META2_EVENTS_PREFIX, name);

		GString *gs = oio_event__create (tmp, url);
		g_string_append (gs, ",\"data\":[");
		meta2_json_dump_all_xbeans (gs, list_of_beans);
		g_string_append (gs, "]}");
		oio_events_queue__send (m2b->notifier, g_string_free (gs, FALSE));
	}
Пример #5
0
static void
test_queue_stalled (void)
{
	struct oio_events_queue_s *q =
		oio_events_queue_factory__create_agent ("inproc://X", 100);
	g_assert_nonnull (q);

	g_assert_false (oio_events_queue__is_stalled (q));
	for (guint i=0; i<100 ;++i)
		oio_events_queue__send (q, g_strdup ("x"));

	/* XXX(jfs): ugly way to give a chance to the internal thread to consume
	   events and update counters. */
	g_thread_yield ();
	g_usleep (100 * G_TIME_SPAN_MILLISECOND);

	g_assert_true (oio_events_queue__is_stalled (q));
	for (guint i=0; i<1000 ;++i)
		oio_events_queue__send (q, g_strdup ("x"));
	g_assert_true (oio_events_queue__is_stalled (q));

	oio_events_queue__run_agent (q, immediately_done);
	oio_events_queue__destroy (q);
}