| 287 | } |
| 288 | |
| 289 | int trigger_stat() |
| 290 | { |
| 291 | GET_BDB_STATE(bdb_state); |
| 292 | if (!bdb_amimaster(bdb_state)) { |
| 293 | logmsg(LOGMSG_USER, "%s: cannot run on replicant\n", __func__); |
| 294 | return -1; |
| 295 | } |
| 296 | Pthread_mutex_lock(&trighash_lk); |
| 297 | time_t now = time(NULL); |
| 298 | for (int i = 0; i < thedb->num_qdbs; ++i) { |
| 299 | struct dbtable *qdb = thedb->qdbs[i]; |
| 300 | consumer_lock_read(qdb); |
| 301 | /* protect us from incomplete triggers (e.g., an old-style queue without a consumer */ |
| 302 | if (qdb->consumers[0] == NULL) { |
| 303 | consumer_unlock(qdb); |
| 304 | continue; |
| 305 | } |
| 306 | int ctype = dbqueue_consumer_type(qdb->consumers[0]); |
| 307 | if (ctype != CONSUMER_TYPE_LUA && ctype != CONSUMER_TYPE_DYNLUA) { |
| 308 | consumer_unlock(qdb); |
| 309 | continue; |
| 310 | } |
| 311 | const char *type = ctype == CONSUMER_TYPE_LUA ? "trigger" : "consumer"; |
| 312 | char *spname = SP4Q(qdb->tablename); |
| 313 | trigger_info_t *info = |
| 314 | trigger_hash ? hash_find(trigger_hash, spname) : NULL; |
| 315 | if (info) { |
| 316 | logmsg(LOGMSG_USER, |
| 317 | "%s: %8s:%s ASSIGNED to node:%s cookie:%016" PRIx64 |
| 318 | " last heartbeat: %.0fs\n", |
| 319 | __func__, type, info->spname, info->host, |
| 320 | info->trigger_cookie, difftime(now, info->hbeat)); |
| 321 | } else { |
| 322 | logmsg(LOGMSG_USER, "%s: %8s:%s UNASSIGNED\n", __func__, type, |
| 323 | spname); |
| 324 | } |
| 325 | consumer_unlock(qdb); |
| 326 | } |
| 327 | Pthread_mutex_unlock(&trighash_lk); |
| 328 | return 0; |
| 329 | } |
| 330 | |
| 331 | static int trigger_registered_int(const char *spname) |
| 332 | { |
no test coverage detected