Modify where memslap keeps its default config file.
[awesomized/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
25 #include "ms_stats.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* command line option */
32 typedef enum
33 {
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 {
62 pthread_mutex_t stat_mutex; /* synchronize the following members */
63
64 ms_stat_t get_stat; /* statistics of get command */
65 ms_stat_t set_stat; /* statistics of set command */
66 ms_stat_t total_stat; /* statistics of both get and set commands */
67 } ms_statistic_t;
68
69 /* global status statistic structure */
70 typedef struct stats
71 {
72 volatile int32_t active_conns; /* active connections */
73 size_t bytes_read; /* read bytes */
74 size_t bytes_written; /* written bytes */
75 size_t obj_bytes; /* object bytes */
76 size_t pre_cmd_get; /* previous total get command count */
77 size_t pre_cmd_set; /* previous total set command count */
78 size_t cmd_get; /* current total get command count */
79 size_t cmd_set; /* current total set command count */
80 size_t get_misses; /* total objects of get miss */
81 size_t vef_miss; /* total objects of verification miss */
82 size_t vef_failed; /* total objects of verification failed */
83 size_t unexp_unget; /* total objects which is unexpired but not get */
84 size_t exp_get; /* total objects which is expired but get */
85 volatile size_t pkt_disorder; /* disorder packages of UDP */
86 size_t pkt_drop; /* packages dropped of UDP */
87 size_t udp_timeout; /* how many times timeout of UDP happens */
88 } ms_stats_t;
89
90 /* lock adapter */
91 typedef struct sync_lock
92 {
93 int count;
94 pthread_mutex_t lock;
95 pthread_cond_t cond;
96 } ms_sync_lock_t;
97
98 /* global variable structure */
99 typedef struct global
100 {
101 /* synchronize lock */
102 ms_sync_lock_t init_lock;
103 ms_sync_lock_t run_lock;
104
105 /* mutex for outputing error log synchronously when memslap crashes */
106 pthread_mutex_t quit_mutex;
107
108 /* mutex for generating key prefix */
109 pthread_mutex_t seq_mutex;
110
111 /* global synchronous flags for slap mode */
112 bool finish_warmup;
113 bool time_out;
114 } ms_global_t;
115
116 /* global structure */
117 ms_global_t ms_global;
118
119 /* global stats information structure */
120 ms_stats_t ms_stats;
121
122 /* global statistic structure */
123 ms_statistic_t ms_statistic;
124
125 #ifdef __cplusplus
126 }
127 #endif
128
129 #endif /* end of MS_MEMSLAP_H */