| 1 | /* |
| 2 | * monitor.h |
| 3 | * |
| 4 | * Copyright (C) 2012-2014 Aerospike, Inc. |
| 5 | * |
| 6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 7 | * license agreements. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU Affero General Public License as published by the Free |
| 11 | * Software Foundation, either version 3 of the License, or (at your option) any |
| 12 | * later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Long Running Job Monitoring interface |
| 25 | * |
| 26 | * This file implements the generic interface for the long running jobs |
| 27 | * in Aerospike like query / scan / batch etc. The idea is to able to see |
| 28 | * what is going on in the system. |
| 29 | * |
| 30 | * Each module which needs to show up in the monitoring needs to register |
| 31 | * and implement the interfaces. |
| 32 | */ |
| 33 | |
| 34 | #pragma once |
| 35 | |
| 36 | #include <stdint.h> |
| 37 | |
| 38 | #include "dynbuf.h" |
| 39 | |
| 40 | #include "base/datamodel.h" |
| 41 | |
| 42 | |
| 43 | #define AS_MON_OK 0 |
| 44 | #define AS_MON_ERR -1 |
| 45 | #define AS_MON_EXIST -2 |
| 46 | #define TRID_LIST_SIZE 1000 |
| 47 | |
| 48 | typedef enum { |
| 49 | QUERY_MOD = 0, |
| 50 | SCAN_MOD = 1, |
| 51 | SBLD_MOD = 2 |
| 52 | } as_mon_module_slot; |
| 53 | |
| 54 | extern const char * AS_MON_MODULES[]; |
| 55 | |
| 56 | // Stat for currently running job |
| 57 | typedef struct as_mon_jobstat_s { |
| 58 | uint64_t trid; |
| 59 | char job_type[32]; |
| 60 | char ns[AS_ID_NAMESPACE_SZ]; |
| 61 | char set[AS_SET_NAME_MAX_SIZE]; |
| 62 | uint32_t priority; |
| 63 | uint32_t rps; |
| 64 | uint32_t active_threads; |
| 65 | char status[64]; |
| 66 | float progress_pct; |
| 67 | uint64_t run_time; |
| 68 | uint64_t time_since_done; |
| 69 | uint64_t recs_throttled; |
| 70 | uint64_t recs_filtered_meta; |
| 71 | uint64_t recs_filtered_bins; |
| 72 | uint64_t recs_succeeded; |
| 73 | uint64_t recs_failed; |
| 74 | uint64_t net_io_bytes; |
| 75 | uint32_t socket_timeout; |
| 76 | char client[64]; |
| 77 | char jdata[512]; |
| 78 | } as_mon_jobstat; |
| 79 | |
| 80 | typedef struct as_mon_cb_s { |
| 81 | as_mon_jobstat *(*get_jobstat) (uint64_t trid); |
| 82 | as_mon_jobstat *(*get_jobstat_all) (int * size); |
| 83 | |
| 84 | // Per transaction |
| 85 | int (*set_priority) (uint64_t trid, uint32_t priority); |
| 86 | int (*kill) (uint64_t trid); |
| 87 | int (*suspend) (uint64_t trid); |
| 88 | |
| 89 | // Per Module |
| 90 | // Numer of pending transaction of this job type in queue allowed |
| 91 | // incoming more than this will be rejected. |
| 92 | int (*set_pendingmax) (int); |
| 93 | |
| 94 | // Set the number of transaction that can be inflight at |
| 95 | // any point of time. |
| 96 | int (*set_maxinflight) (int); |
| 97 | |
| 98 | // Any individual transaction priority has upper bound of max |
| 99 | // priority of jobtype |
| 100 | int (*set_maxpriority) (int); |
| 101 | } as_mon_cb; |
| 102 | |
| 103 | // Structure to register module with as mon interface. |
| 104 | typedef struct as_mon_s { |
| 105 | char *type; |
| 106 | as_mon_cb cb; |
| 107 | } as_mon; |
| 108 | |
| 109 | void as_mon_info_cmd(const char *module, char *cmd, uint64_t trid, uint32_t priority, cf_dyn_buf *db); |
| 110 | int as_mon_init(); |
| 111 | |