Schooner memslap changes
[m6w6/libmemcached] / clients / ms_memslap.h
1 /*
2 * File: ms_memslap.h
3 * Author: Mingqiang Zhuang
4 *
5 * Created on February 10, 2009
6 *
7 * (c) Copyright 2009, Schooner Information Technology, Inc.
8 * http://www.schoonerinfotech.com/
9 *
10 */
11 #ifndef MS_MEMSLAP_H
12 #define MS_MEMSLAP_H
13
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <errno.h>
17 #include <string.h>
18 #include <assert.h>
19 #include <unistd.h>
20 #include <stdint.h>
21 #include <pthread.h>
22 #include <stdbool.h>
23 #include <math.h>
24 #include "../config.h"
25
26 #include "ms_stats.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /* command line option */
33 typedef enum {
34 OPT_VERSION= 'V',
35 OPT_HELP= 'h',
36 OPT_UDP = 'U',
37 OPT_SERVERS= 's',
38 OPT_EXECUTE_NUMBER = 'x',
39 OPT_THREAD_NUMBER = 'T',
40 OPT_CONCURRENCY = 'c',
41 OPT_FIXED_LTH = 'X',
42 OPT_VERIFY = 'v',
43 OPT_GETS_DIVISION = 'd',
44 OPT_TIME = 't',
45 OPT_CONFIG_CMD = 'F',
46 OPT_WINDOW_SIZE = 'w',
47 OPT_EXPIRE = 'e',
48 OPT_STAT_FREQ = 'S',
49 OPT_RECONNECT = 'R',
50 OPT_VERBOSE = 'b',
51 OPT_FACEBOOK_TEST = 'a',
52 OPT_SOCK_PER_CONN = 'n',
53 OPT_BINARY_PROTOCOL = 'B',
54 OPT_OVERWRITE = 'o',
55 OPT_TPS = 'P',
56 OPT_REP_WRITE_SRV = 'p',
57 } ms_options_t;
58
59 /* global statistic of response time */
60 typedef struct statistic {
61 pthread_mutex_t stat_mutex; /* synchronize the following members */
62
63 ms_stat_t get_stat; /* statistics of get command */
64 ms_stat_t set_stat; /* statistics of set command */
65 ms_stat_t total_stat; /* statistics of both get and set commands */
66 } ms_statistic_t;
67
68 /* global status statistic structure */
69 typedef struct stats {
70 int32_t active_conns; /* active connections */
71 uint64_t bytes_read; /* read bytes */
72 uint64_t bytes_written; /* written bytes */
73 uint64_t obj_bytes; /* object bytes */
74 uint64_t pre_cmd_get; /* previous total get command count */
75 uint64_t pre_cmd_set; /* previous total set command count */
76 uint64_t cmd_get; /* current total get command count */
77 uint64_t cmd_set; /* current total set command count */
78 uint64_t get_misses; /* total objects of get miss */
79 uint64_t vef_miss; /* total objects of verification miss */
80 uint64_t vef_failed; /* total objects of verification failed */
81 uint64_t unexp_unget; /* total objects which is unexpired but not get */
82 uint64_t exp_get; /* total objects which is expired but get */
83 uint64_t pkt_disorder; /* disorder packages of UDP */
84 uint64_t pkt_drop; /* packages dropped of UDP */
85 uint64_t udp_timeout; /* how many times timeout of UDP happens */
86 } ms_stats_t;
87
88 /* lock adapter */
89 typedef struct sync_lock {
90 int count;
91 pthread_mutex_t lock;
92 pthread_cond_t cond;
93 } ms_sync_lock_t;
94
95 /* global variable structure */
96 typedef struct global {
97 /* synchronize lock */
98 ms_sync_lock_t init_lock;
99 ms_sync_lock_t run_lock;
100
101 /* mutex for outputing error log synchronously when memslap crashes */
102 pthread_mutex_t quit_mutex;
103
104 /* mutex for generating key prefix */
105 pthread_mutex_t seq_mutex;
106
107 /* global synchronous flags for slap mode */
108 bool finish_warmup;
109 bool time_out;
110 } ms_global_t;
111
112 /* global structure */
113 ms_global_t ms_global;
114
115 /* global stats information structure */
116 ms_stats_t ms_stats;
117
118 /* global statistic structure */
119 ms_statistic_t ms_statistic;
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif /* end of MS_MEMSLAP_H */