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.

197 lines
4.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation
  4. //
  5. // File: DfsRootFolder.hxx
  6. //
  7. // Contents: the Root DFS Folder class
  8. //
  9. // Classes: DfsRootFolder
  10. //
  11. // History: Dec. 8 2000, Author: udayh
  12. //
  13. //-----------------------------------------------------------------------------
  14. #ifndef __DFS_STATISTICS__
  15. #define __DFS_STATISTICS__
  16. #include "DfsGeneric.hxx"
  17. #define VERY_LARGE_TIME_REFERRAL 40*1000
  18. #define LARGE_TIME_REFERRAL 1000
  19. #define SMALL_TIME_REFERRAL 50
  20. class DfsStatistics: public DfsGeneric
  21. {
  22. private:
  23. LONG Hits;
  24. LONG Misses;
  25. LONG TotalReferrals;
  26. ULONG MinReferralTime;
  27. ULONG MaxReferralTime;
  28. LONG VeryLargeTimeReferrals;
  29. LONG LargeTimeReferrals;
  30. LONG SmallTimeReferrals;
  31. LONG NumberOfErrors;
  32. LONG DfsRequiredMemory;
  33. LONG DfsReferralCacheMemory;
  34. LONG ReferralsInMemory;
  35. LONG LinksAdded;
  36. LONG LinksDeleted;
  37. LONG LinksModified;
  38. LONG ForcedCacheFlush;
  39. LONG ReferralsFlushed;
  40. ULONG CacheFlushInterval;
  41. LONG ServerSiteCacheHits;
  42. LONG ServerSiteCacheMisses;
  43. SYSTEMTIME StartTime;
  44. public:
  45. DfsStatistics() : DfsGeneric( DFS_OBJECT_TYPE_STATISTICS )
  46. {
  47. Hits = 0;
  48. Misses = 0;
  49. TotalReferrals = 0;
  50. MinReferralTime = ~0;
  51. MaxReferralTime = 0;
  52. VeryLargeTimeReferrals = 0;
  53. LargeTimeReferrals = 0;
  54. SmallTimeReferrals = 0;
  55. NumberOfErrors = 0;
  56. DfsRequiredMemory = 0;
  57. DfsReferralCacheMemory = 0;
  58. ReferralsInMemory = 0;
  59. LinksAdded = 0;
  60. LinksDeleted = 0;
  61. LinksModified = 0;
  62. ForcedCacheFlush = 0;
  63. CacheFlushInterval = 0;
  64. ServerSiteCacheHits = 0;
  65. ServerSiteCacheMisses = 0;
  66. GetLocalTime( &StartTime );
  67. }
  68. ~DfsStatistics()
  69. {
  70. NOTHING;
  71. }
  72. VOID
  73. UpdateReferralStat ( BOOLEAN CacheHit,
  74. ULONG TimeConsumed,
  75. NTSTATUS ReferralStatus )
  76. {
  77. InterlockedIncrement( &TotalReferrals );
  78. if (ReferralStatus != STATUS_SUCCESS)
  79. {
  80. InterlockedIncrement( &NumberOfErrors);
  81. }
  82. else {
  83. if (CacheHit == TRUE)
  84. {
  85. InterlockedIncrement( &Hits );
  86. }
  87. else
  88. {
  89. InterlockedIncrement( &Misses );
  90. }
  91. if (TimeConsumed < MinReferralTime)
  92. {
  93. MinReferralTime = TimeConsumed;
  94. }
  95. else if (TimeConsumed > MaxReferralTime)
  96. {
  97. MaxReferralTime = TimeConsumed;
  98. }
  99. if (TimeConsumed > LARGE_TIME_REFERRAL)
  100. {
  101. InterlockedIncrement( &LargeTimeReferrals );
  102. if (TimeConsumed > VERY_LARGE_TIME_REFERRAL)
  103. {
  104. InterlockedIncrement( &VeryLargeTimeReferrals );
  105. }
  106. }
  107. else if (TimeConsumed < SMALL_TIME_REFERRAL)
  108. {
  109. InterlockedIncrement( &SmallTimeReferrals );
  110. }
  111. }
  112. return NOTHING;
  113. }
  114. VOID
  115. AddCacheMemoryStat ( LONG Size )
  116. {
  117. InterlockedExchangeAdd( &DfsReferralCacheMemory, Size );
  118. }
  119. VOID
  120. SubCacheMemoryStat ( LONG Size )
  121. {
  122. InterlockedExchangeAdd( &DfsReferralCacheMemory, (-Size) );
  123. }
  124. VOID
  125. AddRequiredMemoryStat ( LONG Size )
  126. {
  127. InterlockedExchangeAdd( &DfsRequiredMemory, Size );
  128. }
  129. VOID
  130. SubRequiredMemoryStat ( LONG Size )
  131. {
  132. InterlockedExchangeAdd( &DfsRequiredMemory, (-Size) );
  133. }
  134. VOID
  135. UpdateLinkAdded()
  136. {
  137. InterlockedIncrement( &LinksAdded );
  138. }
  139. VOID
  140. UpdateLinkDeleted()
  141. {
  142. InterlockedIncrement( &LinksDeleted );
  143. }
  144. VOID
  145. UpdateLinkModified()
  146. {
  147. InterlockedIncrement( &LinksModified );
  148. }
  149. VOID
  150. UpdateForcedCacheFlush()
  151. {
  152. InterlockedIncrement( &ForcedCacheFlush );
  153. }
  154. VOID
  155. DumpStatistics(
  156. PUNICODE_STRING pLogicalShare );
  157. VOID
  158. UpdateServerSiteStat( BOOLEAN CacheHit)
  159. {
  160. if (CacheHit == TRUE)
  161. {
  162. InterlockedIncrement( &ServerSiteCacheHits );
  163. }
  164. else
  165. {
  166. InterlockedIncrement( &ServerSiteCacheMisses );
  167. }
  168. }
  169. };
  170. #endif // __DFS_STATISTICS__