~stewart/percona-playback/cassert-header

« back to all changes in this revision

Viewing changes to src/options.cc

  • Committer: Oleg Tsarev
  • Date: 2011-03-21 02:10:49 UTC
  • Revision ID: oleg.tsarev@percona.com-20110321021049-0olp7o9gjk545yr7
splitfy progress
add "try-run" option
add "split-to" and "from-split" options
change boolean type "is_read_query" to "Unknow", "Read", "Write" types
fix result names of perf test files

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
  return g_slow_query_log_socket;
97
97
}
98
98
 
 
99
Nullable_String g_split_to;
 
100
Nullable_String const& split_to()
 
101
{
 
102
  return g_split_to;
 
103
}
 
104
 
 
105
Nullable_String g_from_split;
 
106
Nullable_String const & from_split()
 
107
{
 
108
  return g_from_split;
 
109
}
 
110
 
 
111
bool g_dry_run= false;
 
112
bool dry_run()
 
113
{
 
114
  return g_dry_run;
 
115
}
 
116
 
99
117
void parse_args(int argc, char* argv[])
100
118
{
101
119
  // Declare the supported options.
108
126
     "0:\tquiet behavior (show nothing while work)\n"
109
127
     "1:\tfor every query print single line report\n"
110
128
     "2:\texplain error codes for failed queries\n"
111
 
     "3:\tprint SQL-text for every query");
 
129
     "3:\tprint SQL-text for every query")
 
130
    ("split_to", po::value<std::string>(), "split to dir/thread_id log files")
 
131
    ("dry_run", "don't run queries on mysql (don't connect)");
112
132
  po::options_description desc_mysql("MySQL client");
113
133
  desc_mysql.add_options()
114
134
    ("host",     po::value<std::string>(),  "mysql host")
120
140
  po::options_description desc_input("Input source");
121
141
  desc_input.add_options()
122
142
    ("slow_query_log_file",   po::value<std::string>(), "input slow query log file")
123
 
    ("slow_query_log_socket", po::value<std::string>(), "input slow query log socket");
 
143
    ("slow_query_log_socket", po::value<std::string>(), "input slow query log socket")
 
144
    ("from_split",            po::value<std::string>(),            "input from_split/thread_id  log files");
124
145
  po::options_description desc("USAGE: ppb [General Options] [Input Source] [MySQ Options]");
125
146
  desc.add(desc_general).add(desc_mysql).add(desc_input);
126
147
  if (argc == 1)
158
179
          throw Too_Long_Argument("verbose", "maximum value is 3", verbose_string.str());
159
180
        }
160
181
    }
161
 
  if (vm.count("verbose"))
162
 
    {
163
 
      g_verbosity= vm[ "verbose" ].as<unsigned int>();
164
 
      if (g_verbosity > 3)
165
 
        {
166
 
          std::ostringstream verbose_string;
167
 
          verbose_string << g_verbosity;
168
 
          throw Too_Long_Argument("verbose", "maximum value is 3", verbose_string.str());
169
 
        }
170
 
    }
 
182
  g_dry_run= vm.count("dry_run");
171
183
#define STRING(name)                                    \
172
184
  if (vm.count( #name ))                                                \
173
185
    {                                                                   \
200
212
  STRING(socket);
201
213
  STRING(slow_query_log_file);
202
214
  STRING(slow_query_log_socket);
203
 
  if (!slow_query_log_file().is_null() && !slow_query_log_socket().is_null())
 
215
  STRING(split_to);
 
216
  STRING(from_split);
 
217
  std::size_t source_count= 0;
 
218
  if (!slow_query_log_file().is_null())
 
219
    source_count +=1 ;
 
220
  if (!slow_query_log_socket().is_null())
 
221
    source_count +=1 ;
 
222
  if (!from_split().is_null())
 
223
    source_count +=1 ;
 
224
  if (source_count > 1)
204
225
    {
205
 
      throw Error("Please select as input only one: file or socket");
 
226
      throw Error("Please select as input only one: file, socket or from_split");
206
227
    }
207
228
#undef STRING
208
229
}