root/src/stratcon_iep.c

Revision 35d80a0f98b37605f57c21fbd5751fce4958910f, 20.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 4 years ago)

fixes #244

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include "noit_defines.h"
34 #include "eventer/eventer.h"
35 #include "utils/noit_log.h"
36 #include "utils/noit_b64.h"
37 #include "noit_jlog_listener.h"
38 #include "stratcon_jlog_streamer.h"
39 #include "stratcon_datastore.h"
40 #include "stratcon_iep.h"
41 #include "noit_conf.h"
42 #include "noit_check.h"
43
44 #include <sys/types.h>
45 #ifdef HAVE_SYS_WAIT_H
46 #include <sys/wait.h>
47 #endif
48 #include <sys/stat.h>
49 #include <fcntl.h>
50 #include <unistd.h>
51 #include <sys/fcntl.h>
52 #ifdef HAVE_SYS_FILIO_H
53 #include <sys/filio.h>
54 #endif
55 #include <signal.h>
56 #include <errno.h>
57 #include <assert.h>
58
59 eventer_jobq_t iep_jobq;
60 static noit_log_stream_t noit_iep = NULL;
61 static noit_spinlock_t iep_conn_cnt = 0;
62
63 static pthread_key_t iep_connection;
64 static noit_hash_table mq_drivers = NOIT_HASH_EMPTY;
65 static mq_driver_t *mq_driver = NULL;
66
67 static int iep_system_enabled = 1;
68 int stratcon_iep_get_enabled() { return iep_system_enabled; }
69 void stratcon_iep_set_enabled(int n) { iep_system_enabled = n; }
70
71
72 struct iep_job_closure {
73   char *line;       /* This is a copy and gets trashed during processing */
74   char *remote;
75   char *doc_str;
76 };
77
78 static void
79 start_iep_daemon();
80
81 static float
82 stratcon_iep_age_from_line(char *data, struct timeval now) {
83   float n, t;
84   if(data && (*data == 'S' || *data == 'M')) {
85     if(data[1] != '\t') return 0;
86     t = strtof(data + 2, NULL);
87     n = (float)now.tv_sec + (float)now.tv_usec / 1000000.0;
88     return n - t;
89   }
90   return 0;
91 }
92
93 struct statement_node {
94   char *id;
95   char *statement;
96   char *provides;
97   int marked; /* helps with identifying cycles */
98   int nrequires;
99   struct statement_node **requires;
100 };
101 static void
102 statement_node_free(void *vstmt) {
103   struct statement_node *stmt = vstmt;
104   if(stmt->id) free(stmt->id);
105   if(stmt->statement) free(stmt->statement);
106   if(stmt->provides) free(stmt->provides);
107   if(stmt->requires) free(stmt->requires);
108 }
109 static int
110 stmt_mark_dag(struct statement_node *stmt, int mgen) {
111   int i;
112   assert(stmt->marked <= mgen);
113   if(stmt->marked == mgen) return -1;
114   if(stmt->marked > 0) return 0; /* validated in a previous sweep */
115   stmt->marked = mgen;
116   for(i=0; i<stmt->nrequires; i++)
117     if(stmt_mark_dag(stmt->requires[i], mgen) < 0) return -1;
118   return 0;
119 }
120 static void
121 submit_statement_node(struct statement_node *stmt) {
122   int line_len, i;
123   char *line, *cp;
124
125   if(stmt->marked) return;
126   for(i=0; i<stmt->nrequires; i++)
127     submit_statement_node(stmt->requires[i]);
128
129   line_len = 3 /* 2 tabs + \0 */ +
130              1 /* 'D' */ + 1 /* '\n' */ +
131              strlen(stmt->id) + strlen(stmt->statement);
132   line = malloc(line_len);
133   snprintf(line, line_len, "D\t%s\t%s\n", stmt->id, stmt->statement);
134   cp = line;
135   while(cp[0] && cp[1]) {
136     if(*cp == '\n') *cp = ' ';
137     cp++;
138   }
139   noitL(noit_error, "submitting statement: %s\n", line);
140   stratcon_iep_line_processor(DS_OP_INSERT, NULL, NULL, line, NULL);
141   stmt->marked = 1;
142 }
143 void stratcon_iep_submit_statements() {
144   int i, cnt = 0;
145   noit_conf_section_t *statement_configs;
146   char path[256];
147   struct statement_node *stmt;
148   void *vstmt;
149   noit_hash_table stmt_by_id = NOIT_HASH_EMPTY;
150   noit_hash_table stmt_by_provider = NOIT_HASH_EMPTY;
151   noit_hash_iter iter = NOIT_HASH_ITER_ZERO;
152   const char *key;
153   int klen, mgen = 0;
154
155   snprintf(path, sizeof(path), "/stratcon/iep/queries//statement");
156   statement_configs = noit_conf_get_sections(NULL, path, &cnt);
157   noitL(noit_debug, "Found %d %s stanzas\n", cnt, path);
158
159   /* Phase 1: sweep in all the statements */
160   for(i=0; i<cnt; i++) {
161     char id[UUID_STR_LEN+1];
162     char provides[256];
163     char *statement;
164
165     if(!noit_conf_get_stringbuf(statement_configs[i],
166                                 "self::node()/@id",
167                                 id, sizeof(id))) {
168       noitL(noit_iep, "No uuid specified in query\n");
169       continue;
170     }
171     if(!noit_conf_get_stringbuf(statement_configs[i],
172                                 "ancestor-or-self::node()/@provides",
173                                 provides, sizeof(provides))) {
174       provides[0] = '\0';
175     }
176     if(!noit_conf_get_string(statement_configs[i], "self::node()/epl",
177                              &statement)) {
178       noitL(noit_iep, "No contents specified in statement\n");
179       continue;
180     }
181     stmt = calloc(1, sizeof(*stmt));
182     stmt->id = strdup(id);
183     stmt->statement = statement;
184     stmt->provides = provides[0] ? strdup(provides) : NULL;
185     if(!noit_hash_store(&stmt_by_id, stmt->id, strlen(stmt->id), stmt)) {
186       noitL(noit_error, "Duplicate statement id: %s\n", stmt->id);
187       exit(-1);
188     }
189     if(stmt->provides) {
190       if(!noit_hash_store(&stmt_by_provider, stmt->provides,
191                           strlen(stmt->provides), stmt)) {
192         noitL(noit_error, "Two statements provide: '%s'\n", stmt->provides);
193         exit(-1);
194       }
195     }
196   }
197
198   /* Phase 2: load the requires graph */
199   for(i=0; i<cnt; i++) {
200     char id[UUID_STR_LEN+1];
201     int rcnt, j;
202     char *requires;
203     noit_conf_section_t *reqs;
204
205     if(!noit_conf_get_stringbuf(statement_configs[i],
206                                 "self::node()/@id",
207                                 id, sizeof(id))) {
208       noitL(noit_iep, "No uuid specified in query\n");
209       continue;
210     }
211     if(!noit_hash_retrieve(&stmt_by_id, id, strlen(id), &vstmt)) {
212       noitL(noit_error, "Cannot find statement: %s\n", id);
213       exit(-1);
214     }
215     stmt = vstmt;
216     reqs = noit_conf_get_sections(statement_configs[i],
217                                   "self::node()/requires", &rcnt);
218     if(rcnt > 0) {
219       stmt->requires = malloc(rcnt * sizeof(*(stmt->requires)));
220       for(j=0; j<rcnt; j++) {
221         void *vrstmt;
222         if(!noit_conf_get_string(reqs[j], "self::node()",
223                                  &requires) || requires[0] == '\0') {
224           continue;
225         }
226         if(!noit_hash_retrieve(&stmt_by_provider, requires, strlen(requires),
227                                &vrstmt)) {
228           noitL(noit_error,
229                 "Statement %s requires %s which no one provides.\n",
230                 stmt->id, requires);
231           exit(-1);
232         }
233         stmt->requires[stmt->nrequires++] = vrstmt;
234       }
235     }
236   }
237
238   /* Phase 3: Recursive sweep and mark to detect cycles.
239      We're walking the graph backwards here from dependent to provider,
240      but a cycle is a cycle, so this validates the graph. */
241   while(noit_hash_next(&stmt_by_id, &iter, &key, &klen, &vstmt)) {
242     stmt = vstmt;
243     if(stmt_mark_dag(stmt, ++mgen) < 0) {
244       noitL(noit_error, "Statement %s has a cyclic requirement\n", stmt->id);
245       exit(-1);
246     }
247   }
248
249   /* Phase 4: clean the markings */
250   mgen = 0;
251   memset(&iter, 0, sizeof(iter));
252   while(noit_hash_next(&stmt_by_id, &iter, &key, &klen, &vstmt)) {
253     stmt = vstmt;
254     stmt->marked = 0;
255   }
256
257   /* Phase 5: do the load */
258   memset(&iter, 0, sizeof(iter));
259   while(noit_hash_next(&stmt_by_id, &iter, &key, &klen, &vstmt)) {
260     stmt = vstmt;
261     submit_statement_node(stmt);
262   }
263
264   noit_hash_destroy(&stmt_by_provider, NULL, NULL);
265   noit_hash_destroy(&stmt_by_id, NULL, statement_node_free);
266   free(statement_configs);
267 }
268
269 void stratcon_iep_submit_queries() {
270   int i, cnt = 0;
271   noit_conf_section_t *query_configs;
272   char path[256];
273
274   snprintf(path, sizeof(path), "/stratcon/iep/queries//query");
275   query_configs = noit_conf_get_sections(NULL, path, &cnt);
276   noitL(noit_debug, "Found %d %s stanzas\n", cnt, path);
277   for(i=0; i<cnt; i++) {
278     char id[UUID_STR_LEN+1];
279     char topic[256];
280     char *query;
281     char *line;
282     int line_len;
283
284     if(!noit_conf_get_stringbuf(query_configs[i],
285                                 "self::node()/@id",
286                                 id, sizeof(id))) {
287       noitL(noit_iep, "No uuid specified in query\n");
288       continue;
289     }
290     if(!noit_conf_get_stringbuf(query_configs[i],
291                                 "ancestor-or-self::node()/@topic",
292                                 topic, sizeof(topic))) {
293       noitL(noit_iep, "No topic specified in query\n");
294       continue;
295     }
296     if(!noit_conf_get_string(query_configs[i], "self::node()/epl",
297                              &query)) {
298       noitL(noit_iep, "No contents specified in query\n");
299       continue;
300     }
301     line_len = 4 /* 3 tabs + \0 */ +
302                1 /* 'Q' */ + 1 /* '\n' */ +
303                strlen(id) + strlen(topic) + strlen(query);
304     line = malloc(line_len);
305     snprintf(line, line_len, "Q\t%s\t%s\t%s\n", id, topic, query);
306     free(query);
307     query = line;
308     while(query[0] && query[1]) {
309       if(*query == '\n') *query = ' ';
310       query++;
311     }
312     stratcon_iep_line_processor(DS_OP_INSERT, NULL, NULL, line, NULL);
313   }
314   free(query_configs);
315 }
316
317 static
318 struct iep_thread_driver *stratcon_iep_get_connection() {
319   int rc;
320   struct iep_thread_driver *driver;
321   driver = pthread_getspecific(iep_connection);
322   if(!driver) {
323     driver = mq_driver->allocate();
324     pthread_setspecific(iep_connection, driver);
325   }
326
327   rc = mq_driver->connect(driver);
328   if(rc < 0) return NULL;
329   if(rc == 0) {
330     /* Initial connect */
331     /* TODO: this should be requested by Esper, not blindly pushed */
332     stratcon_iep_submit_statements();
333     stratcon_datastore_iep_check_preload();
334     stratcon_iep_submit_queries();
335   }
336
337   return driver;
338 }
339
340 static int
341 setup_iep_connection_callback(eventer_t e, int mask, void *closure,
342                               struct timeval *now) {
343   noit_spinlock_unlock(&iep_conn_cnt);
344   stratcon_iep_line_processor(DS_OP_INSERT, NULL, NULL, NULL, NULL);
345   return 0;
346 }
347
348 static void
349 setup_iep_connection_later(int seconds) {
350   eventer_t newe;
351   if(!noit_spinlock_trylock(&iep_conn_cnt)) return;
352   newe = eventer_alloc();
353   gettimeofday(&newe->whence, NULL);
354   newe->whence.tv_sec += seconds;
355   newe->mask = EVENTER_TIMER;
356   newe->callback = setup_iep_connection_callback;
357   newe->closure = NULL;
358   eventer_add(newe);
359 }
360
361 static int
362 stratcon_iep_submitter(eventer_t e, int mask, void *closure,
363                        struct timeval *now) {
364   float age;
365   struct iep_job_closure *job = closure;
366   struct iep_thread_driver *driver;
367   /* We only play when it is an asynch event */
368   if(!(mask & EVENTER_ASYNCH_WORK)) return 0;
369
370   if(mask & EVENTER_ASYNCH_CLEANUP) {
371     /* free all the memory associated with the batch */
372     if(job) {
373       if(job->line) free(job->line);
374       if(job->remote) free(job->remote);
375       if(job->doc_str) free(job->doc_str);
376       free(job);
377     }
378     return 0;
379   }
380   driver = stratcon_iep_get_connection();
381   if(!driver) setup_iep_connection_later(1);
382
383   if(!job->line || job->line[0] == '\0') return 0;
384
385   if((age = stratcon_iep_age_from_line(job->line, *now)) > 60) {
386     noitL(noit_debug, "Skipping old event from %s, %f seconds old.\n",
387           job->remote ? job->remote : "(null)", age);
388     return 0;
389   }
390   /* Submit */
391   if(driver) {
392     int line_len = strlen(job->line);
393     int remote_len = strlen(job->remote);
394
395     job->doc_str = (char*)calloc(line_len + 1 /* \t */ +
396         remote_len + 2, 1);
397     strncpy(job->doc_str, job->line, 2);
398     strncat(job->doc_str, job->remote, remote_len);
399     strncat(job->doc_str, "\t", 1);
400     strncat(job->doc_str, job->line + 2, line_len - 2);
401
402     /* Don't need to catch error here, next submit will catch it */
403     if(mq_driver->submit(driver, job->doc_str, line_len + remote_len + 1) != 0) {
404       noitL(noit_debug, "failed to MQ submit.\n");
405     }
406   }
407   else {
408     noitL(noit_iep, "no iep connection, skipping line: '%s'\n", job->line);
409   }
410   return 0;
411 }
412
413 void
414 stratcon_iep_line_processor(stratcon_datastore_op_t op,
415                             struct sockaddr *remote, const char *remote_cn,
416                             void *operand, eventer_t completion) {
417   int len;
418   char remote_str[128];
419   struct iep_job_closure *jc;
420   eventer_t newe;
421   struct timeval __now, iep_timeout = { 20L, 0L };
422   /* We only care about inserts */
423
424   if(op == DS_OP_CHKPT) {
425     eventer_add(completion);
426     return;
427   }
428   if(op != DS_OP_INSERT) return;
429
430   snprintf(remote_str, sizeof(remote_str), "%s", "0.0.0.0");
431   if(remote) {
432     switch(remote->sa_family) {
433       case AF_INET:
434         len = sizeof(struct sockaddr_in);
435         inet_ntop(remote->sa_family, &((struct sockaddr_in *)remote)->sin_addr,
436                   remote_str, len);
437         break;
438       case AF_INET6:
439        len = sizeof(struct sockaddr_in6);
440         inet_ntop(remote->sa_family, &((struct sockaddr_in6 *)remote)->sin6_addr,
441                   remote_str, len);
442        break;
443       case AF_UNIX:
444         len = SUN_LEN(((struct sockaddr_un *)remote));
445         snprintf(remote_str, sizeof(remote_str), "%s", ((struct sockaddr_un *)remote)->sun_path);
446         break;
447     }
448   }
449
450   /* process operand and push onto queue */
451   gettimeofday(&__now, NULL);
452   newe = eventer_alloc();
453   newe->mask = EVENTER_ASYNCH;
454   add_timeval(__now, iep_timeout, &newe->whence);
455   newe->callback = stratcon_iep_submitter;
456   jc = calloc(1, sizeof(*jc));
457   jc->line = operand;
458   jc->remote = strdup(remote_str);
459   newe->closure = jc;
460
461   eventer_add_asynch(&iep_jobq, newe);
462 }
463
464 static void connection_destroy(void *vd) {
465   struct iep_thread_driver *driver = vd;
466   mq_driver->disconnect(driver);
467   mq_driver->deallocate(driver);
468 }
469
470 jlog_streamer_ctx_t *
471 stratcon_jlog_streamer_iep_ctx_alloc(void) {
472   jlog_streamer_ctx_t *ctx;
473   ctx = stratcon_jlog_streamer_ctx_alloc();
474   ctx->jlog_feed_cmd = htonl(NOIT_JLOG_DATA_TEMP_FEED);
475   ctx->push = stratcon_iep_line_processor;
476   return ctx;
477 }
478
479 struct iep_daemon_info {
480   pid_t child;
481   int stdin_pipe[2];
482   int stderr_pipe[2];
483   char *directory;
484   char *command;
485 };
486
487 static void
488 iep_daemon_info_free(struct iep_daemon_info *info) {
489   if(!info) return;
490   if(info->directory) free(info->directory);
491   if(info->command) free(info->command);
492   if(info->stdin_pipe[0] >= 0) close(info->stdin_pipe[0]);
493   if(info->stdin_pipe[1] >= 0) close(info->stdin_pipe[1]);
494   if(info->stderr_pipe[0] >= 0) close(info->stderr_pipe[0]);
495   if(info->stderr_pipe[1] >= 0) close(info->stderr_pipe[1]);
496   free(info);
497 }
498
499 static int
500 stratcon_iep_err_handler(eventer_t e, int mask, void *closure,
501                          struct timeval *now) {
502   int len, newmask;
503   char buff[4096];
504   struct iep_daemon_info *info = (struct iep_daemon_info *)closure;
505
506   if(mask & EVENTER_EXCEPTION) {
507     int rv;
508    read_error:
509     kill(info->child, SIGKILL);
510     if(waitpid(info->child, &rv, 0) != info->child) {
511       noitL(noit_error, "Failed to reap IEP daemon\n");
512       exit(-1);
513     }
514     noitL(noit_error, "IEP daemon is done, starting a new one\n");
515     start_iep_daemon();
516     eventer_remove_fd(e->fd);
517     iep_daemon_info_free(info);
518     return 0;
519   }
520   while(1) {
521     len = e->opset->read(e->fd, buff, sizeof(buff)-1, &newmask, e);
522     if(len == -1 && (errno == EAGAIN || errno == EINTR))
523       return newmask | EVENTER_EXCEPTION;
524     if(len <= 0) goto read_error;
525     assert(len < sizeof(buff));
526     buff[len] = '\0';
527     noitL(noit_iep, "%s", buff);
528   }
529 }
530
531 static void
532 start_iep_daemon() {
533   eventer_t newe;
534   struct iep_daemon_info *info;
535
536   info = calloc(1, sizeof(*info));
537   info->stdin_pipe[0] = info->stdin_pipe[1] = -1;
538   info->stderr_pipe[0] = info->stderr_pipe[1] = -1;
539
540   if(!noit_conf_get_string(NULL, "/stratcon/iep/start/@directory",
541                            &info->directory))
542     info->directory = strdup(".");
543   if(!noit_conf_get_string(NULL, "/stratcon/iep/start/@command",
544                            &info->command)) {
545     noitL(noit_error, "No IEP start command provided.  You're on your own.\n");
546     setup_iep_connection_later(0);
547     return;
548   }
549   if(pipe(info->stdin_pipe) != 0 ||
550      pipe(info->stderr_pipe) != 0) {
551     noitL(noit_error, "pipe: %s\n", strerror(errno));
552     goto bail;
553   }
554   info->child = fork();
555   if(info->child == -1) {
556     noitL(noit_error, "fork: %s\n", strerror(errno));
557     goto bail;
558   }
559   if(info->child == 0) {
560     char *argv[3] = { "run-iep", NULL, NULL };
561     int stdout_fileno;
562
563     argv[1] = noit_conf_config_filename();
564
565     if(chdir(info->directory) != 0) {
566       noitL(noit_error, "Starting IEP daemon, chdir failed: %s\n",
567             strerror(errno));
568       exit(-1);
569     }
570
571     close(info->stdin_pipe[1]);
572     close(info->stderr_pipe[0]);
573     dup2(info->stdin_pipe[0], 0);
574     dup2(info->stderr_pipe[1], 2);
575     stdout_fileno = open("/dev/null", O_WRONLY);
576     dup2(stdout_fileno, 1);
577
578     exit(execv(info->command, argv));
579   }
580   /* in the parent */
581   close(info->stdin_pipe[0]);
582   info->stdin_pipe[0] = -1;
583   close(info->stderr_pipe[1]);
584   info->stderr_pipe[1] = -1;
585   if(eventer_set_fd_nonblocking(info->stderr_pipe[0])) {
586     goto bail;
587   }
588
589   newe = eventer_alloc();
590   newe->fd = info->stderr_pipe[0];
591   newe->mask = EVENTER_READ | EVENTER_EXCEPTION;
592   newe->callback = stratcon_iep_err_handler;
593   newe->closure = info;
594   eventer_add(newe);
595   info = NULL;
596
597   setup_iep_connection_later(1);
598
599   return;
600
601  bail:
602   if(info) {
603     iep_daemon_info_free(info);
604   }
605   noitL(noit_error, "Failed to start IEP daemon\n");
606   exit(-1);
607   return;
608 }
609
610 void
611 stratcon_iep_mq_driver_register(const char *name, mq_driver_t *d) {
612   noit_hash_replace(&mq_drivers, strdup(name), strlen(name), d, free, NULL);
613 }
614
615 void
616 stratcon_iep_init() {
617   noit_boolean disabled = noit_false;
618   char mq_type[128] = "stomp";
619   void *vdriver;
620
621   if(noit_conf_get_boolean(NULL, "/stratcon/iep/@disabled", &disabled) &&
622      disabled == noit_true) {
623     noitL(noit_error, "IEP system is disabled!\n");
624     return;
625   }
626
627   if(!noit_conf_get_stringbuf(NULL, "/stratcon/iep/mq/@type",
628                               mq_type, sizeof(mq_type))) {
629     noitL(noit_error, "You must specify an <mq type=\"...\"> that is valid.\n");
630     exit(-2);
631   }
632   if(!noit_hash_retrieve(&mq_drivers, mq_type, strlen(mq_type), &vdriver) ||
633      vdriver == NULL) {
634     noitL(noit_error, "Cannot find MQ driver type: %s\n", mq_type);
635     noitL(noit_error, "Did you forget to load a module?\n");
636     exit(-2);
637   }
638   mq_driver = (mq_driver_t *)vdriver;
639
640   noit_iep = noit_log_stream_find("error/iep");
641   if(!noit_iep) noit_iep = noit_error;
642
643   eventer_name_callback("stratcon_iep_submitter", stratcon_iep_submitter);
644   eventer_name_callback("stratcon_iep_err_handler", stratcon_iep_err_handler);
645   eventer_name_callback("setup_iep_connection_callback", setup_iep_connection_callback);
646   pthread_key_create(&iep_connection, connection_destroy);
647
648   /* start up a thread pool of one */
649   memset(&iep_jobq, 0, sizeof(iep_jobq));
650   eventer_jobq_init(&iep_jobq, "iep_submitter");
651   iep_jobq.backq = eventer_default_backq();
652   eventer_jobq_increase_concurrency(&iep_jobq);
653
654   start_iep_daemon();
655
656   /* setup our live jlog stream */
657   stratcon_streamer_connection(NULL, NULL,
658                                stratcon_jlog_recv_handler,
659                                (void *(*)())stratcon_jlog_streamer_iep_ctx_alloc,
660                                NULL,
661                                jlog_streamer_ctx_free);
662 }
663
Note: See TracBrowser for help on using the browser.