void initialize_watch_events(struct rmonitor_file_watch_info *f, struct jx *watch_spec) { struct jx *events_array = jx_lookup(watch_spec, "events"); if(!events_array) { fatal("File watch for '%s' did not define any events", f->filename); } if(!jx_istype(events_array, JX_ARRAY)) { fatal("Value for key 'events' in file watch for '%s' is not an array.", f->filename); } f->events = list_create(0); struct jx *event_spec; int error = 0; for (void *i = NULL; (event_spec = jx_iterate_array(events_array, &i));) { struct rmonitor_file_watch_event *e = parse_event(f->filename, event_spec); if(e) { if(e->on_pattern) { // at least one event defines a pattern, thus we need line by // line processing. f->event_with_pattern = 1; } list_push_tail(f->events, e); debug(D_RMON, "Added event for file '%s', label '%s', max_count %" PRId64, f->filename, e->label, e->max_count); } else { error = 1; } } if(error) { fatal("Error parsing file watch for '%s'.", f->filename); } }
static void update_blacklisted_workers( struct batch_queue *queue, struct list *masters_list ) { if(!masters_list || list_size(masters_list) < 1) return; buffer_t b; struct jx *j; buffer_init(&b); const char *sep = ""; list_first_item(masters_list); while((j=list_next_item(masters_list))) { struct jx *blacklisted = jx_lookup(j,"workers_blacklisted"); if(!blacklisted) { continue; } if(jx_istype(blacklisted, JX_STRING)) { buffer_printf(&b, "%s%s", sep, blacklisted->u.string_value); sep = " "; } if(jx_istype(blacklisted, JX_ARRAY)) { struct jx *item; for (void *i = NULL; (item = jx_iterate_array(blacklisted, &i));) { if(jx_istype(item, JX_STRING)) { buffer_printf(&b, "%s%s", sep, item->u.string_value); sep = " "; } } } } if(buffer_pos(&b) > 0) { batch_queue_set_option(queue, "workers-blacklisted", buffer_tostring(&b)); } else { batch_queue_set_option(queue, "workers-blacklisted", NULL); } buffer_free(&b); }