| 217 | |
| 218 | |
| 219 | def parse_options(): |
| 220 | parser = OptionParser() |
| 221 | parser.add_option('-H', '--hosts', default='127.0.0.1', |
| 222 | help='cassandra hosts to connect to (comma-separated list) [default: %default]') |
| 223 | parser.add_option('-t', '--threads', type='int', default=1, |
| 224 | help='number of threads [default: %default]') |
| 225 | parser.add_option('-n', '--num-ops', type='int', default=10000, |
| 226 | help='number of operations [default: %default]') |
| 227 | parser.add_option('--asyncore-only', action='store_true', dest='asyncore_only', |
| 228 | help='only benchmark with asyncore connections') |
| 229 | parser.add_option('--asyncio-only', action='store_true', dest='asyncio_only', |
| 230 | help='only benchmark with asyncio connections') |
| 231 | parser.add_option('--libev-only', action='store_true', dest='libev_only', |
| 232 | help='only benchmark with libev connections') |
| 233 | parser.add_option('--twisted-only', action='store_true', dest='twisted_only', |
| 234 | help='only benchmark with Twisted connections') |
| 235 | parser.add_option('-m', '--metrics', action='store_true', dest='enable_metrics', |
| 236 | help='enable and print metrics for operations') |
| 237 | parser.add_option('-l', '--log-level', default='info', |
| 238 | help='logging level: debug, info, warning, or error') |
| 239 | parser.add_option('-p', '--profile', action='store_true', dest='profile', |
| 240 | help='Profile the run') |
| 241 | parser.add_option('--protocol-version', type='int', dest='protocol_version', default=4, |
| 242 | help='Native protocol version to use') |
| 243 | parser.add_option('-c', '--num-columns', type='int', dest='num_columns', default=2, |
| 244 | help='Specify the number of columns for the schema') |
| 245 | parser.add_option('-k', '--keyspace', type='str', dest='keyspace', default=KEYSPACE, |
| 246 | help='Specify the keyspace name for the schema') |
| 247 | parser.add_option('--keep-data', action='store_true', dest='keep_data', default=False, |
| 248 | help='Keep the data after the benchmark') |
| 249 | parser.add_option('--column-type', type='str', dest='column_type', default='text', |
| 250 | help='Specify the column type for the schema (supported: int, text, float, uuid, timestamp)') |
| 251 | parser.add_option('--read', action='store_true', dest='read', default=False, |
| 252 | help='Read mode') |
| 253 | |
| 254 | |
| 255 | options, args = parser.parse_args() |
| 256 | |
| 257 | options.hosts = options.hosts.split(',') |
| 258 | |
| 259 | level = options.log_level.upper() |
| 260 | try: |
| 261 | log.setLevel(_log_levels[level]) |
| 262 | except KeyError: |
| 263 | log.warning("Unknown log level specified: %s; specify one of %s", options.log_level, _log_levels.keys()) |
| 264 | |
| 265 | if options.asyncore_only: |
| 266 | options.supported_reactors = [AsyncoreConnection] |
| 267 | elif options.asyncio_only: |
| 268 | options.supported_reactors = [AsyncioConnection] |
| 269 | elif options.libev_only: |
| 270 | if not have_libev: |
| 271 | log.error("libev is not available") |
| 272 | sys.exit(1) |
| 273 | options.supported_reactors = [LibevConnection] |
| 274 | elif options.twisted_only: |
| 275 | if not have_twisted: |
| 276 | log.error("Twisted is not available") |