Add test cases for add server for NULL cases.
[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 #if !defined(__cplusplus)
23 # include <stdbool.h>
24 #endif
25 #include <math.h>
26
27 #include "ms_stats.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /* command line option */
34 typedef enum
35 {
36 OPT_VERSION= 'V',
37 OPT_HELP= 'h',
38 OPT_UDP= 'U',
39 OPT_SERVERS= 's',
40 OPT_EXECUTE_NUMBER= 'x',
41 OPT_THREAD_NUMBER= 'T',
42 OPT_CONCURRENCY= 'c',
43 OPT_FIXED_LTH= 'X',
44 OPT_VERIFY= 'v',
45 OPT_GETS_DIVISION= 'd',
46 OPT_TIME= 't',
47 OPT_CONFIG_CMD= 'F',
48 OPT_WINDOW_SIZE= 'w',
49 OPT_EXPIRE= 'e',
50 OPT_STAT_FREQ= 'S',
51 OPT_RECONNECT= 'R',
52 OPT_VERBOSE= 'b',
53 OPT_FACEBOOK_TEST= 'a',
54 OPT_SOCK_PER_CONN= 'n',
55 OPT_BINARY_PROTOCOL= 'B',
56 OPT_OVERWRITE= 'o',
57 OPT_TPS= 'P',
58 OPT_REP_WRITE_SRV= 'p'
59 } ms_options_t;
60
61 /* global statistic of response time */
62 typedef struct statistic
63 {
64 pthread_mutex_t stat_mutex; /* synchronize the following members */
65
66 ms_stat_t get_stat; /* statistics of get command */
67 ms_stat_t set_stat; /* statistics of set command */
68 ms_stat_t total_stat; /* statistics of both get and set commands */
69 } ms_statistic_t;
70
71 /* global status statistic structure */
72 typedef struct stats
73 {
74 volatile uint32_t active_conns; /* active connections */
75 size_t bytes_read; /* read bytes */
76 size_t bytes_written; /* written bytes */
77 size_t obj_bytes; /* object bytes */
78 size_t pre_cmd_get; /* previous total get command count */
79 size_t pre_cmd_set; /* previous total set command count */
80 size_t cmd_get; /* current total get command count */
81 size_t cmd_set; /* current total set command count */
82 size_t get_misses; /* total objects of get miss */
83 size_t vef_miss; /* total objects of verification miss */
84 size_t vef_failed; /* total objects of verification failed */
85 size_t unexp_unget; /* total objects which is unexpired but not get */
86 size_t exp_get; /* total objects which is expired but get */
87 volatile size_t pkt_disorder; /* disorder packages of UDP */
88 size_t pkt_drop; /* packages dropped of UDP */
89 size_t udp_timeout; /* how many times timeout of UDP happens */
90 } ms_stats_t;
91
92 /* lock adapter */
93 typedef struct sync_lock
94 {
95 uint32_t count;
96 pthread_mutex_t lock;
97 pthread_cond_t cond;
98 } ms_sync_lock_t;
99
100 /* global variable structure */
101 typedef struct global
102 {
103 /* synchronize lock */
104 ms_sync_lock_t init_lock;
105 ms_sync_lock_t warmup_lock;
106 ms_sync_lock_t run_lock;
107
108 /* mutex for outputing error log synchronously when memslap crashes */
109 pthread_mutex_t quit_mutex;
110
111 /* mutex for generating key prefix */
112 pthread_mutex_t seq_mutex;
113
114 /* global synchronous flags for slap mode */
115 bool finish_warmup;
116 bool time_out;
117 } ms_global_t;
118
119 /* global structure */
120 ms_global_t ms_global;
121
122 /* global stats information structure */
123 ms_stats_t ms_stats;
124
125 /* global statistic structure */
126 ms_statistic_t ms_statistic;
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* end of MS_MEMSLAP_H */