def main(args):
    # initialise the RulesSpec parser
    rule_spec_parser = RulesSpec(args.rules_spec)
    # initialise the benchmark runner
    bench_runner_module = __import__(args.benchrunner_module,
                                     fromlist=[args.benchrunner_class])
    bench_runner_class = getattr(bench_runner_module, args.benchrunner_class)
    ods_args = {}
    if args.ods_client and args.ods_entity:
        ods_args['client_script'] = args.ods_client
        ods_args['entity'] = args.ods_entity
        if args.ods_key_prefix:
            ods_args['key_prefix'] = args.ods_key_prefix
    db_bench_runner = bench_runner_class(args.benchrunner_pos_args, ods_args)
    # initialise the database configuration
    db_options = DatabaseOptions(args.rocksdb_options, args.misc_options)
    # set the frequency at which stats are dumped in the LOG file and the
    # location of the LOG file.
    db_log_dump_settings = {
        "DBOptions.stats_dump_period_sec": {
            NO_COL_FAMILY: args.stats_dump_period_sec
        }
    }
    db_options.update_options(db_log_dump_settings)
    # initialise the configuration optimizer
    config_optimizer = ConfigOptimizer(db_bench_runner, db_options,
                                       rule_spec_parser, args.base_db_path)
    # run the optimiser to improve the database configuration for given
    # benchmarks, with the help of expert-specified rules
    final_db_options = config_optimizer.run()
    # generate the final rocksdb options file
    print('Final configuration in: ' +
          final_db_options.generate_options_config('final'))
    print('Final miscellaneous options: ' +
          repr(final_db_options.get_misc_options()))
Exemple #2
0
def main(args):
    # initialise the RulesSpec parser
    rule_spec_parser = RulesSpec(args.rules_spec)
    rule_spec_parser.load_rules_from_spec()
    rule_spec_parser.perform_section_checks()
    # initialize the DatabaseOptions object
    db_options = DatabaseOptions(args.rocksdb_options)
    # Create DatabaseLogs object
    db_logs = DatabaseLogs(args.log_files_path_prefix,
                           db_options.get_column_families())
    # Create the Log STATS object
    db_log_stats = LogStatsParser(args.log_files_path_prefix,
                                  args.stats_dump_period_sec)
    data_sources = {
        DataSource.Type.DB_OPTIONS: [db_options],
        DataSource.Type.LOG: [db_logs],
        DataSource.Type.TIME_SERIES: [db_log_stats]
    }
    if args.ods_client:
        data_sources[DataSource.Type.TIME_SERIES].append(
            OdsStatsFetcher(args.ods_client, args.ods_entity, args.ods_tstart,
                            args.ods_tend, args.ods_key_prefix))
    triggered_rules = rule_spec_parser.get_triggered_rules(
        data_sources, db_options.get_column_families())
    rule_spec_parser.print_rules(triggered_rules)
Exemple #3
0
 def setUp(self):
     this_path = os.path.abspath(os.path.dirname(__file__))
     ini_path = os.path.join(this_path, 'input_files/rules_err1.ini')
     db_rules = RulesSpec(ini_path)
     db_rules.load_rules_from_spec()
     self.rules_dict = db_rules.get_rules_dict()
     self.conditions_dict = db_rules.get_conditions_dict()
     self.suggestions_dict = db_rules.get_suggestions_dict()
 def setUp(self):
     # load the Rules
     this_path = os.path.abspath(os.path.dirname(__file__))
     ini_path = os.path.join(this_path, 'input_files/test_rules.ini')
     self.db_rules = RulesSpec(ini_path)
     self.db_rules.load_rules_from_spec()
     self.db_rules.perform_section_checks()
     # load the data sources: LOG and OPTIONS
     log_path = os.path.join(this_path, 'input_files/LOG-1')
     options_path = os.path.join(this_path, 'input_files/OPTIONS-000005')
     self.data_sources = []
     self.data_sources.append(DatabaseOptions(options_path))
     self.data_sources.append(DatabaseLogs(log_path))
Exemple #5
0
 def setUp(self):
     # load the Rules
     this_path = os.path.abspath(os.path.dirname(__file__))
     ini_path = os.path.join(this_path, 'input_files/test_rules.ini')
     self.db_rules = RulesSpec(ini_path)
     self.db_rules.load_rules_from_spec()
     self.db_rules.perform_section_checks()
     # load the data sources: LOG and OPTIONS
     log_path = os.path.join(this_path, 'input_files/LOG-1')
     options_path = os.path.join(this_path, 'input_files/OPTIONS-000005')
     db_options_parser = DatabaseOptions(options_path)
     self.column_families = db_options_parser.get_column_families()
     db_logs_parser = DatabaseLogs(log_path, self.column_families)
     self.data_sources = [db_options_parser, db_logs_parser]
Exemple #6
0
 def test_section_no_name(self):
     ini_path = os.path.join(self.this_path, 'input_files/rules_err4.ini')
     db_rules = RulesSpec(ini_path)
     regex = 'Parsing error: needed section header:.*'
     with self.assertRaisesRegex(ValueError, regex):
         db_rules.load_rules_from_spec()
Exemple #7
0
 def test_suggestion_missing_action(self):
     ini_path = os.path.join(self.this_path, 'input_files/rules_err3.ini')
     db_rules = RulesSpec(ini_path)
     regex = '.*provide action for option.*'
     with self.assertRaisesRegex(ValueError, regex):
         db_rules.load_rules_from_spec()
Exemple #8
0
 def test_condition_missing_source(self):
     ini_path = os.path.join(self.this_path, 'input_files/rules_err2.ini')
     db_rules = RulesSpec(ini_path)
     regex = '.*provide source for condition.*'
     with self.assertRaisesRegex(NotImplementedError, regex):
         db_rules.load_rules_from_spec()