Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. params.cpp
  5. Abstract:
  6. SIS Groveler parameter support & defaults
  7. Authors:
  8. John Douceur, 1998
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include "all.hxx"
  14. static const _TCHAR registry_parameter_path[] =
  15. _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Groveler\\Parameters");
  16. ReadParameters::ReadParameters()
  17. {
  18. ASSERT(this != 0);
  19. static EntrySpec registry_entries[registry_entry_count] =
  20. {
  21. {_T("parameter backup interval"), entry_int, _T("600000"), &parameter_backup_interval},
  22. {_T("target entries per log extraction"), entry_int, _T("100"), &target_entries_per_extraction},
  23. {_T("max extraction interval"), entry_int, _T("10000"), &max_extraction_interval},
  24. {_T("base grovel interval"), entry_int, _T("5000"), &base_grovel_interval},
  25. {_T("max grovel interval"), entry_int, _T("600000"), &max_grovel_interval},
  26. {_T("max response lag"), entry_int, _T("10000"), &max_response_lag},
  27. {_T("low-confidence grovel interval"), entry_int, _T("15000"), &low_confidence_grovel_interval},
  28. {_T("low-disk-space grovel interval"), entry_int, _T("500"), &low_disk_space_grovel_interval},
  29. {_T("working grovel interval"), entry_int, _T("500"), &working_grovel_interval},
  30. {_T("grovel duration"), entry_int, _T("400"), &grovel_duration},
  31. {_T("partition info update interval"), entry_int, _T("60000"), &partition_info_update_interval},
  32. {_T("base restart extraction interval"), entry_int, _T("10000"), &base_restart_extraction_interval},
  33. {_T("max restart extraction interval"), entry_int, _T("3600000"), &max_restart_extraction_interval},
  34. {_T("base restart groveling interval"), entry_int, _T("30000"), &base_restart_groveling_interval},
  35. {_T("max restart groveling interval"), entry_int, _T("86400000"), &max_restart_groveling_interval},
  36. {_T("base regrovel interval"), entry_int, _T("60000"), &base_regrovel_interval},
  37. {_T("max regrovel interval"), entry_int, _T("86400000"), &max_regrovel_interval},
  38. {_T("volscan regrovel threshold"), entry_int, _T("120000"), &volscan_regrovel_threshold},
  39. {_T("partition balance time constant"), entry_int, _T("1800000"), &partition_balance_time_constant},
  40. {_T("read time increase history size"), entry_int, _T("5"), &read_time_increase_history_size},
  41. {_T("read time decrease history size"), entry_int, _T("2"), &read_time_decrease_history_size},
  42. {_T("SIS efficacy history size"), entry_int, _T("1000"), &sis_efficacy_history_size},
  43. {_T("log winnow history size"), entry_int, _T("1000"), &log_winnow_history_size},
  44. {_T("file size history size"), entry_int, _T("1000"), &file_size_history_size},
  45. {_T("sample group size"), entry_int, _T("10"), &sample_group_size},
  46. {_T("acceptance P-value"), entry_double, _T("0.2"), &acceptance_p_value},
  47. {_T("rejection P-value"), entry_double, _T("0.05"), &rejection_p_value},
  48. {_T("base use multiplier"), entry_double, _T("1.0"), &base_use_multiplier},
  49. {_T("max use multiplier"), entry_double, _T("2.0"), &max_use_multiplier},
  50. {_T("peak finder accuracy"), entry_double, _T("0.05"), &peak_finder_accuracy},
  51. {_T("peak finder range"), entry_double, _T("20.0"), &peak_finder_range},
  52. {_T("base CPU load threshold"), entry_double, _T("0.50"), &base_cpu_load_threshold},
  53. {_T("max CPU load threshold"), entry_double, _T("1.0"), &max_cpu_load_threshold},
  54. {_T("read report discard threshold"), entry_double, _T("0.75"), &read_report_discard_threshold},
  55. {_T("GrovelAllPaths"), entry_int, _T("0"), &GrovelAllPaths}
  56. };
  57. Registry::read(HKEY_LOCAL_MACHINE, registry_parameter_path,
  58. registry_entry_count, registry_entries);
  59. #if WRITE_ALL_PARAMETERS
  60. bool registry_write_ok =
  61. Registry::write(HKEY_LOCAL_MACHINE, registry_parameter_path,
  62. registry_entry_count, registry_entries);
  63. if (!registry_write_ok)
  64. {
  65. PRINT_DEBUG_MSG((_T("GROVELER: Registry::write() to %s failed\n"),
  66. registry_parameter_path));
  67. }
  68. #endif // WRITE_ALL_PARAMETERS
  69. }
  70. WriteParameters::WriteParameters(
  71. int backup_interval)
  72. {
  73. ASSERT(this != 0);
  74. ASSERT(backup_interval >= 0);
  75. this->backup_interval = backup_interval;
  76. static EntrySpec registry_entries[registry_entry_count] =
  77. {
  78. {_T("hash match ratio"), entry_double, _T("0.01"), &hash_match_ratio},
  79. {_T("compare match ratio"), entry_double, _T("1.0"), &compare_match_ratio},
  80. {_T("dequeue hash ratio"), entry_double, _T("1.0"), &dequeue_hash_ratio}
  81. };
  82. for (int index = 0; index < registry_entry_count; index++)
  83. {
  84. this->registry_entries[index] = registry_entries[index];
  85. }
  86. Registry::read(HKEY_LOCAL_MACHINE, registry_parameter_path,
  87. registry_entry_count, registry_entries);
  88. if (backup_interval > 0)
  89. {
  90. backup((void *)this);
  91. }
  92. }
  93. WriteParameters::~WriteParameters()
  94. {
  95. ASSERT(this != 0);
  96. ASSERT(backup_interval >= 0);
  97. backup((void *)this);
  98. }
  99. void
  100. WriteParameters::backup(
  101. void *context)
  102. {
  103. ASSERT(context != 0);
  104. unsigned int invokation_time = GET_TICK_COUNT();
  105. WriteParameters *me = (WriteParameters *)context;
  106. ASSERT(me->backup_interval >= 0);
  107. bool registry_overwrite_ok =
  108. Registry::overwrite(HKEY_LOCAL_MACHINE, registry_parameter_path,
  109. registry_entry_count, me->registry_entries);
  110. if (!registry_overwrite_ok)
  111. {
  112. PRINT_DEBUG_MSG((_T("GROVELER: Registry::overwrite() to %s failed\n"),
  113. registry_parameter_path));
  114. }
  115. event_timer.schedule(invokation_time + me->backup_interval,
  116. context, backup);
  117. }