reqmon 2.3.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. Utils/CPMetrics.py +270 -0
  2. Utils/CertTools.py +62 -0
  3. Utils/EmailAlert.py +50 -0
  4. Utils/ExtendedUnitTestCase.py +62 -0
  5. Utils/FileTools.py +182 -0
  6. Utils/IteratorTools.py +80 -0
  7. Utils/MathUtils.py +31 -0
  8. Utils/MemoryCache.py +119 -0
  9. Utils/Patterns.py +24 -0
  10. Utils/Pipeline.py +137 -0
  11. Utils/PortForward.py +97 -0
  12. Utils/ProcessStats.py +103 -0
  13. Utils/PythonVersion.py +17 -0
  14. Utils/Signals.py +36 -0
  15. Utils/TemporaryEnvironment.py +27 -0
  16. Utils/Throttled.py +227 -0
  17. Utils/Timers.py +130 -0
  18. Utils/Timestamps.py +86 -0
  19. Utils/TokenManager.py +143 -0
  20. Utils/Tracing.py +60 -0
  21. Utils/TwPrint.py +98 -0
  22. Utils/Utilities.py +308 -0
  23. Utils/__init__.py +11 -0
  24. WMCore/Algorithms/Permissions.py +27 -0
  25. WMCore/Algorithms/__init__.py +7 -0
  26. WMCore/Cache/GenericDataCache.py +98 -0
  27. WMCore/Cache/WMConfigCache.py +572 -0
  28. WMCore/Cache/__init__.py +0 -0
  29. WMCore/Configuration.py +651 -0
  30. WMCore/DataStructs/File.py +177 -0
  31. WMCore/DataStructs/Fileset.py +140 -0
  32. WMCore/DataStructs/Job.py +182 -0
  33. WMCore/DataStructs/JobGroup.py +142 -0
  34. WMCore/DataStructs/JobPackage.py +49 -0
  35. WMCore/DataStructs/LumiList.py +734 -0
  36. WMCore/DataStructs/Mask.py +219 -0
  37. WMCore/DataStructs/Pickleable.py +24 -0
  38. WMCore/DataStructs/Run.py +256 -0
  39. WMCore/DataStructs/Subscription.py +175 -0
  40. WMCore/DataStructs/WMObject.py +47 -0
  41. WMCore/DataStructs/WorkUnit.py +112 -0
  42. WMCore/DataStructs/Workflow.py +60 -0
  43. WMCore/DataStructs/__init__.py +8 -0
  44. WMCore/Database/CMSCouch.py +1349 -0
  45. WMCore/Database/CouchUtils.py +118 -0
  46. WMCore/Database/__init__.py +9 -0
  47. WMCore/Lexicon.py +836 -0
  48. WMCore/REST/Auth.py +202 -0
  49. WMCore/REST/CherryPyPeriodicTask.py +166 -0
  50. WMCore/REST/Error.py +333 -0
  51. WMCore/REST/Format.py +642 -0
  52. WMCore/REST/HeartbeatMonitorBase.py +90 -0
  53. WMCore/REST/Main.py +623 -0
  54. WMCore/REST/Server.py +2435 -0
  55. WMCore/REST/Services.py +24 -0
  56. WMCore/REST/Test.py +120 -0
  57. WMCore/REST/Tools.py +38 -0
  58. WMCore/REST/Validation.py +250 -0
  59. WMCore/REST/__init__.py +1 -0
  60. WMCore/ReqMgr/DataStructs/AuthzByStatus.py +113 -0
  61. WMCore/ReqMgr/DataStructs/DefaultConfig/CAMPAIGN_CONFIG.py +116 -0
  62. WMCore/ReqMgr/DataStructs/DefaultConfig/DAS_RESULT_FILTER.py +3 -0
  63. WMCore/ReqMgr/DataStructs/DefaultConfig/EDITABLE_SPLITTING_PARAM_CONFIG.py +42 -0
  64. WMCore/ReqMgr/DataStructs/DefaultConfig/UNIFIED_CONFIG.py +240 -0
  65. WMCore/ReqMgr/DataStructs/DefaultConfig/__init__.py +0 -0
  66. WMCore/ReqMgr/DataStructs/ReqMgrConfigDataCache.py +65 -0
  67. WMCore/ReqMgr/DataStructs/Request.py +293 -0
  68. WMCore/ReqMgr/DataStructs/RequestError.py +21 -0
  69. WMCore/ReqMgr/DataStructs/RequestStatus.py +209 -0
  70. WMCore/ReqMgr/DataStructs/RequestType.py +13 -0
  71. WMCore/ReqMgr/DataStructs/__init__.py +0 -0
  72. WMCore/ReqMgr/__init__.py +1 -0
  73. WMCore/Services/AlertManager/AlertManagerAPI.py +111 -0
  74. WMCore/Services/AlertManager/__init__.py +0 -0
  75. WMCore/Services/CRIC/CRIC.py +238 -0
  76. WMCore/Services/CRIC/__init__.py +0 -0
  77. WMCore/Services/DBS/DBS3Reader.py +1044 -0
  78. WMCore/Services/DBS/DBSConcurrency.py +44 -0
  79. WMCore/Services/DBS/DBSErrors.py +113 -0
  80. WMCore/Services/DBS/DBSReader.py +23 -0
  81. WMCore/Services/DBS/DBSUtils.py +139 -0
  82. WMCore/Services/DBS/DBSWriterObjects.py +381 -0
  83. WMCore/Services/DBS/ProdException.py +133 -0
  84. WMCore/Services/DBS/__init__.py +8 -0
  85. WMCore/Services/FWJRDB/FWJRDBAPI.py +118 -0
  86. WMCore/Services/FWJRDB/__init__.py +0 -0
  87. WMCore/Services/HTTPS/HTTPSAuthHandler.py +66 -0
  88. WMCore/Services/HTTPS/__init__.py +0 -0
  89. WMCore/Services/LogDB/LogDB.py +201 -0
  90. WMCore/Services/LogDB/LogDBBackend.py +191 -0
  91. WMCore/Services/LogDB/LogDBExceptions.py +11 -0
  92. WMCore/Services/LogDB/LogDBReport.py +85 -0
  93. WMCore/Services/LogDB/__init__.py +0 -0
  94. WMCore/Services/MSPileup/__init__.py +0 -0
  95. WMCore/Services/MSUtils/MSUtils.py +54 -0
  96. WMCore/Services/MSUtils/__init__.py +0 -0
  97. WMCore/Services/McM/McM.py +173 -0
  98. WMCore/Services/McM/__init__.py +8 -0
  99. WMCore/Services/MonIT/Grafana.py +133 -0
  100. WMCore/Services/MonIT/__init__.py +0 -0
  101. WMCore/Services/PyCondor/PyCondorAPI.py +154 -0
  102. WMCore/Services/PyCondor/PyCondorUtils.py +105 -0
  103. WMCore/Services/PyCondor/__init__.py +0 -0
  104. WMCore/Services/ReqMgr/ReqMgr.py +261 -0
  105. WMCore/Services/ReqMgr/__init__.py +0 -0
  106. WMCore/Services/ReqMgrAux/ReqMgrAux.py +419 -0
  107. WMCore/Services/ReqMgrAux/__init__.py +0 -0
  108. WMCore/Services/RequestDB/RequestDBReader.py +267 -0
  109. WMCore/Services/RequestDB/RequestDBWriter.py +39 -0
  110. WMCore/Services/RequestDB/__init__.py +0 -0
  111. WMCore/Services/Requests.py +624 -0
  112. WMCore/Services/Rucio/Rucio.py +1287 -0
  113. WMCore/Services/Rucio/RucioUtils.py +74 -0
  114. WMCore/Services/Rucio/__init__.py +0 -0
  115. WMCore/Services/RucioConMon/RucioConMon.py +128 -0
  116. WMCore/Services/RucioConMon/__init__.py +0 -0
  117. WMCore/Services/Service.py +400 -0
  118. WMCore/Services/StompAMQ/__init__.py +0 -0
  119. WMCore/Services/TagCollector/TagCollector.py +155 -0
  120. WMCore/Services/TagCollector/XMLUtils.py +98 -0
  121. WMCore/Services/TagCollector/__init__.py +0 -0
  122. WMCore/Services/UUIDLib.py +13 -0
  123. WMCore/Services/UserFileCache/UserFileCache.py +160 -0
  124. WMCore/Services/UserFileCache/__init__.py +8 -0
  125. WMCore/Services/WMAgent/WMAgent.py +63 -0
  126. WMCore/Services/WMAgent/__init__.py +0 -0
  127. WMCore/Services/WMArchive/CMSSWMetrics.py +526 -0
  128. WMCore/Services/WMArchive/DataMap.py +463 -0
  129. WMCore/Services/WMArchive/WMArchive.py +33 -0
  130. WMCore/Services/WMArchive/__init__.py +0 -0
  131. WMCore/Services/WMBS/WMBS.py +97 -0
  132. WMCore/Services/WMBS/__init__.py +0 -0
  133. WMCore/Services/WMStats/DataStruct/RequestInfoCollection.py +300 -0
  134. WMCore/Services/WMStats/DataStruct/__init__.py +0 -0
  135. WMCore/Services/WMStats/WMStatsPycurl.py +145 -0
  136. WMCore/Services/WMStats/WMStatsReader.py +445 -0
  137. WMCore/Services/WMStats/WMStatsWriter.py +273 -0
  138. WMCore/Services/WMStats/__init__.py +0 -0
  139. WMCore/Services/WMStatsServer/WMStatsServer.py +134 -0
  140. WMCore/Services/WMStatsServer/__init__.py +0 -0
  141. WMCore/Services/WorkQueue/WorkQueue.py +492 -0
  142. WMCore/Services/WorkQueue/__init__.py +0 -0
  143. WMCore/Services/__init__.py +8 -0
  144. WMCore/Services/pycurl_manager.py +574 -0
  145. WMCore/WMBase.py +50 -0
  146. WMCore/WMException.py +183 -0
  147. WMCore/WMExceptions.py +269 -0
  148. WMCore/WMFactory.py +76 -0
  149. WMCore/WMLogging.py +108 -0
  150. WMCore/WMStats/CherryPyThreads/CleanUpTask.py +46 -0
  151. WMCore/WMStats/CherryPyThreads/DataCacheUpdate.py +45 -0
  152. WMCore/WMStats/CherryPyThreads/HeartbeatMonitor.py +6 -0
  153. WMCore/WMStats/CherryPyThreads/LogDBTasks.py +29 -0
  154. WMCore/WMStats/CherryPyThreads/__init__.py +0 -0
  155. WMCore/WMStats/DataStructs/DataCache.py +92 -0
  156. WMCore/WMStats/DataStructs/__init__.py +0 -0
  157. WMCore/WMStats/Service/ActiveRequestJobInfo.py +123 -0
  158. WMCore/WMStats/Service/MetaDataInfo.py +26 -0
  159. WMCore/WMStats/Service/RequestInfo.py +127 -0
  160. WMCore/WMStats/Service/RestApiHub.py +51 -0
  161. WMCore/WMStats/Service/__init__.py +0 -0
  162. WMCore/WMStats/T0/CherryPyThreads/T0DataCacheUpdate.py +35 -0
  163. WMCore/WMStats/T0/CherryPyThreads/__init__.py +0 -0
  164. WMCore/WMStats/T0/Service/T0RestApiHub.py +37 -0
  165. WMCore/WMStats/T0/Service/__init__.py +0 -0
  166. WMCore/WMStats/T0/__init__.py +0 -0
  167. WMCore/WMStats/WebGui/FrontPage.py +59 -0
  168. WMCore/WMStats/WebGui/__init__.py +0 -0
  169. WMCore/WMStats/__init__.py +1 -0
  170. WMCore/Wrappers/JsonWrapper/JSONThunker.py +342 -0
  171. WMCore/Wrappers/JsonWrapper/__init__.py +7 -0
  172. WMCore/Wrappers/__init__.py +6 -0
  173. WMCore/__init__.py +10 -0
  174. reqmon-2.3.10.data/data/bin/wmc-dist-patch +15 -0
  175. reqmon-2.3.10.data/data/bin/wmc-dist-unpatch +8 -0
  176. reqmon-2.3.10.data/data/bin/wmc-httpd +3 -0
  177. reqmon-2.3.10.data/data/data/couchapps/LogDB/_id +1 -0
  178. reqmon-2.3.10.data/data/data/couchapps/LogDB/couchapp.json +5 -0
  179. reqmon-2.3.10.data/data/data/couchapps/LogDB/filters/filterDeletedDocs.js +3 -0
  180. reqmon-2.3.10.data/data/data/couchapps/LogDB/language +1 -0
  181. reqmon-2.3.10.data/data/data/couchapps/LogDB/validate_doc_update.js +6 -0
  182. reqmon-2.3.10.data/data/data/couchapps/LogDB/views/logByRequest/map.js +9 -0
  183. reqmon-2.3.10.data/data/data/couchapps/LogDB/views/logByRequestAndThread/map.js +3 -0
  184. reqmon-2.3.10.data/data/data/couchapps/LogDB/views/requests/map.js +5 -0
  185. reqmon-2.3.10.data/data/data/couchapps/LogDB/views/requests/reduce.js +1 -0
  186. reqmon-2.3.10.data/data/data/couchapps/LogDB/views/tstamp/map.js +7 -0
  187. reqmon-2.3.10.data/data/data/couchapps/T0Request/_id +1 -0
  188. reqmon-2.3.10.data/data/data/couchapps/T0Request/couchapp.json +5 -0
  189. reqmon-2.3.10.data/data/data/couchapps/T0Request/filters/repfilter.js +3 -0
  190. reqmon-2.3.10.data/data/data/couchapps/T0Request/language +1 -0
  191. reqmon-2.3.10.data/data/data/couchapps/T0Request/updates/updaterequest.js +79 -0
  192. reqmon-2.3.10.data/data/data/couchapps/T0Request/validate_doc_update.js +6 -0
  193. reqmon-2.3.10.data/data/data/couchapps/T0Request/views/byrequest/map.js +3 -0
  194. reqmon-2.3.10.data/data/data/couchapps/T0Request/views/bystatus/map.js +7 -0
  195. reqmon-2.3.10.data/data/data/couchapps/T0Request/views/bystatusandtime/map.js +7 -0
  196. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/ColVis.css +76 -0
  197. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/font-awesome.min.css +4 -0
  198. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/badge-circle-check-16.png +0 -0
  199. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/badge-circle-cross-16.png +0 -0
  200. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/badge-circle-plus-16.png +0 -0
  201. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/badge-square-check-16.png +0 -0
  202. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/cms_logo.gif +0 -0
  203. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/cms_logo.jpeg +0 -0
  204. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  205. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  206. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
  207. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  208. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
  209. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  210. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  211. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_highlight-hard_55_5c9ccc_1x100.png +0 -0
  212. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  213. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-bg_inset-soft_100_fcfdfd_1x100.png +0 -0
  214. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_217bc0_256x240.png +0 -0
  215. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_2694e8_256x240.png +0 -0
  216. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_2e83ff_256x240.png +0 -0
  217. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_469bdd_256x240.png +0 -0
  218. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_6da8d5_256x240.png +0 -0
  219. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_cd0a0a_256x240.png +0 -0
  220. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_d8e7f3_256x240.png +0 -0
  221. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/ui-icons_f9bd01_256x240.png +0 -0
  222. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/images/warning-16.png +0 -0
  223. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/jquery-ui-1.12.0.css +1312 -0
  224. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/jquery.dataTables.css +241 -0
  225. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/logdb.css +60 -0
  226. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/css/main_layout.css +565 -0
  227. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/FontAwesome.otf +0 -0
  228. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/fontawesome-webfont.eot +0 -0
  229. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/fontawesome-webfont.svg +565 -0
  230. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/fontawesome-webfont.ttf +0 -0
  231. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/fontawesome-webfont.woff +0 -0
  232. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/fonts/fontawesome-webfont.woff2 +0 -0
  233. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/Sorting icons.psd +0 -0
  234. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/back_disabled.jpg +0 -0
  235. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/back_enabled.jpg +0 -0
  236. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/error.png +0 -0
  237. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/favicon.ico +0 -0
  238. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/forward_disabled.jpg +0 -0
  239. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/forward_enabled.jpg +0 -0
  240. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/loader-1.gif +0 -0
  241. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/module.caption.backg.png +0 -0
  242. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/module.caption.backg.rolledup.png +0 -0
  243. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/rollup.gif +0 -0
  244. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/sort_asc.png +0 -0
  245. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/sort_asc_disabled.png +0 -0
  246. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/sort_both.png +0 -0
  247. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/sort_desc.png +0 -0
  248. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/sort_desc_disabled.png +0 -0
  249. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/stable.png +0 -0
  250. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/images/warning.png +0 -0
  251. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/index.html +105 -0
  252. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/index.html.min +106 -0
  253. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/index.html.org +125 -0
  254. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Controller/WMStats.ActiveRequestController.js +61 -0
  255. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Controller/WMStats.GenericController.js +38 -0
  256. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Controller/WMStats.WorkloadSummaryController.js +12 -0
  257. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Controller/import.js +6 -0
  258. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T0/WMStats.RequestSummary.js +71 -0
  259. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T0/WMStats.RunSummary.js +70 -0
  260. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.AgentRequestSummary.js +28 -0
  261. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.CMSSWSummary.js +28 -0
  262. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.CampaignSummary.js +28 -0
  263. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.ReqMgrRequest.js +10 -0
  264. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/T1/WMStats.RequestSummary.js +190 -0
  265. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Agents.js +98 -0
  266. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Alerts.js +21 -0
  267. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Campaigns.js +25 -0
  268. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.GenericRequests.js +728 -0
  269. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.History.js +78 -0
  270. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.JobDetails.js +19 -0
  271. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.JobSummary.js +32 -0
  272. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.LogDBData.js +93 -0
  273. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.LogMessage.js +38 -0
  274. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.SiteSummary.js +24 -0
  275. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Sites.js +25 -0
  276. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.Tasks.js +107 -0
  277. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats.WorkloadSummary.js +20 -0
  278. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/WMStats._StructBase.js +37 -0
  279. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/DataStruct/import.js +29 -0
  280. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T0/WMStats.ActiveRequestModel.js +9 -0
  281. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T0/WMStats.RequestLogDetailModel.js +17 -0
  282. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T0/WMStats.RequestLogModel.js +14 -0
  283. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T0/WMStats.RequestModel.js +3 -0
  284. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T0/WMStats.RequestSearchModel.js +8 -0
  285. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T1/WMStats.ActiveRequestModel.js +9 -0
  286. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T1/WMStats.ReqMgrRequestModel.js +8 -0
  287. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T1/WMStats.RequestLogDetailModel.js +18 -0
  288. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T1/WMStats.RequestLogModel.js +14 -0
  289. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/T1/WMStats.RequestSearchModel.js +8 -0
  290. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.AgentModel.js +3 -0
  291. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.AlertModel.js +6 -0
  292. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.HistoryModel.js +14 -0
  293. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.JobDetailModel.js +22 -0
  294. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.JobSummaryModel.js +18 -0
  295. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats.WorkloadSummaryModel.js +8 -0
  296. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats._AjaxModelBase.js +55 -0
  297. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats._ModelBase.js +77 -0
  298. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/WMStats._RequestModelBase.js +127 -0
  299. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Models/import.js +26 -0
  300. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/ViewModels/WMStats.ViewModel.js +511 -0
  301. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/ViewModels/import.js +2 -0
  302. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Controls/T0/WMStats.Controls.js +117 -0
  303. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Controls/T1/WMStats.Controls.js +158 -0
  304. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Controls/WMStats.CommonControls.js +100 -0
  305. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Controls/import.js +10 -0
  306. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Graphs/WMStats.SiteHistoryGraph.js +8 -0
  307. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Graphs/import.js +3 -0
  308. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.CategoryDetailList.js +38 -0
  309. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.RequestAlertGUI.js +128 -0
  310. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.RequestDataList.js +25 -0
  311. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.RequestDetailList.js +68 -0
  312. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T0/WMStats.RequestSummaryList.js +31 -0
  313. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.CategoryDetailList.js +54 -0
  314. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestAlertGUI.js +81 -0
  315. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDataList.js +26 -0
  316. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestDetailList.js +122 -0
  317. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.RequestSummaryList.js +35 -0
  318. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/T1/WMStats.ResubmissionList.js +64 -0
  319. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.AgentDetailList.js +137 -0
  320. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.CategoryTitle.js +20 -0
  321. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.HTMLList.js +12 -0
  322. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.JobDetailList.js +178 -0
  323. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.RequestLogList.js +88 -0
  324. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/WMStats.RequestTitle.js +33 -0
  325. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/HTMLList/import.js +25 -0
  326. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T0/WMStats.ActiveRequestTable.js +142 -0
  327. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T0/WMStats.RunSummaryTable.js +77 -0
  328. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T0/WMStats.TaskSummaryTable.js +127 -0
  329. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T0/addCategoryMap.js +10 -0
  330. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.ActiveRequestTable.js +132 -0
  331. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.ActiveRequestTableWithJob.js +164 -0
  332. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.AgentRequestSummaryTable.js +78 -0
  333. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.CMSSWSummaryTable.js +76 -0
  334. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.CampaignSummaryTable.js +76 -0
  335. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.SiteSummaryTable.js +63 -0
  336. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/WMStats.TaskSummaryTable.js +124 -0
  337. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/T1/addCategoryMap.js +17 -0
  338. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/WMStats.JobSummaryTable.js +71 -0
  339. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/WMStats.Table.js +70 -0
  340. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/WMStats.TableController.js +130 -0
  341. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/WMStats.WorkloadSummaryTable.js +62 -0
  342. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/Tables/import.js +26 -0
  343. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/WMStats.CategoryMap.js +45 -0
  344. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/WMStats.View.IndexHTML.js +137 -0
  345. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/Views/import.js +3 -0
  346. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/WMStats.Ajax.js +74 -0
  347. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/WMStats.Couch.js +83 -0
  348. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/WMStats.Globals.js +200 -0
  349. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/WMStats.Utils.js +283 -0
  350. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/import-all.min.js +7 -0
  351. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/loader.js +27 -0
  352. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/minified/global.min.js +639 -0
  353. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/minified/import-all-t0.min.js +4317 -0
  354. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/js/minified/import-all-t1.min.js +4972 -0
  355. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/lib/jquery.dataTables.columnFilter.js +732 -0
  356. reqmon-2.3.10.data/data/data/couchapps/WMStats/_attachments/lib/namespace.js +23 -0
  357. reqmon-2.3.10.data/data/data/couchapps/WMStats/filters/deleteFatDocFilter.js +3 -0
  358. reqmon-2.3.10.data/data/data/couchapps/WMStats/filters/filterDeletedDocs.js +3 -0
  359. reqmon-2.3.10.data/data/data/couchapps/WMStats/filters/repfilter.js +7 -0
  360. reqmon-2.3.10.data/data/data/couchapps/WMStats/rewrites.json +110 -0
  361. reqmon-2.3.10.data/data/data/couchapps/WMStats/shows/redirect.js +23 -0
  362. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/agentInfo.js +17 -0
  363. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/generalFields.js +11 -0
  364. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/insertRequest.js +13 -0
  365. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/jobLogArchiveLocation.js +10 -0
  366. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/jobStateTransition.js +17 -0
  367. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/jobSummaryState.js +5 -0
  368. reqmon-2.3.10.data/data/data/couchapps/WMStats/updates/totalStats.js +39 -0
  369. reqmon-2.3.10.data/data/data/couchapps/WMStats/validate_doc_update.js +10 -0
  370. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl/language +1 -0
  371. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl/views/requestAgentUrl/map.erl +11 -0
  372. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl/views/requestAgentUrl/reduce.erl +1 -0
  373. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl1/language +1 -0
  374. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl1/views/byAgentURL/map.erl +11 -0
  375. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl2/language +1 -0
  376. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl2/views/allWorkflows/map.erl +10 -0
  377. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl2/views/allWorkflows/reduce.erl +1 -0
  378. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl3/language +1 -0
  379. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl3/views/jobsByStatusWorkflow/map.erl +32 -0
  380. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl3/views/jobsByStatusWorkflow/reduce.erl +1 -0
  381. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl4/language +1 -0
  382. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl4/views/cooledoffRequests/map.erl +16 -0
  383. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl4/views/cooledoffRequests/reduce.erl +1 -0
  384. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl5/language +1 -0
  385. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl5/views/time/map.erl +11 -0
  386. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl6/language +1 -0
  387. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl6/views/requestHistory/map.erl +11 -0
  388. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl6/views/requestHistory/reduce.erl +1 -0
  389. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl7/language +1 -0
  390. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl7/views/agentInfo/map.erl +10 -0
  391. reqmon-2.3.10.data/data/data/couchapps/WMStatsErl7/views/latestRequest/map.erl +11 -0
  392. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/index.html +44 -0
  393. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/js/container/histogram.js +141 -0
  394. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/js/container/tree.js +67 -0
  395. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/js/dataMap/errorData.js +69 -0
  396. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/js/htmlFormatter/listFormatter.js +79 -0
  397. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/js/layout/gridLayout.js +77 -0
  398. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/performanceHistogram.html +46 -0
  399. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/_attachments/style/main.css +17 -0
  400. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/couchapp.json +4 -0
  401. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/filters/repfilter.js +3 -0
  402. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/lib/mustache.js +333 -0
  403. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/lib/validate.js +29 -0
  404. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/lists/completedWorkflows.js +27 -0
  405. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/lists/performanceHistogram.js +15 -0
  406. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/rewrites.json +65 -0
  407. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/shows/histogramByWorkflow.js +75 -0
  408. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/shows/lumiMissingByWorkflow.js +97 -0
  409. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/templates/histogramByWorkflow.html +126 -0
  410. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/templates/performanceData.html +44 -0
  411. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/updates/updateacdc.js +6 -0
  412. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/updates/updatecollection.js +5 -0
  413. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/validate_doc_update.js +8 -0
  414. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/vendor/protovis/_attachments/protovis-r3.2.js +277 -0
  415. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/views/outputDataByPrimDs/map.js +21 -0
  416. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/views/performanceDataByCampaign/map.js +19 -0
  417. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/views/summaryByInputdataset/map.js +7 -0
  418. reqmon-2.3.10.data/data/data/couchapps/WorkloadSummary/views/summaryByOutputdataset/map.js +7 -0
  419. reqmon-2.3.10.dist-info/LICENSE +202 -0
  420. reqmon-2.3.10.dist-info/METADATA +24 -0
  421. reqmon-2.3.10.dist-info/NOTICE +16 -0
  422. reqmon-2.3.10.dist-info/RECORD +424 -0
  423. reqmon-2.3.10.dist-info/WHEEL +5 -0
  424. reqmon-2.3.10.dist-info/top_level.txt +2 -0
@@ -0,0 +1,4317 @@
1
+ WMStats.namespace("_StructBase");
2
+
3
+ WMStats._StructBase = function() {
4
+ this._data = null;
5
+ };
6
+
7
+ WMStats._StructBase.prototype = {
8
+
9
+ getData: function() {
10
+ return this._data;
11
+ },
12
+
13
+ setData: function(couchData) {
14
+ this._data = this.convertCouchData(couchData);
15
+ },
16
+
17
+ getDataByKey: function(key, combineFunc) {
18
+ var data = {};
19
+ var dataList = this._data;
20
+ for (var i in dataList) {
21
+ if (data[dataList[i][key]] === undefined) {
22
+ data[dataList[i][key]] = dataList[i];
23
+ } else if (combineFuc === undefined) {
24
+ data[dataList[i][key]] = dataList[i];
25
+ } else {
26
+ data[dataList[i][key]] = combineFunc(data[dataList[i][key]], dataList[i]);
27
+ }
28
+
29
+ }
30
+ return data;
31
+ },
32
+
33
+ convertCouchData: function(couchData) {
34
+ // defaut conversion need to be over written
35
+ return couchData;
36
+ }
37
+ };
38
+ WMStats.namespace("GenericRequests");
39
+ WMStats.namespace("GenericRequestsSummary");
40
+ WMStats.namespace("RequestsByKey");
41
+
42
+ WMStats.GenericRequestsSummary = function (summaryStruct) {
43
+
44
+ this._get = WMStats.Utils.get;
45
+
46
+ this.summaryStruct = {length: 0};
47
+ //default job status structure
48
+ this.jobStatus = {
49
+ success: 0,
50
+ canceled: 0,
51
+ transition: 0,
52
+ queued: {first: 0, retry: 0},
53
+ submitted: {first: 0, retry: 0},
54
+ submitted: {pending: 0, running: 0},
55
+ failure: {create: 0, submit: 0, exception: 0},
56
+ cooloff: {create: 0, submit: 0, job: 0},
57
+ paused: {create: 0, submit: 0, job: 0},
58
+ };
59
+
60
+
61
+ if (summaryStruct) {
62
+ this.summaryStruct = WMStats.Utils.cloneObj(summaryStruct);
63
+ };
64
+ };
65
+
66
+ WMStats.GenericRequestsSummary.prototype = {
67
+
68
+ getJobStatus: function(statusStr) {
69
+ return WMStats.Utils.get(this.jobStatus, statusStr, 0);
70
+ },
71
+
72
+ getAvgProgressSummary: function (doc) {
73
+
74
+ var progressStat = {};
75
+ var datasets = {};
76
+ var numDataset = 0;
77
+ if (doc.outputdatasets) {
78
+ numDataset = doc.outputdatasets.length;
79
+ }
80
+
81
+ for (var task in doc.tasks) {
82
+ for(var site in doc.tasks[task].sites) {
83
+ for (var outputDS in doc.tasks[task].sites[site].dataset) {
84
+ if (datasets[outputDS] === undefined) {
85
+ if (!doc.outputdatasets) {
86
+ //if outputdatasets is not defined calcuate from frwj
87
+ numDataset += 1;
88
+ }
89
+ datasets[outputDS] = true;
90
+ }
91
+ WMStats.Utils.updateObj(progressStat, doc.tasks[task].sites[site].dataset[outputDS]);
92
+ }
93
+ }
94
+ }
95
+ for (var prop in progressStat) {
96
+ progressStat[prop] = progressStat[prop] / numDataset;
97
+ }
98
+ progressStat.numDataset = numDataset;
99
+ return progressStat;
100
+ },
101
+
102
+ getAvgEvents: function() {
103
+ // handle legacy event calculation
104
+ if (this.summaryStruct.progress === undefined || this.summaryStruct.progress.events === undefined) {
105
+ return this.summaryStruct.processedEvents;
106
+ } else {
107
+ return this.summaryStruct.progress.events;
108
+ }
109
+ },
110
+
111
+ getAvgLumis: function() {
112
+ // handle legacy event calculation
113
+ if (this.summaryStruct.progress.totalLumis === undefined) {
114
+ return 0;
115
+ } else {
116
+ return this.summaryStruct.progress.totalLumis;
117
+ }
118
+ },
119
+
120
+ getSummary: function(){
121
+ return this.summaryStruct;
122
+ },
123
+
124
+ summaryStructUpdateFuction: null,
125
+
126
+ update: function(summary) {
127
+ WMStats.Utils.updateObj(this.summaryStruct, summary.summaryStruct, true,
128
+ this.summaryStructUpdateFuction);
129
+ WMStats.Utils.updateObj(this.jobStatus, summary.jobStatus);
130
+ },
131
+
132
+ updateFromRequestDoc: function(doc) {
133
+ var summary = this.createSummaryFromRequestDoc(doc);
134
+ this.update(summary);
135
+ },
136
+
137
+ getWMBSTotalJobs: function() {
138
+ return (this.getJobStatus("success") +
139
+ this.getJobStatus("canceled") +
140
+ this.getJobStatus( "transition") +
141
+ this.getTotalFailure() +
142
+ this.getTotalCooloff() +
143
+ this.getTotalPaused() +
144
+ this.getTotalQueued() +
145
+ this.getRunning() +
146
+ this.getPending());
147
+ },
148
+
149
+ getTotalFailure: function() {
150
+ return (this.getJobStatus("failure.create") +
151
+ this.getJobStatus("failure.submit") +
152
+ this.getJobStatus("failure.exception"));
153
+ },
154
+
155
+ getTotalSubmitted: function() {
156
+ return (this.getJobStatus("submitted.first") +
157
+ this.getJobStatus("submitted.retry"));
158
+ },
159
+
160
+ getRunning: function() {
161
+ return this.getJobStatus("submitted.running");
162
+ },
163
+
164
+ getPending: function() {
165
+ return this.getJobStatus("submitted.pending");
166
+ },
167
+ getTotalCooloff:function() {
168
+ return (this.getJobStatus("cooloff.create") +
169
+ this.getJobStatus("cooloff.submit") +
170
+ this.getJobStatus("cooloff.job"));
171
+ },
172
+
173
+ getTotalPaused: function() {
174
+ return (this.getJobStatus("paused.create") +
175
+ this.getJobStatus("paused.submit") +
176
+ this.getJobStatus("paused.job"));
177
+ },
178
+
179
+ getTotalQueued: function() {
180
+ return (this.getJobStatus("queued.first") +
181
+ this.getJobStatus("queued.retry"));
182
+ },
183
+
184
+ createSummaryFromRequestDoc: function(doc) {
185
+ //THis is just interface which update summarySturct property
186
+ var summary = WMStats.RequestsSummary();
187
+ summary.summaryStruct.length = 1;
188
+ summary.jobStatus = this._get(doc, 'status', {});
189
+ return summary;
190
+ }
191
+ };
192
+
193
+ WMStats.RequestStruct = function(requestName) {
194
+ this._workflow = requestName;
195
+ this._summary = WMStats.RequestsSummary();
196
+ // number of requests in the data
197
+ this._addJobs = WMStats.Utils.updateObj;
198
+ };
199
+
200
+ WMStats.RequestStruct.prototype = {
201
+
202
+ getProgressStat: function () {
203
+ var progressStat = {};
204
+ for (var task in this.tasks) {
205
+ for(var site in this.tasks[task].sites) {
206
+ WMStats.Utils.updateObj(progressStat, this.tasks[task].sites[site].dataset);
207
+ }
208
+ }
209
+ return progressStat;
210
+ },
211
+
212
+ getName: function() {
213
+ return this._workflow;
214
+ },
215
+
216
+ getSummary: function() {
217
+ return this._summary.createSummaryFromRequestDoc(this);
218
+ },
219
+
220
+ getTasks: function() {
221
+ return new WMStats.Tasks(this.tasks, this._workflow);
222
+ },
223
+
224
+ getLastState: function() {
225
+ if (this.request_status){
226
+ return this.request_status[this.request_status.length -1].status;
227
+ };
228
+ return null;
229
+ },
230
+
231
+ getLastStateAndTime: function() {
232
+ if (this.request_status){
233
+ return this.request_status[this.request_status.length -1];
234
+ };
235
+ return null;
236
+ },
237
+
238
+ getSkippedStatus: function () {
239
+ if (this.skipped) {
240
+ return this.skipped;
241
+ } else {
242
+ return false;
243
+ }
244
+ },
245
+
246
+ getSkippedDetail: function(fullTaskName) {
247
+ var skippedTasks = {};
248
+ if (this.skipped) {
249
+ for (var task in this.tasks) {
250
+ if (this.tasks[task].skipped) {
251
+ var taskName = task;
252
+ if (!fullTaskName){
253
+ var taskList = task.split('/');
254
+ taskName = taskList[taskList.length - 1];
255
+ }
256
+ skippedTasks[taskName] = this.tasks[task].skipped;
257
+ }
258
+ }
259
+ }
260
+ return skippedTasks;
261
+ },
262
+
263
+ updateFromCouchDoc: function (doc) {
264
+
265
+ function _tasksUpdateFunction (baseObj, addObj, field) {
266
+ if (field === "JobType") {
267
+ baseObj[field] = addObj[field];
268
+ } else if (field === "updated"){
269
+ baseObj[field] = Math.max(baseObj[field], addObj[field]);
270
+ } else {
271
+ baseObj[field] += addObj[field];
272
+ }
273
+ };
274
+
275
+ for (var field in doc) {
276
+ //handles when request is split in more than one agents
277
+ if (field == "AgentJobInfo") {
278
+ //skipping AgentJobInfo field. - added to handle newer ajax call to wmstats server
279
+ continue;
280
+ } else if (this[field] &&
281
+ (field == 'sites' || field == 'status')){
282
+ this._addJobs(this[field], doc[field]);
283
+ } else if (this[field] && field == 'tasks'){
284
+ //Also task['skipped'] value will be updated here
285
+ this._addJobs(this[field], doc[field], true, _tasksUpdateFunction);
286
+
287
+ } else if (this[field] && field == 'output_progress') {
288
+ var outProgress = this.output_progress;
289
+ for (var index in outProgress){
290
+ for (var prop in doc[field][index]) {
291
+ outProgress[index][prop] += doc[field][index][prop];
292
+ //TODO: need combine dataset separately
293
+ }
294
+ }
295
+ } else if (this[field] && field == 'skipped') {
296
+ this[field] = this[field] || doc[field];
297
+ } else if (field == 'agent_url') {
298
+ if (this[field] === undefined) this[field] = [];
299
+ WMStats.Utils.addToSet(this[field], doc[field]);
300
+
301
+ } else {
302
+ this[field] = doc[field];
303
+ }
304
+ }
305
+ }
306
+ };
307
+
308
+ WMStats.GenericRequests = function (data) {
309
+ /*
310
+ * Data structure for holding the request
311
+ * it handles 3 types (not very robust and modular)
312
+ * TODO: remove dependencies from different data type. (tier0, reqmgr)
313
+ * if possible
314
+ * reqmgr_request, agent_request, tier0_request.
315
+ */
316
+ // request data by workflow name
317
+ this._dataByWorkflow = {};
318
+ // request data by agent - only contains information from agent
319
+ // i.e. job status.
320
+ this._dataByWorkflowAgent = {};
321
+ this._get = WMStats.Utils.get;
322
+ this._filter = {};
323
+ this._filteredRequests = null;
324
+ if (data !== undefined) {
325
+ this.setFromRawData(data);
326
+ }
327
+ };
328
+
329
+ WMStats.GenericRequests.prototype = {
330
+
331
+ _mapProperty: function (workflowData, property) {
332
+ if (property == 'request_status') {
333
+ return workflowData[property][workflowData[property].length - 1].status;
334
+ }
335
+ if (property == 'inputdataset') {
336
+ return WMStats.Utils.getInputDatasets(workflowData);
337
+ }
338
+ return workflowData[property];
339
+ },
340
+
341
+ _getRequestObj: function (request) {
342
+ if (typeof(request) == "string") {
343
+ return this.getData(request);
344
+ } else {
345
+ return request;
346
+ }
347
+ },
348
+
349
+ _getStatusObj: function(request, level) {
350
+ //level could be site, task, or request;
351
+ var requestObj = this._getRequestObj(request);
352
+ if (level == "task"){
353
+ return requestObj.tasks.status;
354
+ } else if (level == "site") {
355
+ return requestObj.sites;
356
+ } else {
357
+ return requestObj.status;
358
+ }
359
+ },
360
+
361
+ _requestDateSort: function(a, b) {
362
+ for (var i in a.request_date) {
363
+ if (b.request_date[i] != a.request_date[i]) {
364
+ return (Number(b.request_date[i]) - Number(a.request_date[i]));
365
+ }
366
+ }
367
+ return 0;
368
+ },
369
+
370
+ _andFilter: function(base, filter) {
371
+ var includeFlag = true;
372
+ for (var property in filter) {
373
+ if (!filter[property]) {
374
+ continue;
375
+ }else if (this._mapProperty(base, property) !== undefined &&
376
+ this._contains(this._mapProperty(base, property), filter[property])) {
377
+ continue;
378
+ } else {
379
+ includeFlag = false;
380
+ break;
381
+ }
382
+ }
383
+ return includeFlag;
384
+ },
385
+
386
+ _contains: function(a, b) {
387
+ //TODO change to regular expression or handle numbers
388
+ if ((typeof a) === "string") return (a.toLowerCase().indexOf(b.toLowerCase()) !== -1);
389
+ else if ((typeof a) == "number") return (Number(b) == a);
390
+ else if (a instanceof Array) {
391
+ for (var i in a) {
392
+ if (this._contains(a[i], b)) return true;
393
+ }
394
+ return false;
395
+ } else {
396
+ alert("value need to be either number or string");
397
+ }
398
+ },
399
+
400
+ getProgressStat: function (request) {
401
+ var requestObj = this._getRequestObj(request);
402
+ return requestObj.getProgressStat();
403
+ },
404
+
405
+ getFilter: function() {
406
+ return this._filter;
407
+ },
408
+
409
+ setFilter: function(filter) {
410
+ this._filter = filter;
411
+ },
412
+
413
+ updateRequest: function(doc) {
414
+ /*
415
+ *
416
+ */
417
+ var doc = WMStats.Globals.convertRequestDocToWMStatsFormat(doc);
418
+ var workflow = doc.workflow;
419
+ var agentURL = doc.agent_url;
420
+
421
+ if (workflow && !this._dataByWorkflow[workflow]) {
422
+ this._dataByWorkflow[workflow] = new WMStats.RequestStruct(workflow);;
423
+ }
424
+
425
+ if (agentURL && !this._dataByWorkflowAgent[workflow]) {
426
+ this._dataByWorkflowAgent[workflow] = {};
427
+ }
428
+ //if it is new agent create one.
429
+ if (agentURL && !this._dataByWorkflowAgent[workflow][agentURL]){
430
+ this._dataByWorkflowAgent[workflow][agentURL] = new WMStats.RequestStruct(workflow);
431
+ }
432
+
433
+ // update both _databyWorkflow
434
+ this.getData(workflow).updateFromCouchDoc(doc);
435
+ if (agentURL) {
436
+ this.getData(workflow, agentURL).updateFromCouchDoc(doc);
437
+ }
438
+ },
439
+
440
+ updateBulkRequests: function(docList) {
441
+ for (var row in docList) {
442
+ //not sure why there is null case
443
+ if (docList[row].doc) {
444
+ this.updateRequest(docList[row].doc);
445
+ }
446
+ }
447
+ },
448
+
449
+ updateRequestFromWMStatsServer: function(doc) {
450
+
451
+ var doc = WMStats.Globals.convertRequestDocToWMStatsFormat(doc);
452
+ var workflow = doc.workflow;
453
+
454
+ if (workflow && !this._dataByWorkflow[workflow]) {
455
+ this._dataByWorkflow[workflow] = new WMStats.RequestStruct(workflow);
456
+ this._dataByWorkflow[workflow].updateFromCouchDoc(doc);
457
+ };
458
+
459
+ if (doc.AgentJobInfo) {
460
+
461
+ for (var agentURL in doc.AgentJobInfo) {
462
+ if (agentURL && !this._dataByWorkflowAgent[workflow]) {
463
+ this._dataByWorkflowAgent[workflow] = {};
464
+ };
465
+ this._dataByWorkflowAgent[workflow][agentURL] = new WMStats.RequestStruct(workflow);
466
+ this._dataByWorkflowAgent[workflow][agentURL].updateFromCouchDoc(doc.AgentJobInfo[agentURL]);
467
+ // legacy format which need to be updated
468
+ doc.AgentJobInfo[agentURL].agent_url = agentURL;
469
+ this._dataByWorkflow[workflow].updateFromCouchDoc(doc.AgentJobInfo[agentURL]);
470
+ };
471
+ };
472
+
473
+ },
474
+
475
+ setFromRawData: function(data) {
476
+ /* {"result": [
477
+ * {"sryu_ReReco_reqmgr2_validation_150717_180724_9878":
478
+ * {"InputDataset": "/QDTojWinc_NC_M-1200_TuneZ2star_8TeV-madgraph/Summer12pLHE-DMWM_Validation_DONOTDELETE_Alan_TEST-v1/GEN",
479
+ * "Group": "DATAOPS", "CustodialSites": [], "OpenRunningTimeout": 1800,
480
+ * "Comments": "MCFromGEN LumiBased splitting with 1l per job. Half an hour opened",
481
+ * "Requestor": "sryu", "ProcessingString": "START53_V7C", "ScramArch": "slc6_amd64_gcc472",
482
+ * "SizePerEvent": 1154, "ConfigCacheID": "1ad063a0d73c1d81143b4182cbf84793", "Memory": 2300,
483
+ * "RunBlacklist": [], "PrepID": "B2G-Summer12-00736", "AutoApproveSubscriptionSites": [],
484
+ * "BlockBlacklist": [], "BlockWhitelist": [], "CustodialSubType": "Move",
485
+ * "RequestType": "ReReco", "TimePerEvent": 16.87
486
+ * "OutputDatasets": ["/QDTojWinc_NC_M-1200_TuneZ2star_8TeV-madgraph/Integ_Test-ReReco_SRYU_pnn-v1/GEN-SIM"],
487
+ * "LumisPerJob": 1, "SoftwareVersions": ["CMSSW_5_3_19"],
488
+ * "AcquisitionEra": "Integ_Test", "PrimaryDataset": "QDTojWinc_NC_M-1200_TuneZ2star_8TeV-madgraph",
489
+ * "CouchDBName": "reqmgr_config_cache", "CMSSWVersion": "CMSSW_5_3_19", "NonCustodialSites": [],
490
+ * "RequestSizeFiles": 0, "CouchWorkloadDBName": "reqmgr_workload_cache", "RequestPriority": 90000,
491
+ * "SiteWhitelist": ["T1_US_FNAL", "T2_CH_CERN"],
492
+ * "SubscriptionPriority": "Low", "ProcessingVersion": "1", "Team": "testbed-dev",
493
+ * "SplittingAlgo": "LumiBased", "TotalEstimatedJobs": 100,
494
+ * "RequestTransition": [{"Status": "new", "DN": null, "UpdateTime": 1437149248},
495
+ * {"Status": "assignment-approved", "DN": null, "UpdateTime": 1437149248},
496
+ * {"Status": "assigned", "DN": null, "UpdateTime": 1437149249},
497
+ * {"Status": "acquired", "DN": null, "UpdateTime": 1437150308},
498
+ * {"Status": "running-open", "DN": null, "UpdateTime": 1437152703},
499
+ * {"Status": "running-closed", "DN": null, "UpdateTime": 1437152709},
500
+ * {"Status": "completed", "DN": null, "UpdateTime": 1437227104}],
501
+ * "RequestName": "sryu_ReReco_reqmgr2_validation_150717_180724_9878",
502
+ * "RequestString": "ReReco_reqmgr2_validation",
503
+ * "InputDatasets": ["/QDTojWinc_NC_M-1200_TuneZ2star_8TeV-madgraph/Summer12pLHE-DMWM_Validation_DONOTDELETE_Alan_TEST-v1/GEN"],
504
+ * "CouchURL": "https://reqmgr2-dev.cern.ch/couchdb", "TotalTime": 28800,
505
+ * "RequestorDN": "....",
506
+ * "RequestWorkflow": "https://reqmgr2-dev.cern.ch/couchdb/reqmgr_workload_cache/sryu_ReReco_reqmgr2_validation_150717_180724_9878/spec", "
507
+ * "Campaign": "Agent108_Validation", "GlobalTag": "START53_V7C::All", "RunWhitelist": [],
508
+ * "FilterEfficiency": 1, "DbsUrl": "https://cmsweb-testbed.cern.ch/dbs/int/global/DBSReader",
509
+ * "TotalInputLumis": 100, "RequestDate": [2015, 7, 17, 16, 7, 24], "NonCustodialSubType": "Replica",
510
+ * "TotalInputFiles": 1, "SiteBlacklist": [], "TotalInputEvents": 2500,
511
+ * "ConfigCacheUrl": "https://cmsweb.cern.ch/couchdb",
512
+ * "_id": "sryu_ReReco_reqmgr2_validation_150717_180724_9878",
513
+ * "RequestStatus": "completed",
514
+ * "RequestNumEvents": 50000,
515
+ * "AgentJobInfo": {"vocms008.cern.ch:9999":
516
+ * {"status": {"success": 107},
517
+ * "agent_team": "testbed-dev",
518
+ * "workflow": "sryu_ReReco_reqmgr2_validation_150717_180724_9878",
519
+ * "timestamp": 1437498506,
520
+ * "_rev": "1-d792c9d73285ff1318d7f5c0e2b2f486",
521
+ * "sites": {"T2_CH_CERN": {"success": 107}},
522
+ * "agent": "WMAgent",
523
+ * "tasks": {"/sryu_ReReco_reqmgr2_validation_150717_180724_9878/ReReco/ReRecoMergeRAWSIMoutput/ReRecoRAWSIMoutputMergeLogCollect":
524
+ * {"status": {"success": 1},
525
+ * "sites": {"T2_CH_CERN":
526
+ * {"inputEvents": 0,
527
+ * "cmsRunCPUPerformance": {"totalJobCPU": 0, "totalJobTime": 0, "totalEventCPU": 0},
528
+ * "wrappedTotalJobTime": 6, "success": 1, "dataset": {}}}},
529
+ * "/sryu_ReReco_reqmgr2_validation_150717_180724_9878/ReReco/LogCollect":
530
+ * {"status": {"success": 1},
531
+ * "sites": .....}}}, ....},
532
+ * "agent_url": "vocms008.cern.ch:9999",
533
+ * "_id": "98e5e3643f1c6575407b6de04bd6619a",
534
+ * "type": "agent_request"}},
535
+ * "sryu_ReReco_reqmgr2_validation_150721_194418_5448":
536
+ * {"InputDataset": .....
537
+ * }}]
538
+ * }
539
+ */
540
+ if (data.result.length == 1) {
541
+ for (var req in data.result[0]) {
542
+ this.updateRequestFromWMStatsServer(data.result[0][req]);
543
+ }
544
+ }
545
+ },
546
+
547
+ filterRequests: function(filter) {
548
+ var requestData = this.getData();
549
+ var filteredData = {};
550
+ var requestWithAgentData = this.getDataWithAgent();
551
+ var filteredDataWithAgent = {};
552
+ if (filter === undefined) {filter = this._filter;}
553
+ for (var workflowName in requestData) {
554
+ if (this._andFilter(requestData[workflowName], filter)){
555
+ filteredData[workflowName] = requestData[workflowName];
556
+ filteredDataWithAgent[workflowName] = requestWithAgentData[workflowName];
557
+ }
558
+ }
559
+ this._filteredRequests = WMStats.Requests();
560
+ this._filteredRequests.setDataByWorkflow(filteredData, filteredDataWithAgent);
561
+ return this._filteredRequests;
562
+ },
563
+
564
+ getKeyValue: function(request, keyString, defaultVal) {
565
+ //keyString is opject property separte by '.'
566
+ return this._get(this._dataByWorkflow[request], keyString, defaultVal);
567
+ },
568
+
569
+ getData: function(workflow, agentURL) {
570
+ if (workflow && (agentURL === "all" || agentURL === "NA" )) {
571
+ return this._dataByWorkflowAgent[workflow];
572
+ } else if (workflow && agentURL) {
573
+ return this._dataByWorkflowAgent[workflow][agentURL];
574
+ } else if (workflow){
575
+ return this._dataByWorkflow[workflow];
576
+ } else{
577
+ return this._dataByWorkflow;
578
+ }
579
+ },
580
+
581
+ getDataWithAgent: function(workflow, agentURL) {
582
+ if (workflow && (agentURL === "all" || agentURL === "NA" )) {
583
+ return this._dataByWorkflowAgent[workflow];
584
+ } else if (workflow && agentURL) {
585
+ return this._dataByWorkflowAgent[workflow][agentURL];
586
+ } else{
587
+ return this._dataByWorkflowAgent;
588
+ }
589
+ },
590
+
591
+ getFilteredRequests: function() {
592
+ return this._filteredRequests;
593
+ },
594
+
595
+ setDataByWorkflow: function(data, agentData) {
596
+ //keyString is opject property separte by '.'
597
+ this._dataByWorkflow = data;
598
+ this._dataByWorkflowAgent = agentData;
599
+ },
600
+
601
+ getList: function(sortFunc) {
602
+ var list = [];
603
+ for (var request in this.getData()) {
604
+ list.push(this.getData(request));
605
+ }
606
+ if (sortFunc) {
607
+ return list.sort(sortFunc);
608
+ } else {
609
+ return list.sort(this._requestDateSort);
610
+ }
611
+ },
612
+
613
+ getRequestNames: function() {
614
+ var list = [];
615
+ for (var request in this.getData()) {
616
+ list.push(request);
617
+ }
618
+ return list;
619
+ },
620
+
621
+ getSummary: function(workflow, agentURL) {
622
+
623
+ var requests = this.getData(workflow, agentURL);
624
+ if (workflow) {
625
+ return requests.getSummary();
626
+ } else {
627
+ var summary = WMStats.RequestsSummary();
628
+ //TODO need to cache the information
629
+ for (var requestName in requests) {
630
+ summary.update(this.getData(requestName).getSummary());
631
+ }
632
+ return summary;
633
+ }
634
+ },
635
+
636
+ getAlertRequests: function() {
637
+ var alertRequests = [];
638
+ for (var workflow in this.getData()) {
639
+ var reqSummary = this.getSummary(workflow);
640
+ var coolOff = reqSummary.getTotalCooloff();
641
+ var paused = reqSummary.getTotalPaused();
642
+ if (coolOff > 0 || paused > 0) {
643
+ alertRequests.push(this.getData(workflow));
644
+ }
645
+ }
646
+ return alertRequests;
647
+ },
648
+
649
+ getRequestStatusAndTime: function(workflowName) {
650
+ var workflowData = this._dataByWorkflow[workflowName];
651
+ return workflowData["request_status"][workflowData["request_status"].length - 1];
652
+ },
653
+
654
+ getTasks: function(workflowName) {
655
+ return this._dataByWorkflow[workflowName].getTasks();
656
+ }
657
+
658
+ };
659
+
660
+ WMStats.RequestsByKey = function (category, summaryFunc) {
661
+
662
+ var _data = {};
663
+ var _category = category;
664
+ var _get = WMStats.Utils.get;
665
+
666
+ function categorize(requestData) {
667
+
668
+ function _getRequestData(workflow, agentURL){
669
+ if (_category === "agent" && agentURL !== "all" && agentURL !== "NA" ) {
670
+ return requestData.getData(workflow, agentURL);
671
+ } else {
672
+ return requestData.getData(workflow);
673
+ }
674
+ }
675
+
676
+ function _getCategoryKey(workflow){
677
+ if (_category === "agent") {
678
+ var agentCategory = requestData.getData(workflow, "all");
679
+ if (agentCategory === undefined) {
680
+ return "NA";
681
+ } else {
682
+ return agentCategory;
683
+ }
684
+ } else {
685
+ return requestData.getKeyValue(workflow, _category, "NA");
686
+ }
687
+ }
688
+ function _updateData(key, workflow, summaryBase) {
689
+ if (_data[key] === undefined) {
690
+ //initial set up
691
+ _data[key] = {};
692
+ _data[key].requests = {};
693
+ _data[key].summary = summaryFunc();
694
+ _data[key].key = key;
695
+ }
696
+ var requestInfo = _getRequestData(workflow, key);
697
+ _data[key].requests[workflow] = requestInfo;
698
+ _data[key].summary.updateFromRequestDoc(summaryBase);
699
+ };
700
+
701
+ var dataByWorkflow = requestData.getData();
702
+ for (var workflow in dataByWorkflow) {
703
+ var key = _getCategoryKey(workflow);
704
+ if (typeof key == 'object') {
705
+ if (key.length) {
706
+ // handles array case
707
+ for (var index in key) {
708
+ _updateData(key[index], workflow, requestData.getData(workflow));
709
+ }
710
+ } else {
711
+ // handles agent, sites and tasks case
712
+ for (var prop in key) {
713
+ _updateData(prop, workflow, key[prop]);
714
+ }
715
+ }
716
+
717
+ } else {
718
+ if (key == "NA" && _category == "sites" || _category == "tasks" || _category == "agent") {
719
+ // summary base shouldn't be higher level. since sites and tasks
720
+ // has sub hierarchy
721
+ _updateData(key, workflow, {});
722
+ } else {
723
+ _updateData(key, workflow, requestData.getData(workflow));
724
+ }
725
+ }
726
+
727
+ }
728
+ };
729
+
730
+ function getData(key){
731
+ if (key === undefined) {
732
+ return _data;
733
+ } else {
734
+ return _data[key];
735
+ }
736
+ };
737
+
738
+ function getRequestData(key){
739
+ var requestData = WMStats.Requests();
740
+ if (_data[key] !== undefined) {
741
+ requestData.setDataByWorkflow(_data[key].requests);
742
+ }
743
+ return requestData;
744
+ };
745
+
746
+ function getList(sortFunc) {
747
+ var list = [];
748
+ for (var key in _data) {
749
+ list.push(_data[key]);
750
+ }
751
+ if (sortFunc) {
752
+ return list.sort(sortFunc);
753
+ } else {
754
+ return list;
755
+ }
756
+ };
757
+
758
+ return {
759
+ categorize: categorize,
760
+ getData: getData,
761
+ getRequestData: getRequestData,
762
+ category: _category,
763
+ getList: getList
764
+ };
765
+ };
766
+ WMStats.namespace("Tasks");
767
+ WMStats.namespace("TaskStruck");
768
+ WMStats.namespace("TasksSummary");
769
+
770
+ WMStats.TasksSummary = function(task) {
771
+ var tier1Summary = {totalEvents: 0,
772
+ processedEvents: 0};
773
+ if (task) {
774
+ var taskSummaryStruct = task.subscription_status || {};
775
+ } else {
776
+ var taskSummaryStruct = {subscription_status: {finished: 0, open:0, total:0}};
777
+ };
778
+
779
+
780
+ var taskSummary = new WMStats.GenericRequestsSummary(taskSummaryStruct);
781
+
782
+ taskSummary.getAvgProgressSummary = function () {
783
+
784
+ var progressStat = {};
785
+ var datasets = {};
786
+ var numDataset = 0;
787
+
788
+ for(var site in task.sites) {
789
+ for (var outputDS in task.sites[site].dataset) {
790
+ if (datasets[outputDS] === undefined) {
791
+ numDataset += 1;
792
+ datasets[outputDS] = true;
793
+ }
794
+ WMStats.Utils.updateObj(progressStat, task.sites[site].dataset[outputDS]);
795
+ }
796
+ }
797
+
798
+ for (var prop in progressStat) {
799
+ progressStat[prop] = progressStat[prop] / numDataset;
800
+ }
801
+ progressStat.numDataset = numDataset;
802
+ return progressStat;
803
+ };
804
+
805
+ taskSummary.summaryStruct.progress = taskSummary.getAvgProgressSummary();
806
+
807
+ taskSummary.jobStatus = task.status;
808
+
809
+
810
+
811
+ return taskSummary;
812
+ };
813
+
814
+ WMStats.TaskStruct = function(taskName, task) {
815
+ this._taskName = taskName;
816
+ this._task = task;
817
+ this._summary = WMStats.TasksSummary(task);
818
+ // number of requests in the data
819
+ this._addJobs = WMStats.Utils.updateObj;
820
+ };
821
+
822
+ WMStats.TaskStruct.prototype = {
823
+
824
+ getProgressStat: function () {
825
+ var progressStat = {};
826
+ for(var site in this._task.sites) {
827
+ WMStats.Utils.updateObj(progressStat, this._task.sites[site].dataset);
828
+ }
829
+ return progressStat;
830
+ },
831
+
832
+ getName: function() {
833
+ return this._taskName;
834
+ },
835
+
836
+ getSummary: function() {
837
+ return this._summary;
838
+ }
839
+ };
840
+
841
+ WMStats.Tasks = function (tasks, requestName) {
842
+ /*
843
+ * Data structure for holding the tasks.
844
+ * tasks structure is
845
+ * {taskName: {'status': {'success: 0, running:10},
846
+ * 'site': {'T2_US_FNAL': {'success: 0, running:10
847
+ * 'jobtype': 'Processing',
848
+ * 'subscription_status': {finished: 0, open:0, total:0}
849
+ * }}}
850
+ */
851
+ // request data by workflow name
852
+ var taskStructDict = {};
853
+ for (var taskName in tasks) {
854
+ taskStructDict[taskName] = new WMStats.TaskStruct(taskName, tasks[taskName]);
855
+ }
856
+
857
+ this._data = taskStructDict;
858
+ this._workflow = requestName;
859
+ };
860
+
861
+ WMStats.Tasks.prototype = {
862
+
863
+ getWorkflow: function() {
864
+ return this._workflow;
865
+ },
866
+ getData: function () {return this._data;},
867
+
868
+ getSummary: function(taskName) {
869
+ // TODO need to add summary case for taskName undefined.
870
+ return this._data[taskName].getSummary();
871
+ }
872
+ };
873
+ WMStats.namespace("Agents");
874
+
875
+ WMStats.Agents = function (couchData) {
876
+
877
+ var agentData = new WMStats._StructBase();
878
+ agentData.agentNumber = {error: 0, stable:0};
879
+
880
+ agentData.convertCouchData = function(data) {
881
+ var dataRows = data.rows;
882
+ var rows = [];
883
+ for (var i in dataRows) {
884
+ var tableRow = dataRows[i].value;
885
+ rows.push(tableRow);
886
+ };
887
+ return rows;
888
+ };
889
+ if (couchData) agentData.setData(couchData);
890
+
891
+ agentData.getAlertList = function(){
892
+ var currentTime = Math.round(new Date().getTime() / 1000);
893
+ var dataList = this.getData();
894
+ var agentPollingCycle = 600;
895
+ agentData.agentNumber = {error: 0, warning:0, stable:0, drain: 0};
896
+
897
+ function getStatus(agentInfo) {
898
+ var lastUpdatedDuration = currentTime - agentInfo.timestamp;
899
+ var dataUpdateDuration = -1;
900
+ if (agentInfo.data_last_update) {
901
+ var dataUpdateDuration = currentTime - agentInfo.data_last_update;
902
+ }
903
+ var report = {"status": "stable", "message": ""};
904
+
905
+ // drain case
906
+ if (agentInfo.drain_mode) {
907
+ report.status = "drain";
908
+ report.message += "Draining Agent; ";
909
+ }
910
+
911
+ if (agentInfo.proxy_warning && agentInfo.status === "warning") {
912
+ report.status = agentInfo.status;
913
+ report.message += "Proxy expiration warning; ";
914
+ } else if (agentInfo.proxy_warning && agentInfo.status === "error") {
915
+ agentData.agentNumber.error += 1;
916
+ report.status = agentInfo.status;
917
+ report.message += "Proxy expiration error; ";
918
+ }
919
+
920
+ // warning case
921
+ if (agentInfo.couch_process_warning) {
922
+ agentData.agentNumber.error += 1;
923
+ report.status = "error";
924
+ report.message += "couchdb process maxed out: " + agentInfo.couch_process_warning;
925
+ }
926
+
927
+ if (agentInfo.disk_warning && (agentInfo.disk_warning.length > 0)) {
928
+ agentData.agentNumber.warning += 1;
929
+ report.status = "warning";
930
+ report.message += "disk is almost full; ";
931
+ }
932
+
933
+ if (lastUpdatedDuration > agentPollingCycle * 2) {
934
+ agentData.agentNumber.error += 1;
935
+ report.status = "error";
936
+ report.message += "Agent Data is not updated: AgentStatusWatcher is Down; ";
937
+ }
938
+
939
+ if (agentInfo.down_components.length > 0) {
940
+ agentData.agentNumber.error += 1;
941
+ report.status = "error";
942
+ report.message += "Components or Thread down; ";
943
+ }
944
+
945
+ if (agentInfo.data_error && (agentInfo.data_error !== "ok")) {
946
+ agentData.agentNumber.error += 1;
947
+ report.status = "error";
948
+ report.message += "Data collect error; ";
949
+ }
950
+ // If there is no drain/warning or errors set the message OK
951
+ if (report.status === "stable") {
952
+ agentData.agentNumber.stable += 1;
953
+ report.message = "OK";
954
+ };
955
+
956
+ report["agent_update"] = WMStats.Utils.formatDuration(lastUpdatedDuration);
957
+ report["data_update"] = WMStats.Utils.formatDuration(dataUpdateDuration);
958
+ return report;
959
+ };
960
+
961
+ for (var index in dataList) {
962
+ dataList[index]['alert'] = getStatus(dataList[index]);
963
+ };
964
+ return dataList;
965
+ };
966
+ // initial calculation
967
+ agentData.getAlertList();
968
+
969
+ return agentData;
970
+ };
971
+ WMStats.namespace("Sites");
972
+
973
+ WMStats.Sites = function (couchData) {
974
+ var _data;
975
+ var baseColumns = ["timestamp", "site", "agent_url"];
976
+
977
+ var siteData = new WMStats._StructBase();
978
+
979
+ siteData.convertCouchData = function(data) {
980
+ var dataRows = data.rows;
981
+ var rows =[];
982
+ for (var i in dataRows) {
983
+ var tableRow = dataRows[i].value;
984
+ for (var j = 0; j < baseColumns.length; j ++) {
985
+ tableRow[baseColumns[j]] = dataRows[i].key[j];
986
+ }
987
+ rows.push(tableRow);
988
+ }
989
+ return rows;
990
+ };
991
+
992
+ if (couchData) siteData.setData(couchData);
993
+
994
+ return siteData;
995
+ };
996
+ WMStats.namespace("JobSummary");
997
+
998
+ WMStats.JobSummary = function (couchData) {
999
+
1000
+ var jobSummaryData = new WMStats._StructBase();
1001
+
1002
+ jobSummaryData.convertCouchData = function(data) {
1003
+ var jobSummary = {};
1004
+ jobSummary.status = [];
1005
+ for (var i in data.rows){
1006
+ jobSummary.workflow = data.rows[i].key[0];
1007
+ var statusSummary = {};
1008
+ statusSummary.task = data.rows[i].key[1];
1009
+ statusSummary.status = data.rows[i].key[2];
1010
+ statusSummary.exitCode = data.rows[i].key[3];
1011
+ statusSummary.site = data.rows[i].key[4];
1012
+ if (typeof(statusSummary.site) === "object") {
1013
+ statusSummary.site = "{}";
1014
+ }
1015
+ statusSummary.acdcURL = data.rows[i].key[5];
1016
+ statusSummary.agentName = data.rows[i].key[6];
1017
+ statusSummary.errorMsg = data.rows[i].key[7];
1018
+ statusSummary.count = data.rows[i].value;
1019
+ jobSummary.status.push(statusSummary);
1020
+ }
1021
+ return jobSummary;
1022
+ };
1023
+
1024
+ if (couchData) jobSummaryData.setData(couchData);
1025
+
1026
+ return jobSummaryData;
1027
+ };
1028
+ WMStats.namespace("Campaigns");
1029
+
1030
+ WMStats.Campaigns = function (couchData) {
1031
+
1032
+ var campaignData = new WMStats._StructBase();
1033
+ var _baseColumns = ["campaign"];
1034
+
1035
+ campaignData.convertCouchData = function(data) {
1036
+ dataRows = data.rows;
1037
+ //TODO sync with group level
1038
+ //This is base on the group_level ["campaign", "team", type]
1039
+ var rows =[];
1040
+ for (var i in dataRows) {
1041
+ var tableRow = dataRows[i].value;
1042
+ for (var j = 0; j < _baseColumns.length; j ++) {
1043
+ tableRow[_baseColumns[j]] = dataRows[i].key[j];
1044
+ }
1045
+ rows.push(tableRow);
1046
+ }
1047
+ return rows;
1048
+ };
1049
+ if (couchData) campaignData.setData(couchData);
1050
+
1051
+ return campaignData;
1052
+ };
1053
+ WMStats.namespace("Alerts");
1054
+
1055
+ WMStats.Alerts = function (couchData) {
1056
+
1057
+ var alertData = new WMStats._StructBase();
1058
+
1059
+ alertData.convertCouchData = function(data) {
1060
+ var dataRows = data.rows;
1061
+ var rows =[];
1062
+ for (var i in dataRows) {
1063
+ var tableRow = {};
1064
+ tableRow.workflow = dataRows[i].key;
1065
+ tableRow.count = dataRows[i].value;
1066
+ rows.push(tableRow);
1067
+ }
1068
+ return rows;
1069
+ };
1070
+ if (couchData) alertData.setData(couchData);
1071
+
1072
+ return alertData;
1073
+ };
1074
+ WMStats.namespace("SiteSummary");
1075
+
1076
+ WMStats.SiteSummary = function() {
1077
+ var siteSummary = {totalEvents: 0,
1078
+ processedEvents: 0,
1079
+ numRequests: 0};
1080
+ var siteSummary = new WMStats.GenericRequestsSummary(siteSummary);
1081
+
1082
+ siteSummary.createSummaryFromRequestDoc = function(doc) {
1083
+ var summary = WMStats.SiteSummary();
1084
+ summary.summaryStruct.totalEvents = Number(this._get(doc, "input_events", 0));
1085
+ summary.summaryStruct.processedEvents = this._get(doc, "output_progress.0.events", 0);
1086
+ summary.summaryStruct.numRequests = 1;
1087
+ summary.jobStatus = doc;
1088
+ //support legacy code which had cooloff jobs instead cooloff.create, cooloff.submit
1089
+ //cooloff.job
1090
+ if ((typeof summary.jobStatus.cooloff) === "number") {
1091
+ summary.jobStatus.cooloff = {create: 0, submit: 0, job: summary.jobStatus.cooloff};
1092
+ }
1093
+ return summary;
1094
+ };
1095
+
1096
+ return siteSummary;
1097
+ };
1098
+ WMStats.namespace("JobDetails");
1099
+
1100
+ WMStats.JobDetails = function (couchData) {
1101
+
1102
+ var jobDetailData = new WMStats._StructBase();
1103
+
1104
+ jobDetailData.convertCouchData = function(data) {
1105
+ var dataRows = data.rows;
1106
+ var jobDetails = [];
1107
+ for (var i in dataRows){
1108
+ jobDetails.push(dataRows[i].doc);
1109
+ }
1110
+ return jobDetails;
1111
+ };
1112
+
1113
+ if (couchData) jobDetailData.setData(couchData);
1114
+
1115
+ return jobDetailData;
1116
+ };
1117
+ WMStats.namespace("WorkloadSummary");
1118
+
1119
+ WMStats.WorkloadSummary = function (couchData) {
1120
+
1121
+ var workloadSummaryData = new WMStats._StructBase();
1122
+
1123
+ workloadSummaryData.convertCouchData = function(data) {
1124
+ var dataRows = data.rows;
1125
+ var workloadSummary = [];
1126
+ for (var i in dataRows){
1127
+ var wmstatsDoc = WMStats.Globals.convertRequestDocToWMStatsFormat(dataRows[i].doc);
1128
+ workloadSummary.push(wmstatsDoc);
1129
+ }
1130
+ return workloadSummary;
1131
+ };
1132
+
1133
+ if (couchData) workloadSummaryData.setData(couchData);
1134
+
1135
+ return workloadSummaryData;
1136
+ };
1137
+ WMStats.namespace("History");
1138
+ WMStats.namespace("TimeBucket");
1139
+
1140
+ WMStats.TimeBucket = function() {
1141
+
1142
+ var _bucket = new Array();
1143
+ var _bucketSize = 24;
1144
+ var _interval = 3600; // 1 hour
1145
+
1146
+ function addRow(currentTime, row) {
1147
+ var timestamp = row.key[0];
1148
+ var couchDoc = row.doc;
1149
+ var index = parseInt((currentTime - timestamp) / 3600);
1150
+ var updateFlag = false;
1151
+ if (_bucket[index] && _bucket[index][couchDoc.agent_url]) {
1152
+ if (_bucket[index][couchDoc.agent_url].timestamp < couchDoc.timestamp) {
1153
+ updteFlag = true;
1154
+ }
1155
+ } else if (_bucket[index]) {
1156
+ updateFlag = true;
1157
+ } else {
1158
+ _bucket[index] = {};
1159
+ _bucket[index][couchDoc.agent_url] = {};
1160
+ _bucket[index][couchDoc.agent_url].requests = {};
1161
+ updateFlag = true;
1162
+ }
1163
+
1164
+ if (updateFlag) {
1165
+ _bucket[index][couchDoc.agent_url].timestamp = couchDoc.timestamp;
1166
+ _bucket[index][couchDoc.agent_url].requests[couchDoc.workflow] = couchDoc;
1167
+ }
1168
+ }
1169
+
1170
+ function addHistory(couchData) {
1171
+ var dataRows = couchData.rows;
1172
+ var currentTime = Math.round((new Date()).getTime() / 1000);
1173
+ for (var i in dataRows) {
1174
+ addRow(currentTime, dataRows[i]);
1175
+ }
1176
+ }
1177
+
1178
+ function getData() {
1179
+ return _bucket;
1180
+ }
1181
+ /*
1182
+ function getSiteFailureRate() {
1183
+ var requestData = []
1184
+ for (var i in _bucket) {
1185
+ requestData[i] = {}
1186
+ for (var request in _bucket[i]) {
1187
+ requestData[i][request]
1188
+ }
1189
+ requestData[i] = _bucket.requests
1190
+ }
1191
+ }
1192
+ */
1193
+ return {
1194
+ addHistory: addHistory,
1195
+ getData: getData
1196
+ };
1197
+ };
1198
+
1199
+ WMStats.History = function (couchData) {
1200
+ var _data;
1201
+
1202
+ var historyData = new WMStats._StructBase();
1203
+
1204
+ historyData.convertCouchData = function(data) {
1205
+ var bucket = WMStats.TimeBucket();
1206
+ bucket.addHistory(data);
1207
+ return bucket.getData();
1208
+ };
1209
+
1210
+
1211
+ if (couchData) historyData.setData(couchData);
1212
+
1213
+ return historyData;
1214
+ };
1215
+ WMStats.namespace("LogDBData");
1216
+
1217
+ WMStats.LogDBData = function (couchData) {
1218
+
1219
+ var logDBData = new WMStats._StructBase();
1220
+ logDBData._sortedLogs = {};
1221
+ logDBData._errorLogIDList =[];
1222
+ logDBData._errorLogs = [];
1223
+
1224
+ logDBData._timestampSort = function(a, b) {
1225
+ // sort the record by descending order
1226
+ return (a.ts - b.ts);
1227
+ };
1228
+
1229
+ logDBData._getValue = function(obj, key, defaultType) {
1230
+ if (obj.key === undefined) {
1231
+ if (defaultType !== undefined) {
1232
+ obj[key] = defaultType;
1233
+ } else {
1234
+ obj[key] = {};
1235
+ }
1236
+ }
1237
+ return obj[key];
1238
+ };
1239
+
1240
+ logDBData._getThreadValue = function(obj, request, agent, thread) {
1241
+ requestObj = this._getValue(this._sortedLogs, request);
1242
+ agentObj = this._getValue(requestObj, agent);
1243
+ threadObj = this._getValue(agentObj, thread, []);
1244
+ return threadObj;
1245
+ };
1246
+
1247
+ logDBData.convertCouchData = function (couchData) {
1248
+ var results = [];
1249
+ if (couchData.rows) {
1250
+ for (var i in couchData.rows) {
1251
+ row = couchData.rows[i]['value'];
1252
+ row.request = couchData.rows[i]['key'];
1253
+ row.id = couchData.rows[i].id;
1254
+ results.push(row);
1255
+ }
1256
+ }
1257
+ // and sortby ts stamp decending order
1258
+ results.sort(this._timestampSort);
1259
+ return results;
1260
+ },
1261
+
1262
+ logDBData._setLogWithLastestError = function () {
1263
+
1264
+ for (var i in this._data) {
1265
+ thrResult = this._getThreadValue(this._sortedLogs, this._data[i].request,
1266
+ this._data[i].agent, this._data[i].thr);
1267
+ if (this._data[i].type !== "message") {
1268
+ thrResult.push(this._data[i]);
1269
+ };
1270
+ };
1271
+
1272
+ var logs = this._sortedLogs;
1273
+ for (var req in this._sortedLogs) {
1274
+ for (var agent in logs[req]) {
1275
+ for (var thread in logs[req][agent]) {
1276
+ for (var i in logs[req][agent][thread]) {
1277
+ if (logs[req][agent][thread][i].type === "agent-error" ||
1278
+ logs[req][agent][thread][i].type === "agent-warning") {
1279
+ this._errorLogs.push(logs[req][agent][thread][i]);
1280
+ this._errorLogIDList.push(logs[req][agent][thread][i].id);
1281
+ }
1282
+ }
1283
+ }
1284
+ }
1285
+ }
1286
+
1287
+ return this._errorLogs;
1288
+ };
1289
+
1290
+ logDBData.getErrorLogIDs = function () {
1291
+ return this._errorLogIDList;
1292
+ };
1293
+
1294
+ logDBData.setMessages = function (request, agent, thread, messages) {
1295
+ this._sortedLogs[request][agent][thread][0].messages = messages;
1296
+ };
1297
+
1298
+ logDBData.getLogWithLastestError = function() {
1299
+ return this._errorLogs;
1300
+ };
1301
+
1302
+ if (couchData) logDBData.setData(couchData);
1303
+
1304
+ logDBData._setLogWithLastestError();
1305
+
1306
+ return logDBData;
1307
+ };
1308
+ WMStats.namespace("LogMessage");
1309
+
1310
+ WMStats.LogMessage = function (couchData) {
1311
+
1312
+ var logdbDetailData = new WMStats._StructBase();
1313
+
1314
+ //set default value to []
1315
+ logdbDetailData._data =[];
1316
+
1317
+ logdbDetailData.convertCouchData = function(data) {
1318
+ var dataRows = data.rows;
1319
+ var rows =[];
1320
+ for (var i in dataRows) {
1321
+ var tableRow = {};
1322
+ doc = dataRows[i].doc;
1323
+ tableRow.request = doc.request;
1324
+ tableRow.agent = doc.identifier;
1325
+ tableRow.thr = doc.thr;
1326
+ tableRow.messages = doc.messages;
1327
+ rows.push(tableRow);
1328
+ }
1329
+ return rows;
1330
+ };
1331
+
1332
+ logdbDetailData.setMessagesToLogDBData = function() {
1333
+ var logDBData = WMStats.RequestLogModel.getData();
1334
+ var d = this._data;
1335
+ for (var i in d) {
1336
+ logDBData.setMessages(d[i].request, d[i].agent, d[i].thr, d[i].messages);
1337
+ }
1338
+ };
1339
+
1340
+ if (couchData) logdbDetailData.setData(couchData);
1341
+
1342
+ logdbDetailData.setMessagesToLogDBData();
1343
+
1344
+ return logdbDetailData;
1345
+ };WMStats.namespace("Requests");
1346
+ WMStats.namespace("RequestsSummary");
1347
+
1348
+ WMStats.RequestsSummary = function() {
1349
+ //TODO add specific tier0 summary structure
1350
+ var tier0Summary = {};
1351
+ var requestSummary = new WMStats.GenericRequestsSummary(tier0Summary);
1352
+ return requestSummary;
1353
+ };
1354
+
1355
+ WMStats.Requests = function(data) {
1356
+ var tier0Requests = new WMStats.GenericRequests(data);
1357
+
1358
+ tier0Requests.getRequestAlerts = function() {
1359
+
1360
+ var alertRequests = {};
1361
+ alertRequests['configError'] = [];
1362
+ alertRequests['siteError'] = [];
1363
+ alertRequests['cPaused'] = [];
1364
+ alertRequests['sPaused'] = [];
1365
+ alertRequests['jPaused'] = [];
1366
+ var ignoreStatus = ["closed-out",
1367
+ "announced",
1368
+ "aborted",
1369
+ "rejected"];
1370
+ for (var workflow in this.getData()) {
1371
+ var requestInfo = this.getData(workflow);
1372
+
1373
+ var reqSummary = this.getSummary(workflow);
1374
+ var cooloff = reqSummary.getTotalCooloff();
1375
+ var paused = reqSummary.getTotalPaused();
1376
+ var failure = reqSummary.getTotalFailure();
1377
+ var success = reqSummary.getJobStatus("success");
1378
+ var sPaused = reqSummary.getJobStatus("paused.submit");
1379
+ var jPaused = reqSummary.getJobStatus("paused.job");
1380
+ var cPaused = reqSummary.getJobStatus("paused.create");
1381
+ var totalFailed = failure;
1382
+ if (cPaused > 0){
1383
+ alertRequests['cPaused'].push(this.getData(workflow));
1384
+ } else if (sPaused > 0){
1385
+ alertRequests['sPaused'].push(this.getData(workflow));
1386
+ } else if (jPaused > 0){
1387
+ alertRequests['jPaused'].push(this.getData(workflow));
1388
+ }
1389
+ /*
1390
+ else if ( totalFailed > 0) {
1391
+ if (success === 0) {
1392
+ alertRequests['configError'].push(this.getData(workflow));
1393
+ } else if ((totalFailed / (totalFailed + success)) > 0.85) {
1394
+ alertRequests['siteError'].push(this.getData(workflow));
1395
+ }
1396
+ }*/
1397
+ }
1398
+ return alertRequests;
1399
+ };
1400
+
1401
+ tier0Requests.numOfRequestError = function() {
1402
+ /***
1403
+ * TODO: need to implement this
1404
+ ***/
1405
+ var alertData = this.getRequestAlerts();
1406
+ var numError = {};
1407
+ numError.alert = 0;
1408
+ for (var error in alertData) {
1409
+ numError.alert += alertData[error].length;
1410
+ };
1411
+
1412
+ return numError;
1413
+ };
1414
+ return tier0Requests;
1415
+ };
1416
+ WMStats.namespace("RunSummary");
1417
+ WMStats.namespace("RunStatus");
1418
+
1419
+ /*
1420
+ * run status is ordered as lower index determines combined status.
1421
+ * i.e. If one request is "Active" and the other is "Real Time Processing"
1422
+ * run status will be Active
1423
+ * There is no way to determine given run has PromptReco "Real Timp Done" is moved
1424
+ * to right before Complete status. If run contains only Express and Repack workflows,
1425
+ * it will never move to Complete run status. However workflow status will be moved to
1426
+ * completed by task archiver and eventually archived.
1427
+ */
1428
+ WMStats.RunStatus = ["Active", "Real Time Processing", "Real Time Merge",
1429
+ "Real Time Harvesting", "PromptReco", "Reco Merge",
1430
+ "Reco Harvest", "Processing Done", "Real Time Done","Complete"];
1431
+
1432
+ WMStats.RunSummary = function() {
1433
+ var runSummary = {numRequests: 0};
1434
+ var runSummary = new WMStats.GenericRequestsSummary(runSummary);
1435
+
1436
+ function getRunStatus(doc) {
1437
+ var wfStatus = doc["request_status"][doc["request_status"].length - 1].status;
1438
+ var wfPrefix = doc['workflow'].split("_")[0].toLowerCase();
1439
+ if (wfPrefix == "express" || wfPrefix == "repack") {
1440
+ if (wfStatus == "new") {
1441
+ return WMStats.RunStatus[0];
1442
+ } else if (wfStatus == "Closed") {
1443
+ return WMStats.RunStatus[1];
1444
+ } else if (wfStatus == "Merge") {
1445
+ return WMStats.RunStatus[2];
1446
+ } else if (wfStatus == "Harvesting") {
1447
+ return WMStats.RunStatus[3];
1448
+ } else if (wfStatus == "Processing Done") {
1449
+ return WMStats.RunStatus[8];
1450
+ }
1451
+ } else if (wfPrefix == "promptreco") {
1452
+ if (wfStatus == "new" || wfStatus == "Closed" || wfStatus == "AlcaSkim" ) {
1453
+ return WMStats.RunStatus[4];
1454
+ } else if (wfStatus == "Merge") {
1455
+ return WMStats.RunStatus[5];
1456
+ } else if (wfStatus == "Harvesting") {
1457
+ return WMStats.RunStatus[6];
1458
+ } else if (wfStatus == "Processing Done") {
1459
+ return WMStats.RunStatus[7];
1460
+ }
1461
+ }
1462
+ return WMStats.RunStatus[9];
1463
+ }
1464
+
1465
+ runSummary.summaryStructUpdateFuction = function(baseObj, additionObj, field) {
1466
+ if (field === "runStatus") {
1467
+ if (WMStats.RunStatus.indexOf(baseObj[field]) > WMStats.RunStatus.indexOf(additionObj[field])) {
1468
+ baseObj[field] = additionObj[field];
1469
+ }
1470
+ } else {
1471
+ baseObj[field] += additionObj[field];
1472
+ }
1473
+ };
1474
+
1475
+ runSummary.createSummaryFromRequestDoc = function(doc) {
1476
+ var summary = WMStats.RunSummary();
1477
+ summary.summaryStruct.numRequests = 1;
1478
+ summary.summaryStruct.runStatus = getRunStatus(doc);
1479
+ summary.jobStatus = this._get(doc, 'status', {});
1480
+
1481
+ return summary;
1482
+ };
1483
+
1484
+ return runSummary;
1485
+ };
1486
+ /** abstract environment of the web page */
1487
+ WMStats.namespace("_ViewModelBase");
1488
+
1489
+ WMStats._ViewModelBase = function (observableObj) {
1490
+ this._eventObj = {};
1491
+ this._eventObjName = "_eventObj";
1492
+ // special observable property holding represented data
1493
+ this.data = this.observable('data', null);
1494
+ if (observableObj !== undefined) {
1495
+ this._createObservableProperty(observableObj);
1496
+ };
1497
+ this._selector = null;
1498
+ this._data = null;
1499
+ };
1500
+
1501
+ WMStats._ViewModelBase.prototype = {
1502
+
1503
+ observable: function(property, defaultValue) {
1504
+
1505
+ var _previousValue = defaultValue;
1506
+ var _property = property;
1507
+
1508
+ function publish(value, noTrigger) {
1509
+ if (value !== undefined) {
1510
+ _previousValue = value;
1511
+ //TODO: check the equality
1512
+ /* trigger parent object changed */
1513
+ if (!noTrigger) {
1514
+ $(this._eventObj).triggerHandler(this._eventObjName, this);
1515
+ /* trigger property changed */
1516
+ $(this._eventObj).triggerHandler(_property, value);
1517
+
1518
+ }
1519
+ return this;
1520
+ } else {
1521
+ return _previousValue;
1522
+ }
1523
+ }
1524
+ return publish;
1525
+ },
1526
+
1527
+ subscribe: function() {
1528
+ /*
1529
+ * takes 1 or 2 arguments
1530
+ * if 1, it is callback function when this object changes
1531
+ * if 2. 1st is property name and 2nd is callback function
1532
+ *
1533
+ */
1534
+ var callback;
1535
+ var eventName;
1536
+ if (arguments.length == 2) {
1537
+ callback = arguments[1];
1538
+ eventName = arguments[0];
1539
+ } else if (arguments.length == 1) {
1540
+ callback = arguments[0];
1541
+ eventName = this._eventObjName;
1542
+ }
1543
+
1544
+ $(this._eventObj).on(eventName, callback);
1545
+ },
1546
+
1547
+ id: function(selector) {
1548
+ // link the selector with the ViewModel
1549
+ // may need to connect multiple selector
1550
+ if (selector) {
1551
+ this._selector = selector;
1552
+ WMStats.ViewModel.Registry[selector] = this;
1553
+ return this;
1554
+ } else {
1555
+ return this._selector;
1556
+ }
1557
+ },
1558
+
1559
+ _createObservableProperty: function(observableObj) {
1560
+ for (var prop in observableObj) {
1561
+ this[prop] = this.observable(prop, observableObj[prop]);
1562
+ }
1563
+ }
1564
+ };
1565
+
1566
+ WMStats.namespace("ViewModel");
1567
+
1568
+ WMStats.ViewModel = (function (){
1569
+ var properties = {page: null};
1570
+ var vm = new WMStats._ViewModelBase(properties);
1571
+ vm.propagateUpdate = function() {
1572
+ if (vm.page().propagateUpdate) {
1573
+ vm.page().propagateUpdate();
1574
+ }
1575
+ };
1576
+ return vm;
1577
+ })();
1578
+
1579
+ // create WMStats.ViewModel properties
1580
+ (function(vm) {
1581
+
1582
+ vm.Registry ={};
1583
+
1584
+ vm.ActiveRequestPage = (function (){
1585
+ var properties = {view: null,
1586
+ filter: {},
1587
+ filteredStats: null,
1588
+ refreshCount: 0};
1589
+ var requestPage = new WMStats._ViewModelBase(properties);
1590
+
1591
+ requestPage.propagateUpdate = function() {
1592
+ var requestData = WMStats.ActiveRequestModel.getData();
1593
+ if (requestData === null) {
1594
+ return false;
1595
+ } else {
1596
+ var filter = vm.ActiveRequestPage.filter();
1597
+ vm.ActiveRequestPage.data(requestData.filterRequests(filter));
1598
+ if (requestPage.view().propagateUpdate) {
1599
+ requestPage.view().propagateUpdate();
1600
+ }
1601
+ return true;
1602
+ }
1603
+ };
1604
+
1605
+ return requestPage;
1606
+ })();
1607
+
1608
+ vm.RequestAlertPage = (function (){
1609
+ var alertPage = new WMStats._ViewModelBase();
1610
+
1611
+ alertPage.propagateUpdate = function() {
1612
+ var requestData = WMStats.ActiveRequestModel.getData();
1613
+ if (requestData === null) {
1614
+ return false;
1615
+ } else {
1616
+ vm.RequestAlertPage.data(requestData);
1617
+ return true;
1618
+ }
1619
+ };
1620
+
1621
+ return alertPage;
1622
+ })();
1623
+
1624
+ vm.AgentPage = (function (){
1625
+ var agentPage =new WMStats._ViewModelBase();
1626
+
1627
+ agentPage.propagateUpdate = function() {
1628
+ var agentData = WMStats.AgentModel.getData();
1629
+ if (agentData === null) {
1630
+ return false;
1631
+ } else {
1632
+ vm.AgentPage.data(agentData);
1633
+ return true;
1634
+ }
1635
+ };
1636
+ return agentPage;
1637
+ })();
1638
+
1639
+ vm.LogDBPage = (function (){
1640
+ var logDBPage =new WMStats._ViewModelBase();
1641
+
1642
+ logDBPage.propagateUpdate = function() {
1643
+
1644
+ var logDBData = WMStats.RequestLogModel.getData();
1645
+ if (logDBData === null) {
1646
+ return false;
1647
+ } else {
1648
+ vm.LogDBPage.data(logDBData);
1649
+ return true;
1650
+ }
1651
+ };
1652
+ return logDBPage;
1653
+ })();
1654
+
1655
+ vm.SearchPage = (function (){
1656
+ /*
1657
+ * keys contain {searchCategory: blah, searchValue: blah}
1658
+ */
1659
+ var properties = {keys: null};
1660
+ searchPage = new WMStats._ViewModelBase(properties);
1661
+
1662
+ searchPage.retrieveData = function(keys) {
1663
+ var selectedSearch = keys.searchCategory;
1664
+ var searchStr = keys.searchValue;
1665
+ var view;
1666
+ var options = {'include_docs': true, 'reduce': false};
1667
+ if (selectedSearch === 'request') {
1668
+ view = "allDocs";
1669
+ options.key = searchStr;
1670
+ } else if (selectedSearch === 'outputdataset') {
1671
+ view = "byoutputdataset";
1672
+ options.key = searchStr;
1673
+ } else if (selectedSearch === 'inputdataset') {
1674
+ view = "byinputdataset";
1675
+ options.key = searchStr;
1676
+ } else if (selectedSearch === 'prep_id') {
1677
+ view = "byprepid";
1678
+ options.key = searchStr;
1679
+ } else if (selectedSearch === 'data_pileup') {
1680
+ view = "bydatapileup";
1681
+ options.key = searchStr;
1682
+ } else if (selectedSearch === 'mc_pileup') {
1683
+ view = "bymcpileup";
1684
+ options.key = searchStr;
1685
+ } else if (selectedSearch === 'request_date') {
1686
+ view = "bydate";
1687
+ var beginDate = $('input[name="dateRange1"]').val().split("/");
1688
+ var endDate = $('input[name="dateRange2"]').val().split("/");
1689
+ options.startkey = [Number(beginDate[0]), Number(beginDate[1]), Number(beginDate[2])];
1690
+ options.endkey = [Number(endDate[0]), Number(endDate[1]), Number(endDate[2]), {}];
1691
+ };
1692
+
1693
+ WMStats.RequestSearchModel.retrieveData(view, options);
1694
+ };
1695
+ return searchPage;
1696
+ })();
1697
+
1698
+ vm.CategoryView = (function (){
1699
+
1700
+ var properties = {category: null,
1701
+ detailView: null};
1702
+
1703
+ var categoryView = new WMStats._ViewModelBase(properties);
1704
+
1705
+ categoryView.convertToCategoryData = function (requestData) {
1706
+ if (requestData === undefined) {
1707
+ requestData = vm.ActiveRequestPage.data();
1708
+ }
1709
+ var category = this.category().name();
1710
+ var summaryStruct = WMStats.CategorySummaryMap.get(this.category().name());
1711
+ var categoryData = WMStats.RequestsByKey(category, summaryStruct);
1712
+ categoryData.categorize(requestData);
1713
+ return categoryData;
1714
+ };
1715
+
1716
+ categoryView.propagateUpdate = function() {
1717
+ if (vm.ActiveRequestPage.data() === null) {
1718
+ return false;
1719
+ };
1720
+ categoryView.data(categoryView.convertToCategoryData());
1721
+ return true;
1722
+ };
1723
+
1724
+ return categoryView;
1725
+ })();
1726
+
1727
+ vm.RequestView = (function (){
1728
+ /*
1729
+ * format is progress or numJobs - this is tied to name of the button
1730
+ * un tie.
1731
+ */
1732
+
1733
+ var properties = {categoryKey: "all",
1734
+ format: null,
1735
+ detailView: null};
1736
+
1737
+ var requestView = new WMStats._ViewModelBase(properties);
1738
+
1739
+ requestView.propagateUpdate = function() {
1740
+ if (vm.ActiveRequestPage.data() === null) {
1741
+ return false;
1742
+ };
1743
+ if (requestView.categoryKey() == "all") {
1744
+ requestView.data(vm.ActiveRequestPage.data());
1745
+ } else {
1746
+ var categoryData = vm.CategoryView.convertToCategoryData();
1747
+ var data = categoryData.getRequestData(requestView.categoryKey());
1748
+ requestView.data(data);
1749
+ };
1750
+ return true;
1751
+ };
1752
+ //TODO: hack for assigning for category map
1753
+ requestView.categoryName = "requests";
1754
+ return requestView;
1755
+ })();
1756
+
1757
+ vm.TaskView = (function (){
1758
+ /*
1759
+ * TODO: not done need to replace in TaskSummary Table.
1760
+ */
1761
+
1762
+ var properties = {requestName: null};
1763
+
1764
+ var taskView = new WMStats._ViewModelBase(properties);
1765
+
1766
+ taskView.propagateUpdate = function() {
1767
+ if (taskView.requestName()) {
1768
+ taskView.data(WMStats.ActiveRequestModel.getData().getTasks(taskView.requestName()));
1769
+ return false;
1770
+ } else {
1771
+ return false;
1772
+ }
1773
+ };
1774
+ return taskView;
1775
+ })();
1776
+
1777
+ function createJobSummaryView(){
1778
+ var properties = {requestName: null, detail: null};
1779
+ var jobView = new WMStats._ViewModelBase(properties);
1780
+
1781
+ jobView.retrieveData = function(requestName) {
1782
+ WMStats.JobSummaryModel.setRequest(requestName);
1783
+ WMStats.JobSummaryModel.retrieveData();
1784
+ };
1785
+
1786
+ jobView.propagateUpdate = function() {
1787
+
1788
+ /* this part is needed if you want to refresh the job view when data is updated */
1789
+ if (jobView.requestName()) {
1790
+ jobView.retrieveData(jobView.requestName());
1791
+ return false;
1792
+ } else {
1793
+ return false;
1794
+ }
1795
+ };
1796
+
1797
+ jobView.updateDataAndChild = function(data) {
1798
+ if (data) {jobView.data(data);}
1799
+ if (jobView.detail().propagateUpdate) {
1800
+ jobView.detail().propagateUpdate();
1801
+ return true;
1802
+ }
1803
+ return false;
1804
+ };
1805
+
1806
+ return jobView;
1807
+ };
1808
+
1809
+ vm.JobView = createJobSummaryView();
1810
+ vm.AlertJobView = createJobSummaryView();
1811
+
1812
+ vm.CampaignCategory = (function (){
1813
+ return new WMStats._ViewModelBase({name: "campaign"});
1814
+ })();
1815
+
1816
+ vm.SiteCategory = (function (){
1817
+ return new WMStats._ViewModelBase({name: "sites"});
1818
+ })();
1819
+
1820
+
1821
+ vm.CMSSWCategory = (function (){
1822
+ return new WMStats._ViewModelBase({name: "cmssw"});
1823
+ })();
1824
+
1825
+ vm.AgentCategory = (function (){
1826
+ return new WMStats._ViewModelBase({name: "agent"});
1827
+ })();
1828
+
1829
+ vm.RunCategory = (function (){
1830
+ return new WMStats._ViewModelBase({name: "run"});
1831
+ })();
1832
+
1833
+ /* request view summary format */
1834
+ vm.RequestProgress = (function (){
1835
+ return new WMStats._ViewModelBase({name: "progress"});
1836
+ })();
1837
+
1838
+ vm.RequestJobs = (function (){
1839
+ return new WMStats._ViewModelBase({name: "numJobs"});
1840
+ })();
1841
+
1842
+ /* request view job detail */
1843
+ vm.CategoryDetail = (function (){
1844
+ var properties = {categoryKey: null};
1845
+ var categoryDetail = new WMStats._ViewModelBase(properties);
1846
+
1847
+ categoryDetail.propagateUpdate = function() {
1848
+ if (categoryDetail.categoryKey()) {
1849
+ var allData = vm.CategoryView.data();
1850
+ categoryDetail.data(allData.getData(categoryDetail.categoryKey()));
1851
+ }
1852
+ };
1853
+ return categoryDetail;
1854
+ })();
1855
+
1856
+
1857
+ vm.RequestDetail = (function (){
1858
+ var properties = {requestName: null};
1859
+ var requestDetail = new WMStats._ViewModelBase(properties);
1860
+ requestDetail.open = false;
1861
+ return requestDetail;
1862
+ })();
1863
+
1864
+ function createJobDetailView(){
1865
+ var properties = {keys: null, indexID: null};
1866
+ var jobDetail = new WMStats._ViewModelBase(properties);
1867
+
1868
+ jobDetail.retrieveData = function(keys) {
1869
+ WMStats.JobDetailModel.setOptions(keys);
1870
+ WMStats.JobDetailModel.retrieveData();
1871
+ };
1872
+
1873
+ jobDetail.propagateUpdate = function() {
1874
+ /* this part is needed if you want to refresh the job view when data is updated */
1875
+ if (jobDetail.keys() !== null) {
1876
+ jobDetail.retrieveData(jobDetail.keys());
1877
+ return true;
1878
+ } else {
1879
+ return false;
1880
+ }
1881
+ };
1882
+
1883
+ return jobDetail;
1884
+ };
1885
+
1886
+ vm.JobDetail = createJobDetailView();
1887
+ vm.AlertJobDetail = createJobDetailView();
1888
+
1889
+ vm.Resubmission = (function (){
1890
+ /* resubmission keys contains
1891
+ * requestName and taskName and acdc url
1892
+ * {requestName: blah, task: blah, acdcURL: blah}
1893
+ * */
1894
+
1895
+ var properties = {keys: null};
1896
+ var resubmission = new WMStats._ViewModelBase(properties);
1897
+
1898
+ resubmission.retrieveData = function(keys) {
1899
+ WMStats.ReqMgrRequestModel.retrieveDoc(keys.requestName);
1900
+ };
1901
+
1902
+ resubmission.formatResubmissionData = function(reqMgrRequest) {
1903
+ var summary = {};
1904
+ // from resubmission keys
1905
+ summary.RequestType = "Resubmission";
1906
+ summary.OriginalRequestName = resubmission.keys().requestName;
1907
+ summary.InitialTaskPath = resubmission.keys().task;
1908
+ if (resubmission.keys().acdcURL) {
1909
+ //TODO: if there is not acdc_url don't create the button'
1910
+ var acdcServiceUrl = WMStats.Utils.splitCouchServiceURL(resubmission.keys().acdcURL);
1911
+ summary.ACDCServer = acdcServiceUrl.couchUrl;
1912
+ summary.ACDCDatabase = acdcServiceUrl.couchdb;
1913
+ }
1914
+
1915
+ var requestInfo = reqMgrRequest.getData();
1916
+ // passed to wmstats view
1917
+ summary.RequestString = WMStats.Utils.acdcRequestSting(summary.OriginalRequestName, requestInfo.Requestor);
1918
+ summary.Campaign = requestInfo.Campaign;
1919
+ summary.RequestPriority = requestInfo.RequestPriority;
1920
+
1921
+ //TODO get the site white list from acdc db. (site might be overflowed)
1922
+ // assign more value for acdc assignment
1923
+ summary.Team = requestInfo.Team;
1924
+ summary.TrustPUSitelists = false;
1925
+ summary.TrustSitelists = false;
1926
+
1927
+ return summary;
1928
+ };
1929
+
1930
+ resubmission.propagateUpdate = function() {
1931
+ if (resubmission.keys() !== null) {
1932
+ resubmission.retrieveData(resubmission.keys());
1933
+ return true;
1934
+ } else {
1935
+ return false;
1936
+ }
1937
+ };
1938
+
1939
+ return resubmission;
1940
+ })();
1941
+
1942
+ vm.initialize = (function (){
1943
+ //default setting
1944
+ vm.page(vm.ActiveRequestPage, true);
1945
+ vm.ActiveRequestPage.view(vm.CategoryView, true);
1946
+ vm.CategoryView.category(vm.CampaignCategory, true);
1947
+ vm.RequestView.format(vm.RequestProgress, true);
1948
+ vm.JobView.detail(vm.JobDetail, true);
1949
+ })();
1950
+
1951
+ })(WMStats.ViewModel);
1952
+
1953
+ // control inside the view model
1954
+ (function(vm){
1955
+ // filter control
1956
+ vm.ActiveRequestPage.subscribe("filter", function() {
1957
+ vm.ActiveRequestPage.propagateUpdate();
1958
+ });
1959
+
1960
+ vm.SearchPage.subscribe("keys", function(){
1961
+ vm.SearchPage.retrieveData(vm.SearchPage.keys());
1962
+ });
1963
+
1964
+ vm.CategoryView.subscribe("category", function() {
1965
+ vm.CategoryView.propagateUpdate();
1966
+ });
1967
+
1968
+ vm.RequestView.subscribe("categoryKey", function() {
1969
+ vm.ActiveRequestPage.view(vm.RequestView);
1970
+ });
1971
+
1972
+ vm.JobView.subscribe("requestName", function() {
1973
+ vm.ActiveRequestPage.view(vm.JobView);
1974
+ });
1975
+
1976
+ vm.AlertJobView.subscribe("requestName", function() {
1977
+ vm.AlertJobView.retrieveData(vm.AlertJobView.requestName());
1978
+ });
1979
+
1980
+ vm.CategoryDetail.subscribe("categoryKey", function() {
1981
+ vm.CategoryDetail.propagateUpdate();
1982
+ });
1983
+
1984
+ vm.JobDetail.subscribe("keys", function() {
1985
+ vm.JobDetail.retrieveData(vm.JobDetail.keys());
1986
+ });
1987
+
1988
+ vm.AlertJobDetail.subscribe("keys", function() {
1989
+ vm.AlertJobDetail.retrieveData(vm.AlertJobDetail.keys());
1990
+ });
1991
+
1992
+ vm.Resubmission.subscribe("keys", function() {
1993
+ vm.Resubmission.retrieveData(vm.Resubmission.keys());
1994
+ });
1995
+
1996
+ })(WMStats.ViewModel);
1997
+ WMStats.namespace("CategorySummaryMap");
1998
+ WMStats.namespace("CategoryTableMap");
1999
+
2000
+ WMStats.CategorySummaryMap = function(){
2001
+ var summaryMap = {};
2002
+ function add(category, summaryFunc) {
2003
+ summaryMap[category] = summaryFunc;
2004
+ }
2005
+ function get(category) {
2006
+ return summaryMap[category];
2007
+ }
2008
+ return {add: add, get: get};
2009
+ }();
2010
+
2011
+ WMStats.CategoryTableMap = function(){
2012
+ var tableMap = {};
2013
+ var vm = WMStats.ViewModel;
2014
+ function add(category, view) {
2015
+ tableMap[category] = view;
2016
+ }
2017
+ function get(category, view) {
2018
+ if (category === vm.RequestView.categoryName) {
2019
+ return tableMap[category][vm.RequestView.format().name()];
2020
+ }else {
2021
+ return tableMap[category];
2022
+ }
2023
+
2024
+ }
2025
+ return {add: add, get: get};
2026
+ }();
2027
+
2028
+ (function(vm){
2029
+ //WMStats.CategoryTableMap.add(WMStats.Controls.requests, WMStats.ActiveRequestTableWithJob);
2030
+
2031
+ // add controller
2032
+ vm.CategoryView.subscribe("data", function() {
2033
+ var view = WMStats.CategoryTableMap.get(vm.CategoryView.category().name());
2034
+ view(vm.CategoryView.data(), vm.CategoryView.category().id());
2035
+ });
2036
+
2037
+ vm.RequestView.subscribe("data", function() {
2038
+ var view = WMStats.CategoryTableMap.get(vm.RequestView.categoryName);
2039
+ view(vm.RequestView.data(), vm.RequestView.format().id());
2040
+ });
2041
+ })(WMStats.ViewModel);
2042
+ WMStats.namespace("View");
2043
+
2044
+ WMStats.View.IndexHTML = function(){
2045
+
2046
+ function applyTemplate(){
2047
+ var viewPane = $('#data_board div.viewPane');
2048
+ $('div.viewTemplate').children().clone().appendTo(viewPane);
2049
+ };
2050
+
2051
+ function retrieveData() {
2052
+ WMStats.ActiveRequestModel.retrieveData();
2053
+ WMStats.AgentModel.retrieveData();
2054
+ //WMStats.HistoryModel.setOptions();
2055
+ //WMStats.HistoryModel.retrieveData();
2056
+ };
2057
+
2058
+ $(document).ready(function() {
2059
+ $('#loading_page').addClass("front").show();
2060
+ //applyTemplate();
2061
+ WMStats.CommonControls.setLinkTabs("#link_tabs");
2062
+ WMStats.CommonControls.setUTCClock("#clock");
2063
+ WMStats.CommonControls.setWorkloadSummarySearch("#search_option_board");
2064
+ WMStats.Controls.setFilter("#filter_board");
2065
+ WMStats.Controls.setAllRequestButton("#status_board");
2066
+ WMStats.Controls.setTabs("#tab_board");
2067
+ WMStats.Controls.setCategoryButton("#category_bar");
2068
+ WMStats.Controls.setViewSwitchButton("#view_switch_bar");
2069
+
2070
+ //view model bind
2071
+ var vm = WMStats.ViewModel;
2072
+ vm.ActiveRequestPage.id('#activeRequestPage');
2073
+ vm.RequestAlertPage.id('#requestAlertPage');
2074
+ vm.AgentPage.id('#agentInfoPage');
2075
+ vm.LogDBPage.id('#logDBPage');
2076
+ vm.SearchPage.id('#workloadSummaryPage');
2077
+
2078
+ vm.CategoryView.id('#category_view');
2079
+ vm.RequestView.id('#request_view');
2080
+ vm.JobView.id('#job_view');
2081
+
2082
+ // Category summary view
2083
+ //TODO: Tier1 Category - move this some other place which belongs Tier1
2084
+ vm.CampaignCategory.id('#category_view div.summary_data');
2085
+ vm.SiteCategory.id('#category_view div.summary_data');
2086
+ vm.CMSSWCategory.id('#category_view div.summary_data');
2087
+ vm.AgentCategory.id('#category_view div.summary_data');
2088
+
2089
+ //TODO: Tier0 Category - move this some other place which belongs Tier0
2090
+ vm.RunCategory.id('#category_view div.summary_data');
2091
+
2092
+ // Request summary view
2093
+ vm.RequestProgress.id('#request_view div.summary_data');
2094
+ vm.RequestJobs.id('#request_view div.summary_data');
2095
+
2096
+ // Job summary view
2097
+ //To do need to add
2098
+
2099
+ vm.CategoryDetail.id('#category_view div.detail_data');
2100
+ vm.RequestDetail.id('#request_view div.detail_data');
2101
+ vm.JobDetail.id('#job_view div.detail_data');
2102
+ vm.Resubmission.id('#acdc_submission');
2103
+
2104
+
2105
+ // request alert view
2106
+ vm.AlertJobView.id("#alert_job_summary");
2107
+ vm.AlertJobDetail.id("#alert_job_detail");
2108
+
2109
+ // view model controller
2110
+ var wsControl = WMStats.GenericController;
2111
+
2112
+ //callback funtion
2113
+ function switchPage(event, data) {
2114
+ //data is page object
2115
+ wsControl.switchDiv(data.id(), ["#activeRequestPage", "#requestAlertPage",
2116
+ "#agentInfoPage", "#logDBPage", "#workloadSummaryPage"]);
2117
+ vm.propagateUpdate();
2118
+ };
2119
+
2120
+ function switchView(event, data) {
2121
+ //data is page object
2122
+ wsControl.switchDiv(data.id(), ["#category_view", "#request_view", "#job_view"]);
2123
+ vm.ActiveRequestPage.view().propagateUpdate();
2124
+ };
2125
+
2126
+ // set the control bind
2127
+ vm.subscribe("page", switchPage);
2128
+ vm.ActiveRequestPage.subscribe("view", switchView);
2129
+ vm.RequestView.subscribe("categoryKey", function(event, categoryKey) {
2130
+ WMStats.CategoryTitle(categoryKey, '#category_title');
2131
+ });
2132
+
2133
+ vm.JobView.subscribe("requestName", function(event, requestName) {
2134
+ WMStats.RequestTitle(requestName, '#request_title');
2135
+ });
2136
+
2137
+ var E = WMStats.CustomEvents;
2138
+ $(WMStats.Globals.Event).on(E.AGENTS_LOADED, function(event, agentData) {
2139
+ // refresh the agentData.agentNumber.error
2140
+ agentData.getAlertList();
2141
+ if (agentData.agentNumber.error > 0) {
2142
+ $('#linkTabs a[href="#agentInfoPage"] strong').text("(" + agentData.agentNumber.error + ")");
2143
+ } else {
2144
+ $('#linkTabs a[href="#agentInfoPage"] strong').text("");
2145
+ }
2146
+ });
2147
+
2148
+ $(WMStats.Globals.Event).on(E.ERROR_LOG_LOADED, function(event, logdbDetailData) {
2149
+ // refresh the agentData.agentNumber.error
2150
+ var errorNum = logdbDetailData.getData().length;
2151
+ if ( errorNum > 0) {
2152
+ $('#linkTabs a[href="#logDBPage"] strong').text("(" + errorNum + ")");
2153
+ } else {
2154
+ $('#linkTabs a[href="#logDBPage"] strong').text("");
2155
+ };
2156
+ });
2157
+
2158
+ $(WMStats.Globals.Event).on(E.REQUESTS_LOADED,
2159
+ function(event) {
2160
+ //only Tier1 case
2161
+ var numError = WMStats.ActiveRequestModel.getData().numOfRequestError();
2162
+ if ((numError.alert) > 0) {
2163
+ $('#linkTabs a[href="#requestAlertPage"] strong').text("(" + numError.alert + ")");
2164
+ } else {
2165
+ $('#linkTabs a[href="#requestAlertPage"] strong').text("");
2166
+ };
2167
+ });
2168
+
2169
+ // initialize page)
2170
+ vm.page(vm.ActiveRequestPage);
2171
+ vm.ActiveRequestPage.view(vm.CategoryView);
2172
+ //vm.CategoryView.subscribe("ecategory", switchCategory)
2173
+ retrieveData();
2174
+ //$("div.draggable").draggable();
2175
+ // 3 min update
2176
+ setInterval(retrieveData, 180000);
2177
+ } );
2178
+ };
2179
+ WMStats.namespace("CommonControls");
2180
+ WMStats.CommonControls = function($){
2181
+
2182
+ var vm = WMStats.ViewModel;
2183
+ var vmRegistry = WMStats.ViewModel.Registry;
2184
+
2185
+ function setUTCClock(selector) {
2186
+ setInterval(function() {
2187
+ $(selector).text(WMStats.Utils.utcClock());
2188
+ }, 100);
2189
+ };
2190
+
2191
+ function setLinkTabs(selector) {
2192
+ var linkTabs =
2193
+ '<nav id="linkTabs" class="linkTabs">\
2194
+ <ul><li><a href="#activeRequestPage"> active request </a></li>\
2195
+ <li><a href="#requestAlertPage"> request alert <strong></strong></a></li>\
2196
+ <li><a href="#agentInfoPage"> agent info <strong></strong></a></li>\
2197
+ <li><a href="#logDBPage"> error logs <strong></strong></a></li>\
2198
+ <li><a href="#workloadSummaryPage"> search </a></li></ul>\
2199
+ </nav>';
2200
+
2201
+ $(selector).append(linkTabs);
2202
+
2203
+ // add controller for this view
2204
+ function changeTab(event, data) {
2205
+ $('#linkTabs li').removeClass("title-tab-selected").addClass("title-tab-hide");
2206
+ $('#linkTabs a[href="' + data.id() +'"]').parent().removeClass("title-tab-hide").addClass("title-tab-selected");
2207
+ }
2208
+ // viewModel -> view control
2209
+ vm.subscribe("page", changeTab);
2210
+
2211
+ // view -> viewModel control
2212
+ $(document).on('click', "#linkTabs li a", function(event){
2213
+ vm.page(vmRegistry[this.hash]);
2214
+ event.preventDefault();
2215
+ });
2216
+ };
2217
+
2218
+ function setWorkloadSummarySearch(selector) {
2219
+ var searchOption =
2220
+ '<fieldset id="SearchOptionsPane">\
2221
+ <legend>Search WorkloadSummary</legend>\
2222
+ <div id="searchPane">\
2223
+ <div class="OptionBox">\
2224
+ <select name="SearchOptions" class="searchSelector" title="Select a search option">\
2225
+ <option value="request" data-search-type="stringMatch" selected="selected"> request name</option>\
2226
+ <option value="outputdataset" data-search-type="stringMatch"> output dataset </option>\
2227
+ <option value="inputdataset" data-search-type="stringMatch">input dataset</option>\
2228
+ <option value="prep_id" data-search-type="stringMatch">prep id</option>\
2229
+ <option value="data_pileup" data-search-type="stringMatch">data pileup</option>\
2230
+ <option value="mc_pileup" data-search-type="stringMatch">mc pileup</option>\
2231
+ <option value="request_date" data-search-type="dateRange">date range</option>\
2232
+ </select>\
2233
+ </div>\
2234
+ <div class="SearchBox">\
2235
+ <input type="text" size="100" name="workloadSummarySearch" value=""></input>\
2236
+ </div>\
2237
+ </div>\
2238
+ <div>\
2239
+ <button type="submit" id="WorkloadSummarySearchButton">submit</button>\
2240
+ </div>\
2241
+ </fieldset>';
2242
+
2243
+ $(selector).append(searchOption);
2244
+
2245
+ // change the search options
2246
+ $(document).on('change', 'select[name="SearchOptions"]',function(){
2247
+ var filterType = $(':selected', this).attr('data-search-type');
2248
+ var searchBox = $('#searchPane .SearchBox');
2249
+ $(searchBox).empty();
2250
+ $('div.template.'+ filterType).children().clone().appendTo('#searchPane .SearchBox');
2251
+ $('#searchPane .SearchBox input[name="dateRange1"]').datepicker({
2252
+ altField: 'input[name="dateRange1"]',
2253
+ altFormat: "yy/mm/dd",
2254
+ changeYear: true,
2255
+ yearRange: "2012:c"});
2256
+ $('#searchPane .SearchBox input[name="dateRange2"]').datepicker({
2257
+ altField: 'input[name="dateRange2"]',
2258
+ altFormat: "yy/mm/dd",
2259
+ changeYear: true,
2260
+ yearRange: "2012:c"});
2261
+ });
2262
+
2263
+ // control submit button
2264
+ $(document).on('click', '#WorkloadSummarySearchButton', function(event) {
2265
+ var keys = {};
2266
+ keys.searchCategory = $('#search_option_board select[name="SearchOptions"] :selected').val();
2267
+ keys.searchValue = $('input[name="workloadSummarySearch"]').val();
2268
+ vm.SearchPage.keys(keys);
2269
+ event.stopPropagation();
2270
+ });
2271
+ };
2272
+
2273
+ return {
2274
+ setUTCClock: setUTCClock,
2275
+ setLinkTabs: setLinkTabs,
2276
+ setWorkloadSummarySearch: setWorkloadSummarySearch
2277
+ };
2278
+ }(jQuery);WMStats.namespace("Table");
2279
+ WMStats.Table = function(config, tableSetting) {
2280
+
2281
+ var tableSetting = tableSetting || '<table cellpadding="0" cellspacing="0" border="0.5" class="display" width="100%"></table>';
2282
+ var tableConfig = {
2283
+ //"paginationType": "full_numbers",
2284
+ //"scrollX": "100%",
2285
+ //"scrollCollapse": true,
2286
+ "stateSave": true,
2287
+ "processing": true,
2288
+ //"iDisplayLength": 10,
2289
+ "dom": '<"top"pl>rt<"bottom"ip>',
2290
+ //"sDom": 'C<"clear">lfrtip',
2291
+ "autoWidth": true,
2292
+ "jQueryUI": true
2293
+ };
2294
+
2295
+ function updateConfig(config) {
2296
+ for (var prop in config) {
2297
+ tableConfig[prop] = config[prop];
2298
+ }
2299
+
2300
+ }
2301
+
2302
+ /* footer is needed to use columnFilter */
2303
+ function _footer() {
2304
+ var footer = '<tfoot><tr>';
2305
+
2306
+ for (var i in tableConfig.aoColumns) {
2307
+ if (tableConfig.aoColumns[i].bVisible != false){
2308
+ footer += '<th>' + tableConfig.aoColumns[i]["title"] + '</th>';
2309
+ }
2310
+ }
2311
+ footer += '</tr></tfoot>';
2312
+ return footer;
2313
+ }
2314
+
2315
+ function create(selector, filterConfig) {
2316
+ $(selector).empty();
2317
+ $(selector).html(tableSetting);
2318
+
2319
+ tableConfig.stateSaveCallback = function(settings,data) {
2320
+ localStorage.setItem(selector, JSON.stringify(data));
2321
+ };
2322
+ tableConfig.stateLoadCallback = function(settings) {
2323
+ return JSON.parse(localStorage.getItem(selector));
2324
+ };
2325
+
2326
+ var oTable = $(selector + " table").DataTable(tableConfig);
2327
+ if ( oTable.length > 0 ) {
2328
+ oTable.columns.adjust().draw();
2329
+ }
2330
+
2331
+ jQuery(WMStats.Globals.Event).triggerHandler(WMStats.CustomEvents.LOADING_DIV_END);
2332
+
2333
+ //TODO: enable column filter
2334
+ //if (filterConfig) {
2335
+ //oTable.append(_footer());
2336
+ //https://datatables.net/reference/api/column().search()
2337
+ //}
2338
+ return oTable;
2339
+ }
2340
+
2341
+ if (config) {updateConfig(config);}
2342
+
2343
+ return {'config': tableConfig,
2344
+ 'updateConfig': updateConfig,
2345
+ 'create': create
2346
+ };
2347
+ };
2348
+ WMStats.namespace("JobSummaryTable");
2349
+
2350
+ WMStats.JobSummaryTable = function (data, containerDiv) {
2351
+
2352
+ var tableConfig = {
2353
+ "dom": '<"top"plf>rt<"bottom"ip>',
2354
+ "pageLength": 25,
2355
+ "columns": [
2356
+ {"title": "L",
2357
+ "defaultContent": 0,
2358
+ "render": function (data, type, row, meta) {
2359
+ return WMStats.Utils.formatDetailButton("drill");
2360
+ }},
2361
+ { "render": function (data, type, row, meta) {
2362
+ if (type == 'display') {
2363
+ var taskList = row.task.split('/');
2364
+ return taskList[taskList.length - 1];
2365
+ }
2366
+ return row.task;
2367
+ }, "title": "task", "width": "150px"},
2368
+ { "data": "status", "title": "status"},
2369
+ { "data": "site", "title": "site"},
2370
+ { "data": "exitCode", "title": "exit code"},
2371
+ { "data": "count", "title": "jobs"},
2372
+ { "data": "errorMsg", "title": "error mesage",
2373
+ "defaultContent": ""},
2374
+ { "title": "acdc", defaultContent: "",
2375
+ "width": "15px",
2376
+ "render": function (data, type, row, meta) {
2377
+ if (type == 'display') {
2378
+ var taskList = row.task.split('/');
2379
+ var endTask = taskList[taskList.length - 1];
2380
+ if (row.status !== "success" &&
2381
+ !endTask.match(/LogCollect$/) &&
2382
+ !endTask.match(/Cleanup$/)) {
2383
+ return WMStats.Utils.formatDetailButton("acdc");
2384
+ }
2385
+ }
2386
+ return "";
2387
+ }
2388
+ }
2389
+ ],
2390
+ "order": [[1, 'asc']]
2391
+ };
2392
+
2393
+ tableConfig.data = data.getData().status;
2394
+
2395
+ var filterConfig = {};
2396
+
2397
+ $(containerDiv).data('workflow', (data.getData()).workflow);
2398
+
2399
+ // store the table data
2400
+ WMStats.JobSummaryTable.data = WMStats.Table(tableConfig).create(containerDiv, filterConfig);
2401
+ return WMStats.JobSummaryTable.data;
2402
+ };
2403
+
2404
+ (function() {
2405
+ var vm = WMStats.ViewModel;
2406
+
2407
+ vm.JobView.subscribe("data", function() {
2408
+ // need to create the lower level view
2409
+ var divSelector = vm.JobView.id() + " div.summary_data";
2410
+ WMStats.JobSummaryTable(vm.JobView.data(), divSelector);
2411
+ });
2412
+
2413
+ /*
2414
+ vm.AlertJobView.subscribe("data", function() {
2415
+ WMStats.JobSummaryTable(vm.AlertJobView.data(), vm.AlertJobView.id());
2416
+ });
2417
+ */
2418
+ })();
2419
+ WMStats.namespace("WorkloadSummaryTable");
2420
+
2421
+ WMStats.WorkloadSummaryTable = function (data, containerDiv) {
2422
+
2423
+ var formatReqDetailUrl = WMStats.Utils.formatReqDetailUrl;
2424
+ var formatWorkloadSummarylUrl = WMStats.Utils.formatWorkloadSummarylUrl;
2425
+
2426
+ var tableConfig = {
2427
+ "pageLength": 25,
2428
+ "scrollX": true,
2429
+ "dom": 'lfrtip',
2430
+ "columns": [
2431
+ /*
2432
+ {"title": "D",
2433
+ "defaultContent": 0,
2434
+ "width": "15px",
2435
+ "render": function (data, type, row, meta) {
2436
+ return WMStats.Utils.formatDetailButton("detail");
2437
+ }},
2438
+ {"title": "L",
2439
+ "defaultContent": 0,
2440
+ "width": "15px",
2441
+ "render": function (data, type, row, meta) {
2442
+ return WMStats.Utils.formatDetailButton("drill");
2443
+ }},
2444
+ */
2445
+ { "data": "workflow", "title": "workflow",
2446
+ "render": function (data, type, row, meta) {
2447
+ return formatReqDetailUrl(row._id);
2448
+ },
2449
+ "width": "150px"
2450
+ },
2451
+ {"render": function (data, type, row, meta) {
2452
+ if (type === "display") {
2453
+ return formatWorkloadSummarylUrl(row._id,
2454
+ row.request_status[row.request_status.length -1].status);
2455
+ }
2456
+ return row.request_status[row.request_status.length -1].status;
2457
+ },
2458
+ },
2459
+ { "data": "request_type", "title": "type", "defaultContent": ""},
2460
+ { "data": "priority", "title": "priority", "defaultContent": 0},
2461
+ { "data": "campaign", "title": "campaign", "defaultContent": ""}
2462
+ ]
2463
+ };
2464
+
2465
+ var filterConfig = {};
2466
+
2467
+ tableConfig.data = data.getData();
2468
+
2469
+ return WMStats.Table(tableConfig).create(containerDiv, filterConfig);
2470
+ };
2471
+
2472
+ (function() {
2473
+
2474
+ var vm = WMStats.ViewModel;
2475
+
2476
+ vm.SearchPage.subscribe("data", function(){
2477
+ WMStats.WorkloadSummaryTable(vm.SearchPage.data(), "#search_result_board");
2478
+ });
2479
+ })();
2480
+ /*
2481
+ * Add EventHandler
2482
+ */
2483
+ (function($) {
2484
+
2485
+ //custom events
2486
+ var E = WMStats.CustomEvents;
2487
+ var vm = WMStats.ViewModel;
2488
+
2489
+ // Super class for table event handling
2490
+ function TableEventHandler(containerID, populateRequestTable) {
2491
+ this.containerID = containerID;
2492
+ if (populateRequestTable) {
2493
+ this.populateRequestTable = populateRequestTable;
2494
+ }
2495
+ }
2496
+ // add Classmethod and property
2497
+ TableEventHandler.highlightRow = function(selector, currenElement) {
2498
+ $(selector).removeClass('mouseclickRow');
2499
+ $(currenElement).addClass('mouseclickRow');
2500
+ };
2501
+
2502
+ TableEventHandler.prototype = {
2503
+ constructor: TableEventHandler,
2504
+
2505
+ tableRowBind: function(bind, parentSelector, func) {
2506
+ var currentObj = this;
2507
+ var selector = parentSelector + " table tbody tr";
2508
+ $(document).on(bind, selector, function () {
2509
+ TableEventHandler.highlightRow(selector, this);
2510
+ currentObj[func](this);
2511
+ });
2512
+ },
2513
+
2514
+ tableColumnBind: function(bind, parentSelector, name, func) {
2515
+ var currentObj = this;
2516
+ var selector = parentSelector + ' table tbody tr td div[name="' + name + '"]';
2517
+ var rowSelector = parentSelector + ' table tbody tr';
2518
+ $(document).on(bind, selector, function () {
2519
+ var currentRow = $(this).closest("tr")[0];
2520
+ TableEventHandler.highlightRow(rowSelector, currentRow);
2521
+ currentObj[func](currentRow);
2522
+ event.preventDefault();
2523
+ });
2524
+ },
2525
+
2526
+ populateRequestSummary: function(currentElement){
2527
+ // create the request table
2528
+ var nTds = $('td', currentElement);
2529
+ vm.RequestView.categoryKey($(nTds[2]).text());
2530
+ },
2531
+
2532
+ populateJobSummary: function(currentElement){
2533
+
2534
+ var nTds = $('td', currentElement);
2535
+ vm.JobView.requestName($(nTds[2]).text());
2536
+ },
2537
+
2538
+ populateRequestDetail: function(currentElement){
2539
+ // create the request table
2540
+ var nTds = $('td', currentElement);
2541
+ vm.RequestDetail.requestName($(nTds[2]).text());
2542
+ },
2543
+
2544
+ populateCategoryDetail: function(currentElement){
2545
+ // create the request table
2546
+ var nTds = $('td', currentElement);
2547
+ vm.CategoryDetail.categoryKey($(nTds[2]).text());
2548
+ },
2549
+
2550
+ populateJobDetail: function (currentElement){
2551
+ // 2. create the job detail view
2552
+ var summary = {};
2553
+ // need to get the workflow name with out depending on the selector
2554
+ summary.workflow = $("#job_view div.summary_data").data("workflow");
2555
+ //summary.task = $(nTds[0]).text();
2556
+ var currentRow = $(currentElement).closest("tr")[0];
2557
+ var currentRowData = WMStats.JobSummaryTable.data.row(currentElement).data();
2558
+ summary.task = currentRowData.task;
2559
+ summary.status = currentRowData.status;
2560
+ summary.site = currentRowData.site;
2561
+ if (summary.site ==="{}"){
2562
+ summary.site = {};
2563
+ }
2564
+ summary.acdcURL = currentRowData.acdcURL;
2565
+ summary.exitCode = currentRowData.exitCode;
2566
+
2567
+ vm.JobDetail.keys(summary);
2568
+ $(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);
2569
+ },
2570
+
2571
+ createACDCResubmission: function (currentElement){
2572
+ var workflow = $("#job_view div.summary_data").data("workflow");
2573
+ var summary = {};
2574
+ summary.requestName = workflow;
2575
+ //TODO: should be getting most information from request mgr database
2576
+ var currentRowData = WMStats.JobSummaryTable.data.row(currentElement).data();
2577
+ summary.task = currentRowData.task;
2578
+ summary.acdcURL = currentRowData.acdcURL;
2579
+ vm.Resubmission.keys(summary);
2580
+ }
2581
+ };
2582
+
2583
+ var ActiveModelHandler = new TableEventHandler();
2584
+ ActiveModelHandler.tableColumnBind('click', "#category_view div.summary_data", "drill",
2585
+ "populateRequestSummary");
2586
+ ActiveModelHandler.tableColumnBind("click", "#request_view div.summary_data", "drill",
2587
+ "populateJobSummary");
2588
+ //ActiveModelHandler.tableRowBind("click","#job_view div.summary_data",
2589
+ // "populateJobDetail");
2590
+ ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data", "drill",
2591
+ "populateJobDetail");
2592
+ ActiveModelHandler.tableColumnBind("click","#job_view div.summary_data", "acdc",
2593
+ "createACDCResubmission");
2594
+ ActiveModelHandler.tableColumnBind('click', "#category_view div.summary_data", "detail",
2595
+ "populateCategoryDetail");
2596
+ ActiveModelHandler.tableColumnBind('click', "#request_view div.summary_data", "detail",
2597
+ "populateRequestDetail");
2598
+
2599
+ // actual event binding codes
2600
+ // row mouse over/ mouse out events
2601
+ $(document).on('mouseover', 'tr', function(event) {
2602
+ $(this).addClass('mouseoverRow');
2603
+ });
2604
+
2605
+ $(document).on('mouseout', 'tr', function(event) {
2606
+ $(this).removeClass('mouseoverRow');
2607
+ });
2608
+
2609
+ })(jQuery);
2610
+ WMStats.namespace('JobDetailList');
2611
+ (function() {
2612
+
2613
+ var stateTransitionFormat = function(state) {
2614
+ return "<b>" + state['newstate'] + ":</b> " +
2615
+ WMStats.Utils.utcClock(new Date(state['timestamp'] * 1000)) +
2616
+ ", " + state['location'];
2617
+ };
2618
+
2619
+ var inputFileFormat = function(inputFile) {
2620
+ return inputFile['lfn'];
2621
+ };
2622
+
2623
+ var lumiFormat = function(lumis) {
2624
+
2625
+ function lumiRangeFormat() {
2626
+ if (startLumi == preLumi) {
2627
+ lumiFormat.push("[" + startLumi + "]");
2628
+ } else {
2629
+ lumiFormat.push("[" + startLumi + " - " + preLumi + "]");
2630
+ };
2631
+ };
2632
+
2633
+ var preLumi = null;
2634
+ var startLumi = null;
2635
+ var lumiFormat = new Array();
2636
+ for (var i in lumis) {
2637
+ for (var j in lumis[i]) {
2638
+ for (var k in lumis[i][j]) {
2639
+ var currentLumi = Number(lumis[i][j][k]);
2640
+ if (startLumi === null) {
2641
+ startLumi = currentLumi;
2642
+ } else if ((preLumi + 1) !== currentLumi) {
2643
+ lumiRangeFormat();
2644
+ startLumi = currentLumi;
2645
+ };
2646
+ preLumi = currentLumi;
2647
+ };
2648
+ };
2649
+ };
2650
+
2651
+ if (startLumi !== null) {
2652
+ lumiRangeFormat();
2653
+ };
2654
+ return lumiFormat;
2655
+ };
2656
+
2657
+ var logArchiveFormat = function(archiveObj, key) {
2658
+ return key;
2659
+ };
2660
+
2661
+ var format = function (data) {
2662
+ var jobDetails = data.getData();
2663
+ var requestData = WMStats.ActiveRequestModel.getData();
2664
+ var htmlstr = '<div><nav id="jobDetailNav" class="button-group"><ul>';
2665
+ var jobDivIDPrefix = "jobDetail-";
2666
+ for (var index in jobDetails) {
2667
+ var buttonNumber = Number(index) + 1;
2668
+ if (buttonNumber == 1) {
2669
+ htmlstr += '<li><a href="#' + jobDivIDPrefix + index + '" class="pageButton button-selected">' + buttonNumber +' </a></li>';
2670
+ } else {
2671
+ htmlstr += '<li><a href="#' + jobDivIDPrefix + index + '" class="pageButton button-unselected">' + buttonNumber +' </a></li>';
2672
+ }
2673
+ }
2674
+ htmlstr += '</nav></ul></div>';
2675
+ for (var index in jobDetails) {
2676
+ var jobDoc = jobDetails[index];
2677
+ if (index === "0") {
2678
+ htmlstr += "<div class='jobDetailBox' id='" + jobDivIDPrefix + index + "'>";
2679
+ } else {
2680
+ htmlstr += "<div class='jobDetailBox hideDiv' id='" + jobDivIDPrefix + index + "'>";
2681
+ }
2682
+ htmlstr += "<ul>";
2683
+ htmlstr += "<li><b>Job Name:</b> " + jobDoc._id + "</li>";
2684
+ htmlstr += "<li><b>WMBS job id:</b> " + jobDoc.wmbsid + "</li>";
2685
+ htmlstr += "<li><b>Workflow:</b> " + jobDoc.workflow + "</li>";
2686
+ htmlstr += "<li><b>Task:</b> " + jobDoc.task + "</li>";
2687
+ htmlstr += "<li><b>Status:</b> " + jobDoc.state + "</li>";
2688
+ htmlstr += "<li><b>Input dataset:</b> " + WMStats.Utils.getInputDatasets(requestData.getData(jobDoc.workflow)) + "</li>";
2689
+ if (typeof jobDoc.site == "object") {
2690
+ htmlstr += "<li><b>Site:</b> N/A </li>";
2691
+ } else {
2692
+ htmlstr += "<li><b>Site:</b> " + jobDoc.site + "</li>";
2693
+ }
2694
+ htmlstr += "<li><b>Agent:</b> " + jobDoc.agent_name + "</li>";
2695
+ htmlstr += "<li><b>ACDC URL:</b> " + jobDoc.acdc_url + "</li>";
2696
+ htmlstr += "<li>" + WMStats.Utils.expandFormat(jobDoc.state_history, "State Transition", stateTransitionFormat) + "</li>";
2697
+ htmlstr += "<li><b>Exit code:</b> " + jobDoc.exitcode + "</li>";
2698
+ htmlstr += "<li><b>Retry count:</b> " + jobDoc.retrycount + "</li>";
2699
+ htmlstr += "<li><b>Errors:</b> ";
2700
+ for (var errorType in jobDoc.errors) {
2701
+ htmlstr += "<ul>";
2702
+ htmlstr += "<li><b>" + errorType + "</b></li>";
2703
+ for (var i in jobDoc.errors[errorType]){
2704
+ htmlstr += "<ul>";
2705
+ htmlstr += "<li><b>" + jobDoc.errors[errorType][i].type +" (Exit Code: " + jobDoc.errors[errorType][i].exitCode + ")</b></li>";
2706
+ htmlstr += "<ul>";
2707
+ htmlstr += "<li><pre>" + WMStats.Utils.escapeHtml(jobDoc.errors[errorType][i].details) +"</pre></li>";
2708
+ htmlstr += "</ul>";
2709
+ htmlstr += "</ul>";
2710
+ }
2711
+ htmlstr += "</ul>";
2712
+ }
2713
+ htmlstr += "</li>";
2714
+
2715
+ htmlstr += "<li>" + WMStats.Utils.expandFormat(jobDoc.inputfiles, "Input files", inputFileFormat) + "</li>";
2716
+ htmlstr += "<li>" + WMStats.Utils.expandFormat(lumiFormat(jobDoc.lumis), "Lumis") + "</li>";
2717
+
2718
+ htmlstr += "<li><b>Output:</b> ";
2719
+ for (var i in jobDoc.output) {
2720
+ htmlstr += "<ul>";
2721
+ htmlstr += "<li><b>" + jobDoc.output[i].type + "</b></li>";
2722
+ htmlstr += "<ul>";
2723
+ htmlstr += "<li><b>lfn:</b> " + jobDoc.output[i].lfn +"</li>";
2724
+
2725
+ htmlstr += "<li><b>location:</b> ";
2726
+ htmlstr += jobDoc.output[i].location;
2727
+ if (jobDoc.output[i].type === "logArchive") {
2728
+ htmlstr += "<li class='pfn'><b>pfn:</b> ";
2729
+ // call phedex to get lfn
2730
+ }
2731
+ /*
2732
+ for (var j in jobDoc.output[i].location) {
2733
+ htmlstr += jobDoc.output[i].location[j] + " ";
2734
+ }*/
2735
+ htmlstr += "</li>";
2736
+ htmlstr += "<li><b>checksums: adler32:</b> " + jobDoc.output[i].checksums.adler32 + "</li>";
2737
+ htmlstr += "<li><b>size:</b> " + jobDoc.output[i].size + "</li>";
2738
+ htmlstr += "</ul>";
2739
+ htmlstr += "</ul>";
2740
+ }
2741
+ htmlstr += "</li>";
2742
+ if (jobDoc.worker_node_info) {
2743
+ htmlstr += "<li><b>Worker Node:</b>" + jobDoc.worker_node_info.HostName + "</li>";
2744
+ };
2745
+
2746
+ htmlstr += "<li>" + WMStats.Utils.expandFormat(jobDoc.logArchiveLFN, "log archive", logArchiveFormat) + "</li>";
2747
+ if (jobDoc.eos_log_url) {
2748
+ htmlstr += '<li><b>EOS log URL:</b><a href="' + jobDoc.eos_log_url.replace("eoscmshttp", "eoscmsweb") + '"> download log </a></li>';
2749
+ }
2750
+ htmlstr += "</ul>";
2751
+ htmlstr += "</div>";
2752
+ }
2753
+ return htmlstr;
2754
+ };
2755
+
2756
+
2757
+ WMStats.JobDetailList = function (data, containerDiv) {
2758
+ $(containerDiv).html(format(data));
2759
+ };
2760
+
2761
+ // control job Detail
2762
+
2763
+ var vm = WMStats.ViewModel;
2764
+
2765
+ vm.JobDetail.subscribe("data", function() {
2766
+ WMStats.JobDetailList(vm.JobDetail.data(), vm.JobDetail.id());
2767
+ });
2768
+ /*
2769
+ vm.AlertJobDetail.subscribe("data", function() {
2770
+ WMStats.JobDetailList(vm.AlertJobDetail.data(), vm.AlertJobDetail.id());
2771
+ });
2772
+ */
2773
+ $(document).on('click', "#jobDetailNav li a", function(event){
2774
+ $('div.jobDetailBox').hide();
2775
+ $(this.hash).show();
2776
+ //TODO call phedex to get PFN
2777
+
2778
+ $("#jobDetailNav li a").removeClass("button-selected").addClass("button-unselected");
2779
+ $(this).removeClass("button-unselected").addClass("button-selected");
2780
+ event.preventDefault();
2781
+ });
2782
+
2783
+ $(WMStats.Globals.Event).on(WMStats.CustomEvents.PHEDEX_PFN_SUCCESS,
2784
+ function(event, requestName) {
2785
+ $('#acdc_submission div.requestDetailBox').append(WMStats.Utils.formatReqDetailUrl(requestName));
2786
+ });
2787
+ })();
2788
+ WMStats.namespace("AgentDetailList");
2789
+
2790
+ (function () {
2791
+
2792
+ var componentFormat = function(componentList) {
2793
+ var formatStr = "";
2794
+ for (var i in componentList) {
2795
+ formatStr += "<details> <summary>" + componentList[i].name +"</summary> <ul>";
2796
+ formatStr += "<li><b>worker thread:</b> " + componentList[i].worker_name +"</li>";
2797
+ formatStr += "<li><b>status:</b> " + componentList[i].state + "</li>";
2798
+ //formatStr += "<li><b>error:</b> " + WMStats.Utils.utcClock(new Date(componentList[i].last_error * 1000)) + "</li>";
2799
+ formatStr += "<li><b>last updated:</b> " + WMStats.Utils.utcClock(new Date(componentList[i].last_updated * 1000)) + "</li>";
2800
+ formatStr += "<li><b>pid:</b> " + componentList[i].pid + "</li>";
2801
+ formatStr += "<li><b>error message:</b> <pre>" + componentList[i].error_message + "</pre></li>";
2802
+ formatStr += "</ul></details>";
2803
+ }
2804
+
2805
+ return formatStr;
2806
+ };
2807
+
2808
+ var diskFullFormat = function(diskList) {
2809
+ var formatStr = "<details> <summary> disk list</summary> <ul>";
2810
+ for (var i in diskList) {
2811
+ formatStr += "<li><b>" + diskList[i].filesystem +"</b>:" + diskList[i].percent +"</li>";
2812
+ }
2813
+ formatStr += "</ul></details>";
2814
+ return formatStr;
2815
+ };
2816
+
2817
+ var agentReportFormat = function (agentInfo, msgType) {
2818
+ var htmlstr = '';
2819
+ htmlstr += "<div class='" + msgType + " agent_detail_box'>";
2820
+ htmlstr += "<ul>";
2821
+ if (agentInfo) {
2822
+ agentVersion = ' (' + agentInfo.agent_version + ')'
2823
+ htmlstr += "<li><b>agent:</b> " + agentInfo.agent_url + agentVersion + "</li>";
2824
+ htmlstr += "<li><b>agent last updated:</b> " + WMStats.Utils.utcClock(new Date(agentInfo.timestamp * 1000)) +" : " +
2825
+ agentInfo.alert.agent_update + "</li>";
2826
+ htmlstr += "<li><b>data last updated:</b> " + agentInfo.alert.data_update + "</li>";
2827
+ htmlstr += "<li><b>status:</b> " + agentInfo.alert.message + "</li>";
2828
+ if (agentInfo.agent_team) {
2829
+ htmlstr += "<li><b>team:</b> " + agentInfo.agent_team+ "</li>";
2830
+ }
2831
+ };
2832
+ var componentsDown = agentInfo.down_components;
2833
+ if (componentsDown && (componentsDown.length > 0)) {
2834
+ htmlstr += "<li><b>component errors for:</b> " + componentsDown;
2835
+ if (agentInfo.down_component_detail && (agentInfo.down_component_detail.length > 0)) {
2836
+ htmlstr += componentFormat(agentInfo.down_component_detail);
2837
+ }
2838
+ htmlstr +="</li>";
2839
+ };
2840
+
2841
+ var diskInfo = agentInfo.disk_warning;
2842
+ if (diskInfo && (diskInfo.length > 0)) {
2843
+ htmlstr += "<li><b>disk warning:</b> ";
2844
+ htmlstr += diskFullFormat(diskInfo);
2845
+ htmlstr +="</li>";
2846
+ };
2847
+
2848
+ if (agentInfo.proxy_warning) {
2849
+ htmlstr += "<li><b>proxy warning:</b> " + agentInfo.proxy_warning + "</li>";
2850
+ };
2851
+
2852
+ if (agentInfo.drain_stats) {
2853
+ htmlstr += "<li><b>drain statistics:</b></li><ul>";
2854
+ htmlstr += "<li>workflows completed (" + agentInfo.drain_stats.workflows_completed + ")</li>";
2855
+ if (agentInfo.drain_stats.workflows_completed) {
2856
+ htmlstr += "<li>condor running (" + agentInfo.drain_stats.condor_status.running + ")</li>";
2857
+ htmlstr += "<li>condor idle (" + agentInfo.drain_stats.condor_status.idle + ")</li>";
2858
+ htmlstr += "<li>dbs open blocks (" + agentInfo.drain_stats.upload_status.dbs_open_blocks + ")</li>";
2859
+ htmlstr += "<li>dbs not uploaded (" + agentInfo.drain_stats.upload_status.dbs_notuploaded + ")</li>";
2860
+ htmlstr += "<li>phedex not uploaded (" + agentInfo.drain_stats.upload_status.phedex_notuploaded + ")</li>";
2861
+ for (var key in agentInfo.drain_stats.global_wq_status) {
2862
+ htmlstr += "<li>global WQ in '" + key + "' status (" + agentInfo.drain_stats.global_wq_status[key] + ")</li>";
2863
+ }
2864
+ for (var key in agentInfo.drain_stats.local_wq_status) {
2865
+ htmlstr += "<li>local WQ in '" + key + "' status (" + agentInfo.drain_stats.local_wq_status[key] + ")</li>";
2866
+ }
2867
+ for (var key in agentInfo.drain_stats.local_wqinbox_status) {
2868
+ htmlstr += "<li>local WQInbox in '" + key + "' status (" + agentInfo.drain_stats.local_wqinbox_status[key] + ")</li>";
2869
+ }
2870
+ // only print job information that are != than 0
2871
+ htmlstr += "<li>there are no wmbs jobs in the agent, except for...</li>";
2872
+ for (var key in agentInfo.WMBS_INFO.wmbsCountByState) {
2873
+ if (agentInfo.WMBS_INFO.wmbsCountByState[key]) {
2874
+ htmlstr += "<li> jobs in '" + key + "' state (" + agentInfo.WMBS_INFO.wmbsCountByState[key] + ")</li>";
2875
+ }
2876
+ }
2877
+ }
2878
+ htmlstr += "</ul>"
2879
+ }
2880
+
2881
+
2882
+ var dataError = agentInfo.data_error;
2883
+ if (dataError && dataError !== 'ok') {
2884
+ htmlstr += "<li><b>data collect error:</b> ";
2885
+ htmlstr += dataError;
2886
+ htmlstr +="</li>";
2887
+ };
2888
+
2889
+ var couchProcess = agentInfo.couch_process_warning;
2890
+ if (couchProcess && couchProcess > 0) {
2891
+ htmlstr += "<li><b>Couch Process maxed:</b> ";
2892
+ htmlstr += couchProcess;
2893
+ htmlstr +="</li>";
2894
+ };
2895
+
2896
+ htmlstr += "</ul>";
2897
+ htmlstr += "</div>";
2898
+ return htmlstr;
2899
+ };
2900
+
2901
+ var format = function (agentData) {
2902
+ var htmlstr = "";
2903
+ var agentsWithWarning = agentData.getAlertList();
2904
+ for (i in agentsWithWarning) {
2905
+ if (agentsWithWarning[i].alert && agentsWithWarning[i].alert.status) {
2906
+ htmlstr += agentReportFormat(agentsWithWarning[i], agentsWithWarning[i].alert.status);
2907
+ }
2908
+ };
2909
+ return htmlstr;
2910
+ };
2911
+
2912
+ WMStats.AgentDetailList = function (data, containerDiv) {
2913
+ $(containerDiv).html(format(data));
2914
+ };
2915
+
2916
+ // controller for this view to be triggered
2917
+ var vm = WMStats.ViewModel;
2918
+ vm.AgentPage.subscribe("data", function() {
2919
+ //TODO get id form the view
2920
+ var divID = '#agent_detail';
2921
+ WMStats.AgentDetailList(vm.AgentPage.data(), divID);
2922
+ });
2923
+
2924
+ })();
2925
+ WMStats.namespace('WMStats.CategoryTitle');
2926
+ (function() {
2927
+
2928
+ var format = function (data) {
2929
+ var categoryKey = data;
2930
+
2931
+ var htmlstr = "";
2932
+ //htmlstr += "<legend>request</legend>";
2933
+ htmlstr += "<div class='requestSummaryBox'>";
2934
+ htmlstr += "<ul>";
2935
+ htmlstr += "<li><b> Category: " + categoryKey + "</b></li>";
2936
+ htmlstr += "</ul>";
2937
+ htmlstr += "</div>";
2938
+ return htmlstr;
2939
+ };
2940
+
2941
+ WMStats.CategoryTitle = function (data, containerDiv) {
2942
+ $(containerDiv).html(format(data));
2943
+ };
2944
+ })();
2945
+ WMStats.namespace('WMStats.RequestTitle');
2946
+ (function() {
2947
+ var format = function (data) {
2948
+ var workflow;
2949
+ var dataType;
2950
+ if (typeof data === "string") {
2951
+ workflow = data;
2952
+ dataType = 0;
2953
+ } else {
2954
+ workflow = data.getData().workflow;
2955
+ dataType = 1;
2956
+ };
2957
+ var requestInfo = WMStats.ActiveRequestModel.getData().getData(workflow);
2958
+
2959
+ var htmlstr = "";
2960
+ //htmlstr += "<legend>request</legend>";
2961
+ htmlstr += "<div class='requestSummaryBox'>";
2962
+ htmlstr += "<ul>";
2963
+ htmlstr += "<li><b>" + workflow + "</b></li>";
2964
+ if (dataType == 1) {
2965
+ htmlstr += "<li><b>agent: </b>" + requestInfo.agent_url + "</li>";
2966
+ };
2967
+ htmlstr += "</ul>";
2968
+ htmlstr += "</div>";
2969
+ return htmlstr;
2970
+ };
2971
+
2972
+ WMStats.RequestTitle = function (data, containerDiv) {
2973
+ if (typeof data === "string" || (typeof data === "object" && data.getData().workflow !== undefined)) {
2974
+ $(containerDiv).html(format(data));
2975
+ };
2976
+ };
2977
+ })();
2978
+ WMStats.namespace('WMStats.RequestLogList');
2979
+ (function() {
2980
+
2981
+ function createRequestLogList(res, containerDiv) {
2982
+ var pat_war = /.*warning.*/;
2983
+ var pat_err = /.*error.*/;
2984
+ // construct list
2985
+ $.each(res, function(i)
2986
+ {
2987
+ var req = $('<div/>')
2988
+ .addClass('request')
2989
+ .text(res[i].request);
2990
+ $(containerDiv).append(req);
2991
+ var obj = res[i];
2992
+ var keys = Object.keys(obj);
2993
+ $.each(keys, function(j) {
2994
+ var thr = $('<div/>')
2995
+ .addClass('thread')
2996
+ .text(keys[j]);
2997
+ $(containerDiv).append(thr);
2998
+ var values = obj[keys[j]];
2999
+ $.each(values, function(k) {
3000
+ var val = values[k];
3001
+ var type = val.type;
3002
+ var msg_cls = 'agent-info';
3003
+ var icon_cls = '';
3004
+ if(val.type.match(pat_war)) {
3005
+ msg_cls = 'agent-warning';
3006
+ icon_cls = 'fa fa-bell-o medium agent-warning';
3007
+ } else if(val.type.match(pat_err)) {
3008
+ msg_cls = 'agent-error';
3009
+ icon_cls = 'fa fa-exclamation-triangle medium agent-error';
3010
+ } else {
3011
+ msg_cls = 'agent-info';
3012
+ icon_cls = 'fa fa-check medium agent-info';
3013
+ }
3014
+ var icon = $('<i/>').addClass(icon_cls).addClass('type-ts-msg');
3015
+ var date = new Date(val.ts);
3016
+ var span = $('<span/>').addClass('type-ts-msg '+msg_cls).text(val.type);
3017
+ var rest = $('<span/>').text(' | '+date.toGMTString()+' | '+val.msg);
3018
+ var ttm = $('<div/>')
3019
+ .addClass('type-ts-msg')
3020
+ .add(icon).add(rest).add('<br/>');
3021
+ $(containerDiv).append(ttm);
3022
+ });
3023
+ });
3024
+ $(containerDiv).append('<br/><hr/>');
3025
+ });
3026
+ };
3027
+
3028
+ var errorFormat = function(logData) {
3029
+ //var formatStr = "<div class='fa fa-exclamation-triangle medium agent-error'>";
3030
+ var formatStr = "";
3031
+ for (var i in logData) {
3032
+ formatStr += "<details> <summary> <b>" + logData[i].request + "</b></summary> <ul>";
3033
+ formatStr += "<li><b>agent</b>: " + logData[i].agent + "</li>";
3034
+ formatStr += "<li><b>thread</b>: " + logData[i].thr + "</li>";
3035
+ formatStr += "<li><b>type</b>: " + logData[i].type + "</li>";
3036
+ formatStr += "<li><b>update time</b>: " + WMStats.Utils.utcClock(new Date(logData[i].ts * 1000)) + "</li>";
3037
+ formatStr += "<li><b>error message</b>: <pre>" + logData[i].messages[0].msg + "</pre></li>";
3038
+ formatStr += "<li><b>id</b>: " + logData[i].id + "</li>";
3039
+ formatStr += "</ul></details>";
3040
+ }
3041
+ //formatStr += "</div>";
3042
+ return formatStr;
3043
+ };
3044
+
3045
+
3046
+ var format = function (data) {
3047
+ var htmlstr = "";
3048
+ htmlstr += errorFormat(data);
3049
+ return htmlstr;
3050
+ };
3051
+
3052
+ WMStats.RequestLogList = function (data, containerDiv) {
3053
+ $(containerDiv).html(format(data));
3054
+ };
3055
+
3056
+ // controller for this view to be triggered
3057
+ var vm = WMStats.ViewModel;
3058
+ vm.LogDBPage.subscribe("data", function() {
3059
+ //TODO get id form the view
3060
+ var divID = '#logdb_summary';
3061
+ logDBData = vm.LogDBPage.data();
3062
+ errors = logDBData.getLogWithLastestError();
3063
+ WMStats.RequestLogList(errors, divID);
3064
+ });
3065
+ })();
3066
+ WMStats.namespace("SiteHistoryGraph");
3067
+
3068
+ WMStats.SiteHistoryGraph = function (historyData, containerDiv) {
3069
+
3070
+ var siteHistory = JSON.stringify(historyData);
3071
+ var htmlList = '<pre>' + siteHistory + '</pre>';
3072
+ $(containerDiv).html(htmlList);
3073
+ };
3074
+ WMStats.namespace("Controls");
3075
+ WMStats.Controls = function($){
3076
+ var _filterSelector;
3077
+ var _categorySelector;
3078
+ var vm = WMStats.ViewModel;
3079
+ var vmRegistry = WMStats.ViewModel.Registry;
3080
+
3081
+ function setFilter(selector) {
3082
+ var inputFilter = '<div name="filter">\
3083
+ workflow: <input name="workflow" value=""></input>\
3084
+ status: <input name="request_status" value=""></input>\
3085
+ run: <input name="run" value=""></input>\
3086
+ </div>';
3087
+ $(selector).append(inputFilter);
3088
+ _filterSelector = selector + ' div[name="filter"] input';
3089
+
3090
+ $(document).on('keyup', selector + " input",
3091
+ function() { WMStats.Utils.delay(function() {
3092
+ //change the view model filter value
3093
+ WMStats.ViewModel.ActiveRequestPage.filter(WMStats.Utils.createInputFilter(_filterSelector));
3094
+
3095
+ }, 300)});
3096
+ }
3097
+
3098
+ function setCategoryButton(selector) {
3099
+
3100
+ vm.CategoryView.category(vm.RunCategory);
3101
+ };
3102
+
3103
+ function setViewSwitchButton(selector) {
3104
+ var viewSwitchBottons =
3105
+ '<nav id="view_switch_button" class="button-group">\
3106
+ <ul><li><a href="#progress" class="nav-button nav-button-selected"> progress </a></li>\
3107
+ </nav>';
3108
+
3109
+ $(selector).append(viewSwitchBottons);
3110
+
3111
+ $(document).on('click', "#view_switch_button li a", function(event){
3112
+ // format is either progress or numJobs need to decouple the name
3113
+ var buttonName = this.hash.substring(1);
3114
+ var requestFormat;
3115
+ if (buttonName === "progress") {
3116
+ requestFormat = vm.RequestProgress;
3117
+ }
3118
+ vm.RequestView.format(requestFormat);
3119
+ // this might not be the efficient way. or directly update the table.
3120
+ vm.RequestView.propagateUpdate();
3121
+ $("#view_switch_button li a").removeClass("nav-button-selected").addClass("button-unselected");
3122
+ $(this).addClass("nav-button-selected");
3123
+ event.preventDefault();
3124
+ });
3125
+ };
3126
+
3127
+ function setAllRequestButton(selector) {
3128
+ var requestButtons =
3129
+ '<nav id="all_requests" class="button-group">\
3130
+ <ul><li><a href="#" class="nav-button"> all requests </a></li></ul>\
3131
+ </nav>';
3132
+
3133
+ $(selector).append(requestButtons).addClass("button-group");
3134
+
3135
+ $(document).on('click', "#all_requests li a", function(event){
3136
+ vm.RequestView.categoryKey("all");
3137
+ event.preventDefault();
3138
+ });
3139
+
3140
+ vm.RequestView.subscribe("categoryKey", function(){
3141
+ var buttonSelector = "#all_requests li a";
3142
+ if (vm.RequestView.categoryKey() === "all") {
3143
+ $(buttonSelector).removeClass("button-unselected").addClass("nav-button-selected");
3144
+ } else {
3145
+ $(buttonSelector).removeClass("nav-button-selected").addClass("button-unselected");
3146
+ }
3147
+ });
3148
+ };
3149
+
3150
+ function getFilter() {
3151
+ return WMStats.Utils.createInputFilter(_filterSelector);
3152
+ };
3153
+
3154
+
3155
+ function setTabs(selector) {
3156
+ var tabs = '<ul><li class="first"><a href="#category_view">Run</a></li>\
3157
+ <li><a href="#request_view">&#187 Requests</a></li>\
3158
+ <li><a href="#job_view">&#187 Jobs</a></li></ul>';
3159
+
3160
+ $(selector).append(tabs).addClass("tabs");
3161
+ $(selector + " ul").addClass("tabs-nav");
3162
+
3163
+ // add controller for this view
3164
+ function changeTab(event, data) {
3165
+ $(selector + ' li').removeClass("tabs-selected");
3166
+ $(selector + ' a[href="' + data.id() +'"]').parent().addClass("tabs-selected");
3167
+ }
3168
+ // viewModel -> view control
3169
+ vm.ActiveRequestPage.subscribe("view", changeTab);
3170
+
3171
+ // view -> viewModel control
3172
+ $(document).on('click', selector + " li a", function(event){
3173
+ vm.ActiveRequestPage.view(vmRegistry[this.hash]);
3174
+ //vm.CategoryView.category(vm.RunCategory);
3175
+ event.preventDefault();
3176
+ });
3177
+ };
3178
+
3179
+ return {
3180
+ setFilter: setFilter,
3181
+ setTabs: setTabs,
3182
+ setCategoryButton: setCategoryButton,
3183
+ setAllRequestButton: setAllRequestButton,
3184
+ setViewSwitchButton: setViewSwitchButton,
3185
+ getFilter: getFilter,
3186
+ requests: "requests",
3187
+ sites: "sites",
3188
+ run: "run"
3189
+ };
3190
+ }(jQuery);
3191
+ WMStats.namespace("ActiveRequestTable");
3192
+
3193
+ WMStats.ActiveRequestTable = function (requestData, containerDiv) {
3194
+
3195
+ var formatReqDetailUrl = WMStats.Utils.formatReqDetailUrl;
3196
+ var formatWorkloadSummarylUrl = WMStats.Utils.formatWorkloadSummarylUrl;
3197
+ var tableConfig = {
3198
+ "pageLength": 25,
3199
+ "scrollX": "",
3200
+ "columns": [
3201
+ {"title": "D",
3202
+ "defaultContent": 0,
3203
+ "render": function (data, type, row, meta) {
3204
+ if (type === "display") {
3205
+ return WMStats.Utils.formatDetailButton("detail", row.skipped);
3206
+ }
3207
+ if (row.skipped) {
3208
+ return 1;
3209
+ }
3210
+ }},
3211
+ {"title": "L",
3212
+ "defaultContent": 0,
3213
+ "render": function (data, type, row, meta) {
3214
+ return WMStats.Utils.formatDetailButton("drill");
3215
+ }},
3216
+ { "data": "workflow", "title": "workflow"},
3217
+ /*
3218
+ { "defaultContent": "new",
3219
+ "title": "status",
3220
+ "render": function (data, type, row, meta) {
3221
+
3222
+ var status = row.request_status[row.request_status.length -1].status;
3223
+ var reqSummary = requestData.getSummary(row.workflow);
3224
+ var totalJobs = reqSummary.getWMBSTotalJobs();
3225
+ if (totalJobs > 0) {
3226
+ if (reqSummary.getTotalSubmitted() > 0) {
3227
+ if (reqSummary.getJobStatus("submitted.running") > 0) {
3228
+ status = "running";
3229
+ } else {
3230
+ status = "submitted";
3231
+ }
3232
+
3233
+ } else {
3234
+ if (reqSummary.getTotalPaused() > 0) {
3235
+ status = "paused";
3236
+ }
3237
+ }
3238
+ }
3239
+ return status
3240
+ }
3241
+ },*/
3242
+ { "title": "status",
3243
+ "render": function (data, type, row, meta) {
3244
+ if (type === "display") {
3245
+ return formatWorkloadSummarylUrl(row.workflow,
3246
+ row.request_status[row.request_status.length -1].status);
3247
+ }
3248
+ return row.request_status[row.request_status.length -1].status;
3249
+ }
3250
+ },
3251
+ { "title": "duration",
3252
+ "render": function (data, type, row, meta) {
3253
+ if (type === "display") {
3254
+ var currentTime = Math.round(new Date().getTime() / 1000);
3255
+ var startTime = row.request_status[row.request_status.length -1].update_time;
3256
+ return WMStats.Utils.formatDuration(currentTime - startTime);
3257
+ }
3258
+ return row.request_status[row.request_status.length -1].update_time;
3259
+ },
3260
+ },
3261
+ { "defaultContent": 0,
3262
+ "title": "job progress",
3263
+ "render": function (data, type, row, meta) {
3264
+ var reqSummary = requestData.getSummary(row.workflow);
3265
+ var totalJobs = reqSummary.getWMBSTotalJobs() || 1;
3266
+ var result = (reqSummary.getJobStatus("success") + reqSummary.getTotalFailure()) /
3267
+ totalJobs * 100;
3268
+ return (result.toFixed(1) + "%");
3269
+ },
3270
+ "type": "num-fmt"
3271
+ },
3272
+ { "defaultContent": 0,
3273
+ "title": "submitted",
3274
+ "render": function (data, type, row, meta) {
3275
+ var result = requestData.getKeyValue(row.workflow, "status.submitted.first", 0);
3276
+ result += requestData.getKeyValue(row.workflow, "status.submitted.retry", 0);
3277
+ return result;
3278
+ }
3279
+ },
3280
+ { "defaultContent": 0,
3281
+ "title": "pending",
3282
+ "render": function (data, type, row, meta) {
3283
+ var result = requestData.getKeyValue(row.workflow, "status.submitted.pending", 0);
3284
+ return result;
3285
+ }
3286
+ },
3287
+ { "defaultContent": 0,
3288
+ "title": "running",
3289
+ "render": function (data, type, row, meta) {
3290
+ var result = requestData.getKeyValue(row.workflow, "status.submitted.running", 0);
3291
+ return result;
3292
+ }
3293
+ },
3294
+ { "defaultContent": 0,
3295
+ "title": "cool off ",
3296
+ "render": function (data, type, row, meta) {
3297
+ var reqSummary = requestData.getSummary(row.workflow);
3298
+ return reqSummary.getTotalCooloff();
3299
+ }
3300
+ },
3301
+ { "defaultContent": 0,
3302
+ "title": "paused",
3303
+ "render": function (data, type, row, meta) {
3304
+ var reqSummary = requestData.getSummary(row.workflow);
3305
+ return reqSummary.getTotalPaused();
3306
+ }
3307
+ },
3308
+ { "defaultContent": 0,
3309
+ "title": "failed",
3310
+ "render": function (data, type, row, meta) {
3311
+ var reqSummary = requestData.getSummary(row.workflow);
3312
+ return reqSummary.getTotalFailure();
3313
+ }
3314
+ },
3315
+ { "defaultContent": 0,
3316
+ "title": "run",
3317
+ "render": function (data, type, row, meta) {
3318
+ return requestData.getKeyValue(row.workflow, "run", 0);
3319
+ }
3320
+ }
3321
+ //TODO add more data (consult dataops)
3322
+ ]
3323
+ };
3324
+
3325
+ function runNumerDesc(a, b) {
3326
+ return (Number(b.run) - Number(a.run));
3327
+ }
3328
+
3329
+ tableConfig.data = requestData.getList(runNumerDesc);
3330
+
3331
+ return WMStats.Table(tableConfig).create(containerDiv, null);
3332
+ };
3333
+ WMStats.namespace("TaskSummaryTable");
3334
+
3335
+ WMStats.TaskSummaryTable = function (data, containerDiv) {
3336
+
3337
+ var taskData = data;
3338
+ var _activePageData = WMStats.ViewModel.ActiveRequestPage.data();
3339
+ var tableConfig = {
3340
+ "dom": '<"top"plf>rt<"bottom"ip>',
3341
+ "pageLength": 25,
3342
+ "columns": [
3343
+ { "render": function (data, type, row, meta) {
3344
+ if (type == 'display') {
3345
+ var taskList = row[0].split('/');
3346
+ return taskList[taskList.length - 1];
3347
+ }
3348
+ return row;
3349
+ }, "title": "task", "sWidth": "150px"},
3350
+ { "defaultContent": 0,
3351
+ "title": "created",
3352
+ "render": function (data, type, row, meta) {
3353
+ var taskSummary = taskData.getSummary(row[0]);
3354
+ var jobs = taskSummary.getWMBSTotalJobs();
3355
+ return jobs;
3356
+ }
3357
+ },
3358
+ { "defaultContent": 0,
3359
+ "title": "queued",
3360
+ "render": function (data, type, row, meta) {
3361
+ var taskSummary = taskData.getSummary(row[0]);
3362
+ var jobs = taskSummary.getTotalQueued();
3363
+ return jobs;
3364
+ }
3365
+ },
3366
+ { "defaultContent": 0,
3367
+ "title": "pending ",
3368
+ "render": function (data, type, row, meta) {
3369
+ var taskSummary = taskData.getSummary(row[0]);
3370
+ var jobs = taskSummary.getPending();
3371
+ return jobs;
3372
+ }
3373
+ },
3374
+ { "defaultContent": 0,
3375
+ "title": "running ",
3376
+ "render": function (data, type, row, meta) {
3377
+ var taskSummary = taskData.getSummary(row[0]);
3378
+ var jobs = taskSummary.getRunning();
3379
+ return jobs;
3380
+ }
3381
+ },
3382
+ { "defaultContent": 0,
3383
+ "title": "success ",
3384
+ "render": function (data, type, row, meta) {
3385
+ var taskSummary = taskData.getSummary(row[0]);
3386
+ var jobs = taskSummary.getJobStatus("success");
3387
+ return jobs;
3388
+ }
3389
+ },
3390
+ { "defaultContent": 0,
3391
+ "title": "failure ",
3392
+ "render": function (data, type, row, meta) {
3393
+ var taskSummary = taskData.getSummary(row[0]);
3394
+ var jobs = taskSummary.getTotalFailure();
3395
+ return jobs;
3396
+ }
3397
+ },
3398
+ { "defaultContent": 0,
3399
+ "title": "cool off ",
3400
+ "render": function (data, type, row, meta) {
3401
+ var taskSummary = taskData.getSummary(row[0]);
3402
+ var jobs = taskSummary.getTotalCooloff();
3403
+ return jobs;
3404
+ }
3405
+ },
3406
+ { "defaultContent": 0,
3407
+ "title": "paused",
3408
+ "render": function (data, type, row, meta) {
3409
+ var taskSummary = taskData.getSummary(row[0]);
3410
+ var jobs = taskSummary.getTotalPaused();
3411
+ return jobs;
3412
+ }
3413
+ },
3414
+ { "defaultContent": 0,
3415
+ "title": "events processed",
3416
+ "render": function (data, type, row, meta) {
3417
+ var outputEvents = taskData.getSummary(row[0]).getAvgEvents() || 0;
3418
+ return outputEvents;
3419
+ }
3420
+ },
3421
+ { "defaultContent": 0,
3422
+ "title": "lumi processed",
3423
+ "render": function (data, type, row, meta) {
3424
+ var outputLumis = taskData.getSummary(row[0]).getAvgLumis();
3425
+ return outputLumis;
3426
+ }
3427
+ }
3428
+ ],
3429
+ "order": [[1, 'asc']]
3430
+ };
3431
+
3432
+ var taskNamesArray = [];
3433
+ for (var taskNames in data.getData()){
3434
+ taskNamesArray.push([taskNames]);
3435
+ }
3436
+ tableConfig.data = taskNamesArray;
3437
+
3438
+ var filterConfig = {};
3439
+
3440
+ return WMStats.Table(tableConfig).create(containerDiv, filterConfig);
3441
+ };
3442
+
3443
+ (function() {
3444
+ var vm = WMStats.ViewModel;
3445
+ var E = WMStats.CustomEvents;
3446
+
3447
+ vm.JobView.subscribe("requestName", function() {
3448
+ // empty job detail and resubmission window first
3449
+ vm.JobDetail.keys(null, true);
3450
+ $(vm.JobDetail.id()).empty();
3451
+ $(vm.Resubmission.id()).empty();
3452
+ // need to create the lower level view
3453
+ var divSelector = vm.JobView.id() + " div.task_summary";
3454
+ var tasks = WMStats.ActiveRequestModel.getData().getTasks(vm.JobView.requestName());
3455
+ WMStats.TaskSummaryTable(tasks, divSelector);
3456
+ $(WMStats.Globals.Event).triggerHandler(E.AJAX_LOADING_START);
3457
+ });
3458
+
3459
+ })();
3460
+ WMStats.namespace("RunSummaryTable");
3461
+
3462
+ WMStats.RunSummaryTable = function (data, containerDiv) {
3463
+
3464
+ var tableConfig = {
3465
+ "pageLength": 25,
3466
+ "scrollX": "",
3467
+ "columns": [
3468
+ {"title": "D",
3469
+ "defaultContent": 0,
3470
+ "render": function (data, type, row, meta) {
3471
+ return WMStats.Utils.formatDetailButton("detail");
3472
+ }},
3473
+ {"title": "L",
3474
+ "defaultContent": 0,
3475
+ "render": function (data, type, row, meta) {
3476
+ return WMStats.Utils.formatDetailButton("drill");
3477
+ }},
3478
+ { "data": "key", "title": "run"},
3479
+ { "render": function (data, type, row, meta) {
3480
+ return row.summary.summaryStruct.numRequests;
3481
+ }, "title": "requests", "defaultContent": 0,
3482
+ },
3483
+ { "render": function (data, type, row, meta) {
3484
+ return row.summary.summaryStruct.runStatus;
3485
+ }, "title": "run status", "defaultContent": "Active",
3486
+ },
3487
+ { "render": function (data, type, row, meta) {
3488
+ return row.summary.getJobStatus("success");
3489
+ }, "title": "success", "defaultContent": 0,
3490
+ },
3491
+ { "render": function (data, type, row, meta) {
3492
+ return row.summary.getTotalFailure();
3493
+ }, "title": "failure", "defaultContent": 0,
3494
+ },
3495
+ { "defaultContent": 0,
3496
+ "title": "job progress",
3497
+ "render": function (data, type, row, meta) {
3498
+ var totalJobs = row.summary.getWMBSTotalJobs() || 1;
3499
+ var result = (row.summary.getJobStatus("success") +
3500
+ row.summary.getTotalFailure()) /
3501
+ totalJobs * 100;
3502
+ if (type === 'display') {
3503
+ return result.toFixed(1) + "%";
3504
+ }
3505
+ return result.toFixed(1);
3506
+ }
3507
+ },
3508
+ { "render": function (data, type, row, meta) {
3509
+ return row.summary.getJobStatus("submitted.pending");
3510
+ }, "title": "pending", "defaultContent": 0,
3511
+ },
3512
+ { "render": function (data, type, row, meta) {
3513
+ return row.summary.getJobStatus("submitted.running");
3514
+ }, "title": "running", "defaultContent": 0,
3515
+ },
3516
+ { "render": function (data, type, row, meta) {
3517
+ return row.summary.getTotalCooloff();
3518
+ }, "title": "cool off", "defaultContent": 0,
3519
+ },
3520
+ { "render": function (data, type, row, meta) {
3521
+ return row.summary.getTotalPaused();
3522
+ }, "title": "paused", "defaultContent": 0,
3523
+ }
3524
+ ]
3525
+ };
3526
+
3527
+ function runNumerDesc(a, b) {
3528
+ return (Number(b.key) - Number(a.key));
3529
+ }
3530
+
3531
+ tableConfig.data = data.getList(runNumerDesc);
3532
+
3533
+ var filterConfig = {};
3534
+
3535
+ return WMStats.Table(tableConfig).create(containerDiv,filterConfig);
3536
+ };
3537
+ //register mapping
3538
+ (function(vm){
3539
+ WMStats.CategorySummaryMap.add(vm.SiteCategory.name(), WMStats.SiteSummary);
3540
+ WMStats.CategoryTableMap.add(vm.SiteCategory.name(), WMStats.SiteSummaryTable);
3541
+
3542
+ WMStats.CategoryTableMap.add(vm.RequestView.categoryName,
3543
+ {'progress': WMStats.ActiveRequestTable});
3544
+ WMStats.CategorySummaryMap.add(vm.RunCategory.name(), WMStats.RunSummary);
3545
+ WMStats.CategoryTableMap.add(vm.RunCategory.name(), WMStats.RunSummaryTable);
3546
+ })(WMStats.ViewModel);WMStats.namespace('RequestDetailList');
3547
+ (function() {
3548
+
3549
+ var vm = WMStats.ViewModel;
3550
+ var transitionFormat = function(dataArray, maxLength, summaryStr) {
3551
+ var htmlstr = "";
3552
+ if (dataArray == undefined || dataArray.length == undefined ||
3553
+ dataArray.length <= maxLength) {
3554
+
3555
+ htmlstr += dataArray;
3556
+ } else {
3557
+ htmlstr += "<details> <summary>" + summaryStr +"</summary><ul>";
3558
+ for (var i in dataArray) {
3559
+ htmlstr += "<li> <b>" + dataArray[i].status + ":</b> " + WMStats.Utils.utcClock(new Date(dataArray[i].update_time * 1000)) + "</li>";
3560
+ }
3561
+ htmlstr += "</ul></details>";
3562
+ }
3563
+ return htmlstr;
3564
+ };
3565
+
3566
+ var format = function (requestStruct) {
3567
+ var htmlstr = '<div class="closingButton">X</div>';
3568
+ var reqDoc = requestStruct.requests;
3569
+ var reqSummary = requestStruct.summary;
3570
+
3571
+ htmlstr += "<div class='requestDetailBox'>";
3572
+ htmlstr += "<ul>";
3573
+ if (reqDoc) {
3574
+
3575
+ htmlstr += "<li><b>category:</b> " + requestStruct.key + "</li>";
3576
+ htmlstr += "<li><b>state transition</b> " + transitionFormat(reqDoc[requestStruct.key].request_status, 0, "State List") + "</li>";
3577
+ htmlstr += "<li><b>queued (first):</b> " + reqSummary.getJobStatus("queued.first", 0) + "</li>";
3578
+ htmlstr += "<li><b>queued (retried):</b> " + reqSummary.getJobStatus("queued.retry", 0) + "</li>";
3579
+ htmlstr += "<li><b>created:</b> " + reqSummary.getWMBSTotalJobs() + "</li>";
3580
+ htmlstr += "<li><b>paused jobs:</b> " + reqSummary.getTotalPaused() + "</li>";
3581
+ htmlstr += "<li><b>cooloff jobs:</b> " + reqSummary.getTotalCooloff() + "</li>";
3582
+ htmlstr += "<li><b>submitted:</b> " + reqSummary.getTotalSubmitted() + "</li>";
3583
+ htmlstr += "<li><b>pending:</b> " + reqSummary.getJobStatus("submitted.pending", 0) + "</li>";
3584
+ htmlstr += "<li><b>running:</b> " + reqSummary.getJobStatus("submitted.running", 0) + "</li>";
3585
+ htmlstr += "<li><b>failure:</b> " + reqSummary.getTotalFailure() + "</li>";
3586
+ htmlstr += "<li><b>success:</b> " + reqSummary.getJobStatus("success", 0) + "</li>";
3587
+ if (reqDoc.skipped) {
3588
+ htmlstr += "<li>" + WMStats.Utils.expandFormat(reqDoc.getSkippedDetail(), "Skipped Summary", siteStatusFormat) + "</li>";
3589
+ }
3590
+ }
3591
+ htmlstr += "</ul>";
3592
+ htmlstr += "</div>";
3593
+ return htmlstr;
3594
+ };
3595
+
3596
+ WMStats.RequestDetailList = function (workflow, containerDiv) {
3597
+ var allRequests = vm.ActiveRequestPage.data();
3598
+ var reqDoc = allRequests.getData(workflow);
3599
+ var reqSummary = allRequests.getSummary(workflow);
3600
+ var requests = {};
3601
+ requests[workflow] = reqDoc;
3602
+ var data = {key: workflow, requests: requests, summary: reqSummary};
3603
+ $(containerDiv).html(format(data));
3604
+ $(containerDiv).show("slide", {}, 500);
3605
+ vm.RequestDetail.open = true;
3606
+ };
3607
+
3608
+ var vm = WMStats.ViewModel;
3609
+
3610
+ vm.RequestDetail.subscribe("requestName", function() {
3611
+ WMStats.RequestDetailList(vm.RequestDetail.requestName(), vm.RequestDetail.id());
3612
+ });
3613
+ })();
3614
+ WMStats.namespace("RequestAlertGUI");
3615
+
3616
+ WMStats.RequestAlertGUI = function (requestData, containerDiv) {
3617
+
3618
+ function displayAlert(errorArray, title) {
3619
+ if (errorArray.length > 0) {
3620
+ htmlList += '<fieldset><legend>' + title + '</legend> <div><ul>';
3621
+
3622
+ for (var i in errorArray) {
3623
+ var workflow = errorArray[i].getName();
3624
+ var summary = errorArray[i].getSummary();
3625
+ var running = summary.getRunning();
3626
+ var pending = summary.getPending();
3627
+ var cooloff = summary.getTotalCooloff();
3628
+ var failure =summary.getTotalFailure();
3629
+ var success = summary.getJobStatus("success");
3630
+ var sPaused = summary.getJobStatus("paused.submit");
3631
+ var jPaused = summary.getJobStatus("paused.job");
3632
+ var cPaused = summary.getJobStatus("paused.create");
3633
+ var lastState = errorArray[i].getLastStateAndTime();
3634
+ var lastStatus = "N/A";
3635
+ var lastUpdate = "N/A";
3636
+ if (lastState !== null) {
3637
+ lastStatus = lastState.status;
3638
+ lastUpdate = WMStats.Utils.utcClock(new Date(lastState.update_time * 1000));
3639
+ }
3640
+ htmlList += ('<li> <a class="requestAlert">' + workflow + "</a>: status:" +
3641
+ lastStatus + " (" + lastUpdate + "), cooloff " + cooloff +
3642
+ " submit paused:" + sPaused + " job paused:" + jPaused +
3643
+ " create paused:" + cPaused +
3644
+ " failure:" + failure + " success:" + success +
3645
+ " running:" + running + " pending:" + pending + '</li>');
3646
+ }
3647
+ htmlList += "</ul></div></fieldset>";
3648
+
3649
+ errorFlag = true;
3650
+ };
3651
+ };
3652
+
3653
+
3654
+ function mapType(workflowName){
3655
+ // TODO: this is a hack to get jobType rely on the conventsion
3656
+ // need a better solution
3657
+ var workflowType = workflowName.split("_")[0].toLowerCase();
3658
+ if (workflowType == "express") {
3659
+ return 1;
3660
+ } else if (workflowType == "repack") {
3661
+ return 2;
3662
+ } else if (workflowType == "promptreco") {
3663
+ return 3;
3664
+ }
3665
+ return 4;
3666
+ }
3667
+
3668
+ function alertSort(a, b) {
3669
+ var aRun = a.run;
3670
+ var bRun = b.run;
3671
+ if (aRun == bRun) {
3672
+ var aType = mapType(a.workflow);
3673
+ var bType = mapType(b.workflow);
3674
+ if ( aType == bType){
3675
+ var aJobs = a.getSummary().getTotalPaused() + a.getSummary().getTotalCooloff();
3676
+ var bJobs = b.getSummary().getTotalPaused() + b.getSummary().getTotalCooloff();
3677
+ return bJobs - aJobs;
3678
+ } else {
3679
+ return aType - bType;
3680
+ }
3681
+ } else {
3682
+ return aRun - bRun;
3683
+ }
3684
+ }
3685
+
3686
+ var alertRequests = requestData.getRequestAlerts();
3687
+ var errorFlag = false;
3688
+
3689
+ var htmlList = "";
3690
+
3691
+ if (alertRequests.cPaused.length > 0) {
3692
+ var paused = alertRequests.cPaused.sort(alertSort);
3693
+ displayAlert(paused, "create paused");
3694
+ };
3695
+ if (alertRequests.sPaused.length > 0) {
3696
+ var paused = alertRequests.sPaused.sort(alertSort);
3697
+ displayAlert(paused, "submit paused");
3698
+ };
3699
+ if (alertRequests.jPaused.length > 0) {
3700
+ var paused = alertRequests.jPaused.sort(alertSort);
3701
+ displayAlert(paused, "job paused");
3702
+ };
3703
+ if (alertRequests.configError.length > 0) {
3704
+ var configError = alertRequests.configError.sort(alertSort);
3705
+ displayAlert(configError, "Config Error");
3706
+ };
3707
+ if (alertRequests.siteError.length > 0) {
3708
+ var siteError = alertRequests.siteError.sort(alertSort);
3709
+ displayAlert(siteError, "Site Error");
3710
+
3711
+ };
3712
+
3713
+
3714
+ $(containerDiv).addClass("request_error_box");
3715
+ if (errorFlag) {
3716
+ $(containerDiv).removeClass("stable warning").addClass("error").html(htmlList);
3717
+ } else {
3718
+ $(containerDiv).removeClass("warning error").addClass("stable").html("request alarm");
3719
+ }
3720
+ };
3721
+
3722
+ // controller for request alert view
3723
+ (function() {
3724
+
3725
+ var vm = WMStats.ViewModel;
3726
+ vm.RequestAlertPage.subscribe("data", function(){
3727
+ var divSelector = vm.RequestAlertPage.id() + " div.summary_data";
3728
+ WMStats.RequestAlertGUI(vm.RequestAlertPage.data(), divSelector);
3729
+ });
3730
+
3731
+ $(document).on('click', 'a.requestAlert', function() {
3732
+ var workflow = $(this).text();
3733
+ vm.JobView.requestName(workflow);
3734
+ //TODO: this cause calling one more time for retrieving data
3735
+ vm.ActiveRequestPage.view(vm.JobView);
3736
+ vm.page(vm.ActiveRequestPage);
3737
+
3738
+ $(this).addClass('reviewed');
3739
+ });
3740
+ })();
3741
+
3742
+ WMStats.namespace('CategoryDetailList');
3743
+ (function() {
3744
+ var format = function (requestStruct) {
3745
+ var htmlstr = '';
3746
+ var reqDoc = requestStruct.requests;
3747
+ var reqSummary = requestStruct.summary;
3748
+
3749
+ htmlstr += "<div class='requestDetailBox'>";
3750
+ htmlstr += "<ul>";
3751
+ if (reqDoc) {
3752
+
3753
+ htmlstr += "<li><b>category:</b> " + requestStruct.key + "</li>";
3754
+ htmlstr += "<li><b>queued (first):</b> " + reqSummary.getJobStatus("queued.first", 0) + "</li>";
3755
+ htmlstr += "<li><b>queued (retried):</b> " + reqSummary.getJobStatus("queued.retry", 0) + "</li>";
3756
+ htmlstr += "<li><b>created:</b> " + reqSummary.getWMBSTotalJobs() + "</li>";
3757
+ htmlstr += "<li><b>paused jobs:</b> " + reqSummary.getTotalPaused() + "</li>";
3758
+ htmlstr += "<li><b>cooloff jobs:</b> " + reqSummary.getTotalCooloff() + "</li>";
3759
+ htmlstr += "<li><b>submitted:</b> " + reqSummary.getTotalSubmitted() + "</li>";
3760
+ htmlstr += "<li><b>pending:</b> " + reqSummary.getJobStatus("submitted.pending", 0) + "</li>";
3761
+ htmlstr += "<li><b>running:</b> " + reqSummary.getJobStatus("submitted.running", 0) + "</li>";
3762
+ htmlstr += "<li><b>failure:</b> " + reqSummary.getTotalFailure() + "</li>";
3763
+ htmlstr += "<li><b>success:</b> " + reqSummary.getJobStatus("success", 0) + "</li>";
3764
+ }
3765
+ htmlstr += "</ul>";
3766
+ htmlstr += "</div>";
3767
+ return htmlstr;
3768
+ };
3769
+
3770
+ WMStats.CategoryDetailList = function (data, containerDiv) {
3771
+ $(containerDiv).html(format(data));
3772
+ };
3773
+
3774
+ var vm = WMStats.ViewModel;
3775
+
3776
+ vm.CategoryDetail.subscribe("data", function() {
3777
+ WMStats.CategoryDetailList(vm.CategoryDetail.data(), vm.CategoryDetail.id());
3778
+ });
3779
+ })();
3780
+ WMStats.namespace('RequestSummaryList');
3781
+ (function() {
3782
+ var format = function (summary) {
3783
+ var summaryStruct = summary.summaryStruct;
3784
+ var htmlstr = "";
3785
+ htmlstr += "<div class='requestSummaryBox'>";
3786
+ htmlstr += "<ul>";
3787
+ htmlstr += "<li><b>requests:</b> " + summary.summaryStruct.length + "</li>";
3788
+ htmlstr += "<li><b>created:</b> " + summary.getWMBSTotalJobs() + "</li>";
3789
+ htmlstr += "<li><b>cooloff:</b> " + summary.getTotalCooloff() + "</li>";
3790
+ htmlstr += "<li><b>success:</b> " + summary.getJobStatus('success') + "</li>";
3791
+ htmlstr += "<li><b>failure:</b> " + summary.getTotalFailure() + "</li>";
3792
+ htmlstr += "<li><b>queued:</b> " + summary.getTotalQueued() + "</li>";
3793
+ htmlstr += "<li><b>running:</b> " + summary.getJobStatus('submitted.running') + "</li>";
3794
+ htmlstr += "<li><b>pending:</b> " + summary.getJobStatus('submitted.pending') + "</li>";
3795
+ htmlstr += "</ul>";
3796
+ htmlstr += "</div>";
3797
+ return htmlstr;
3798
+ };
3799
+
3800
+ WMStats.RequestSummaryList = function (data, containerDiv) {
3801
+ $(containerDiv).html(format(data));
3802
+ };
3803
+
3804
+ var vm = WMStats.ViewModel;
3805
+
3806
+ vm.ActiveRequestPage.subscribe("data", function() {
3807
+ var filteredData = vm.ActiveRequestPage.data();
3808
+ WMStats.RequestSummaryList(filteredData.getSummary(), "#filter_summary");
3809
+ });
3810
+ })();
3811
+ WMStats.namespace('RequestDataList');
3812
+ (function() {
3813
+ var format = function (summary) {
3814
+ var summaryStruct = summary.summaryStruct;
3815
+ var htmlstr = "";
3816
+ htmlstr += "<div class='requestSummaryBox'>";
3817
+ htmlstr += "<ul>";
3818
+ htmlstr += "<li> requests: " + summary.summaryStruct.length + "</li>";
3819
+ htmlstr += "<li> total created: " + summary.getWMBSTotalJobs() + "</li>";
3820
+ htmlstr += "<li> paused: " + summary.getTotalPaused() + "</li>";
3821
+ htmlstr += "<li> cooloff: " + summary.getTotalCooloff() + "</li>";
3822
+ htmlstr += "<li> success: " + summary.getJobStatus('success') + "</li>";
3823
+ htmlstr += "<li> failure: " + summary.getTotalFailure() + "</li>";
3824
+ htmlstr += "<li> queued: " + summary.getTotalQueued() + "</li>";
3825
+ htmlstr += "<li> running: " + summary.getJobStatus('submitted.running') + "</li>";
3826
+ htmlstr += "<li> pending: " + summary.getJobStatus('submitted.pending') + "</li>";
3827
+ htmlstr += "</ul>";
3828
+ htmlstr += "</div>";
3829
+ return htmlstr;
3830
+ };
3831
+
3832
+ WMStats.RequestDataList = function (data, containerDiv) {
3833
+ $(containerDiv).html(format(data));
3834
+ };
3835
+ })();
3836
+ WMStats.namespace("_ModelBase");
3837
+
3838
+ WMStats._ModelBase = function(initView, options, dataStruct) {
3839
+
3840
+ this._initialView = initView;
3841
+ this._options = options;
3842
+ this._dataStruct = dataStruct;
3843
+ this._trigger = null;
3844
+ this._data = null;
3845
+ // default _dbSource is wmstats database
3846
+ this._dbSource = WMStats.Couch;
3847
+ };
3848
+
3849
+ WMStats._ModelBase.prototype = {
3850
+
3851
+ setTrigger: function(triggerName) {
3852
+ this._trigger = triggerName;
3853
+ },
3854
+
3855
+ getData: function() {
3856
+ return this._data;
3857
+ },
3858
+
3859
+ dataReady: function(data) {
3860
+ this._data = this._dataStruct(data);
3861
+ if (this._trigger instanceof Array){
3862
+ for (var i in this._trigger) {
3863
+ jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i], this._data);
3864
+ }
3865
+ }else{
3866
+ jQuery(WMStats.Globals.Event).triggerHandler(this._trigger, this._data);
3867
+ }
3868
+
3869
+ },
3870
+
3871
+ retrieveData: function (view, options) {
3872
+ if (options === undefined){
3873
+ var options = this._options;
3874
+ }
3875
+ if (view === undefined) {
3876
+ var view = this._initialView;
3877
+ }
3878
+
3879
+ if (view === "allDocs") {
3880
+ return this.retrieveAllDocs(options);
3881
+ } else if (view === "doc") {
3882
+ return this.retrieveDoc(options);
3883
+ }else {
3884
+ return this._dbSource.view(view, options,
3885
+ jQuery.proxy(this.callback, this));
3886
+ }
3887
+
3888
+ },
3889
+
3890
+ retrieveAllDocs: function (options) {
3891
+ if (options === undefined){
3892
+ var options = this._options;
3893
+ }
3894
+ return this._dbSource.allDocs(options, jQuery.proxy(this.callback, this));
3895
+ },
3896
+
3897
+ retrieveDoc: function (docID) {
3898
+ return this._dbSource.openDoc(docID, jQuery.proxy(this.callback, this));
3899
+ },
3900
+
3901
+ setDBSource: function(dbSource) {
3902
+ this._dbSource = dbSource;
3903
+ },
3904
+ callback: function (data) {
3905
+ // use current object context
3906
+ return this.dataReady(data);
3907
+ },
3908
+
3909
+ clearData: function () {
3910
+ delete this._data;
3911
+ }
3912
+ };
3913
+ WMStats.namespace("_AjaxModelBase");
3914
+
3915
+ WMStats._AjaxModelBase = function(uri, dataStruct) {
3916
+ this._uri = uri;
3917
+ this._dataStruct = dataStruct;
3918
+ this._data = null;
3919
+ // default _dbSource is wmstats database
3920
+ };
3921
+
3922
+ WMStats._AjaxModelBase.prototype = {
3923
+
3924
+ setTrigger: function(triggerName) {
3925
+ this._trigger = triggerName;
3926
+ },
3927
+
3928
+ getData: function() {
3929
+ return this._data;
3930
+ },
3931
+
3932
+ dataReady: function(data) {
3933
+ this._data = this._dataStruct(data);
3934
+ if (this._trigger instanceof Array){
3935
+ for (var i in this._trigger) {
3936
+ jQuery(WMStats.Globals.Event).triggerHandler(this._trigger[i], this._data);
3937
+ }
3938
+ }else{
3939
+ jQuery(WMStats.Globals.Event).triggerHandler(this._trigger, this._data);
3940
+ }
3941
+
3942
+ },
3943
+
3944
+ retrieveData: function(args) {
3945
+ $.ajax(this._uri,
3946
+ {type: 'GET',
3947
+ //accept: {json: "application/json"},
3948
+ //contentType: "application/json",
3949
+ headers: {"Accept": "application/json"},
3950
+ processData: false,
3951
+ data: args || "",
3952
+ success: jQuery.proxy(this.callback, this),
3953
+ error: function(jqXHR, textStatus, errorThrown){
3954
+ console.log("call fails, response: " + jqXHR.responseText);
3955
+ }
3956
+ });
3957
+ },
3958
+
3959
+ callback: function (data, textStatus, jqXHR) {
3960
+ // use current object context
3961
+ return this.dataReady(data);
3962
+ },
3963
+
3964
+ clearData: function () {
3965
+ delete this._data;
3966
+ }
3967
+ };
3968
+ WMStats.namespace("_RequestModelBase");
3969
+
3970
+ WMStats._RequestModelBase = function(initView, options) {
3971
+
3972
+ this._initialView = initView || 'bystatus';
3973
+ this._options = options || {'include_docs': true};
3974
+ this._data = null;
3975
+ this._trigger = "requestReady";
3976
+ this._dbSource = WMStats.Couch;
3977
+ };
3978
+ //Class method
3979
+ WMStats._RequestModelBase.keysFromIDs = function(data) {
3980
+ var keys = [];
3981
+ for (var i in data.rows){
3982
+ if (data.rows[i].value && data.rows[i].value.id) {
3983
+ keys.push(data.rows[i].value.id);
3984
+ } else {
3985
+ keys.push(data.rows[i].id);
3986
+ }
3987
+ }
3988
+ return keys;
3989
+ };
3990
+
3991
+ WMStats._RequestModelBase.requestAgentUrlKeys = function(requestList, requestAgentData) {
3992
+ var keys = {};
3993
+ var requestAgentUrlList = [];
3994
+ for (var i in requestAgentData.rows){
3995
+ var request = requestAgentData.rows[i].key[0];
3996
+ if (!keys[request]) {
3997
+ keys[request] = [];
3998
+ }
3999
+ keys[request].push(requestAgentData.rows[i].key[1]);
4000
+ }
4001
+
4002
+ for (var j=0; j < requestList.length; j++) {
4003
+ for (var k in keys[requestList[j]]) {
4004
+ requestAgentUrlList.push([requestList[j], keys[requestList[j]][k]]);
4005
+ }
4006
+ }
4007
+ return requestAgentUrlList;
4008
+ };
4009
+
4010
+ WMStats._RequestModelBase.prototype = {
4011
+
4012
+ setInitView: function(initView) {
4013
+ this._initialView = initView;
4014
+ },
4015
+
4016
+ setTrigger: function(triggerName) {
4017
+ this._trigger = triggerName;
4018
+ },
4019
+
4020
+ setDBSource: function(dbSource) {
4021
+ this._dbSource = dbSource;
4022
+ },
4023
+
4024
+ // deprecated
4025
+ getData: function() {
4026
+ return this._data;
4027
+ },
4028
+
4029
+ getRequests: function() {
4030
+ return this._data;
4031
+ },
4032
+
4033
+ _getRequestDetailsAndTriggerEvent: function (agentIDs, reqmgrData, objPtr) {
4034
+ var options = {'keys': WMStats._RequestModelBase.keysFromIDs(agentIDs), 'reduce': false,
4035
+ 'include_docs': true};
4036
+ WMStats.Couch.allDocs(options,
4037
+ function(agentData) {
4038
+ //start loading sign disable the filter
4039
+ jQuery(WMStats.Globals.Event).triggerHandler(WMStats.CustomEvents.LOADING_DIV_START);
4040
+ // combine reqmgrData(reqmgr_request) and
4041
+ // agent_request(agentData) data
4042
+ var requestCache = WMStats.Requests();
4043
+ requestCache.updateBulkRequests(reqmgrData.rows);
4044
+ requestCache.updateBulkRequests(agentData.rows);
4045
+
4046
+ // set the data cache
4047
+ objPtr._data = requestCache;
4048
+ // trigger custom events
4049
+ jQuery(WMStats.Globals.Event).triggerHandler(objPtr._trigger, objPtr._data);
4050
+ });
4051
+ },
4052
+
4053
+ _getLatestRequestAgentUrlAndCreateTable: function (overviewData, keys, objPtr) {
4054
+ var options = {"keys": keys, "reduce": false};
4055
+ WMStats.Couch.view('latestRequest', options,
4056
+ function(agentIDs) {
4057
+ objPtr._getRequestDetailsAndTriggerEvent(agentIDs, overviewData, objPtr);
4058
+ });
4059
+ },
4060
+
4061
+ _getLatestRequestIDsAndCreateTable: function (overviewData, objPtr) {
4062
+ /*
4063
+ * get list of request ids first from the couchDB then
4064
+ * get the details of the requests.
4065
+ */
4066
+ var options = {"reduce": true, "group": true, "descending": true};
4067
+ var requestList = WMStats._RequestModelBase.keysFromIDs(overviewData);
4068
+ WMStats.Couch.view('requestAgentUrl', options,
4069
+ function(requestAgentUrlData) {
4070
+ var keys = WMStats._RequestModelBase.requestAgentUrlKeys(requestList, requestAgentUrlData);
4071
+ objPtr._getLatestRequestAgentUrlAndCreateTable(overviewData, keys, objPtr);
4072
+ });
4073
+ },
4074
+
4075
+ retrieveData: function (viewName, options) {
4076
+
4077
+ if (!viewName) {viewName = this._initialView;}
4078
+ if (!options) {options = WMStats.Utils.cloneObj(this._options);}
4079
+ var objPtr = this;
4080
+ if (viewName == "allDocs") {
4081
+ this._dbSource.allDocs(options, function (overviewData) {
4082
+ objPtr._getLatestRequestIDsAndCreateTable(overviewData, objPtr);
4083
+ });
4084
+ } else {
4085
+ this._dbSource.view(viewName, options, function (overviewData) {
4086
+ objPtr._getLatestRequestIDsAndCreateTable(overviewData, objPtr);
4087
+ });
4088
+ }
4089
+ },
4090
+
4091
+ clearRequests: function () {
4092
+ delete this._data;
4093
+ }
4094
+ };
4095
+ WMStats.namespace("JobSummaryModel");
4096
+
4097
+ WMStats.JobSummaryModel = new WMStats._ModelBase('jobsByStatusWorkflow', {},
4098
+ WMStats.JobSummary);
4099
+
4100
+ WMStats.JobSummaryModel.setRequest = function(workflow) {
4101
+ this._options = {'reduce': true, 'group_level': 8, 'startkey':[workflow],
4102
+ 'endkey':[workflow, {}]};
4103
+ };
4104
+ WMStats.JobSummaryModel.setTrigger([WMStats.CustomEvents.JOB_SUMMARY_READY,
4105
+ WMStats.CustomEvents.LOADING_DIV_END]);
4106
+
4107
+ /*
4108
+ WMStats.JobSummaryModel.retrieveData = function(workflow) {
4109
+ WMStats.JobSummaryModel.setRequest(workflow);
4110
+ WMStats.JobSummaryModel.prototype.retrieveData();
4111
+ }
4112
+ */WMStats.namespace("JobDetailModel");
4113
+
4114
+ WMStats.JobDetailModel = new WMStats._ModelBase('jobsByStatusWorkflow', {},
4115
+ WMStats.JobDetails);
4116
+
4117
+ WMStats.JobDetailModel.setOptions = function(summary) {
4118
+ var startkey = null;
4119
+ if ((typeof summary.site) == "object") {
4120
+ startkey = [summary.workflow, summary.task, summary.status, summary.exitCode];
4121
+ } else if (!summary.acdcURL) {
4122
+ startkey = [summary.workflow, summary.task, summary.status, summary.exitCode, summary.site];
4123
+ } else {
4124
+ startkey = [summary.workflow, summary.task, summary.status, summary.exitCode, summary.site, summary.acdcURL];
4125
+ }
4126
+ this._options= {'include_docs': true, 'reduce': false,
4127
+ 'startkey': startkey,
4128
+ 'endkey': [summary.workflow, summary.task, summary.status, summary.exitCode, summary.site, {}],
4129
+ 'limit': 10};
4130
+ };
4131
+
4132
+ WMStats.JobDetailModel.setTrigger([WMStats.CustomEvents.JOB_DETAIL_READY,
4133
+ WMStats.CustomEvents.LOADING_DIV_END]);
4134
+ WMStats.namespace("AgentModel");
4135
+ WMStats.AgentModel = new WMStats._ModelBase('agentInfo', {}, WMStats.Agents);
4136
+ WMStats.AgentModel.setTrigger(WMStats.CustomEvents.AGENTS_LOADED);
4137
+ WMStats.namespace("WorkloadSummaryModel");
4138
+
4139
+ WMStats.WorkloadSummaryModel = new WMStats._ModelBase('',
4140
+ {"reduce": false, 'include_docs': true},
4141
+ WMStats.WorkloadSummary);
4142
+
4143
+ WMStats.WorkloadSummaryModel.setDBSource(WMStats.WorkloadSummaryCouch);
4144
+ WMStats.WorkloadSummaryModel.setTrigger(WMStats.CustomEvents.WORKLOAD_SUMMARY_READY);
4145
+ WMStats.namespace("HistoryModel");
4146
+
4147
+ WMStats.HistoryModel = new WMStats._ModelBase('requestHistory', {}, WMStats.History);
4148
+
4149
+ WMStats.HistoryModel.setOptions = function() {
4150
+ var current = Math.round((new Date()).getTime() / 1000);
4151
+ this._options= {'reduce': false,
4152
+ 'startkey': [current, {}],
4153
+ 'endkey': [current - 600*60*24],
4154
+ 'include_docs': true,
4155
+ 'descending': true};
4156
+ };
4157
+
4158
+ WMStats.HistoryModel.setTrigger(WMStats.CustomEvents.HISTORY_LOADED);
4159
+ WMStats.namespace("ActiveRequestModel");
4160
+ WMStats.ActiveRequestModel = function() {
4161
+
4162
+ var uri = "/t0_reqmon/data/requestcache";
4163
+ var reqModel = new WMStats._AjaxModelBase(uri, WMStats.Requests);
4164
+ reqModel.setTrigger(WMStats.CustomEvents.REQUESTS_LOADED);
4165
+
4166
+ return reqModel;
4167
+ }();
4168
+ WMStats.namespace("RequestModel");
4169
+ //TODO: specify tableConfig and filterConfig for T0.
4170
+ WMStats.RequestModel = new WMStats._RequestModelBase();
4171
+ WMStats.namespace("RequestSearchModel");
4172
+
4173
+ WMStats.RequestSearchModel = new WMStats._ModelBase('',
4174
+ {"reduce": false, 'include_docs': true},
4175
+ WMStats.WorkloadSummary);
4176
+
4177
+ WMStats.RequestSearchModel.setDBSource(WMStats.T0Couch);
4178
+ WMStats.RequestSearchModel.setTrigger(WMStats.CustomEvents.WORKLOAD_SUMMARY_READY);WMStats.namespace("RequestLogDetailModel");
4179
+ // don't set the initial view - it is only used for doc retrieval
4180
+ WMStats.RequestLogDetailModel = new WMStats._ModelBase('', {},
4181
+ WMStats.LogMessage);
4182
+
4183
+ WMStats.RequestLogDetailModel.setDBSource(WMStats.T0LogDBCouch);
4184
+ WMStats.RequestLogDetailModel.setTrigger(WMStats.CustomEvents.ERROR_LOG_LOADED);
4185
+
4186
+ $(WMStats.Globals.Event).on(WMStats.CustomEvents.LOG_LOADED,
4187
+ function(event) {
4188
+ var options = {"include_docs": true};
4189
+
4190
+ var logData = WMStats.RequestLogModel.getData();
4191
+ options.keys = logData.getErrorLogIDs();
4192
+
4193
+ WMStats.RequestLogDetailModel.retrieveData("allDocs", options);
4194
+ });WMStats.namespace("RequestLogModel");
4195
+ // don't set the initial view - it is only used for doc retrieval
4196
+ WMStats.RequestLogModel = new WMStats._ModelBase('', {},
4197
+ WMStats.LogDBData);
4198
+
4199
+ WMStats.RequestLogModel.setDBSource(WMStats.T0LogDBCouch);
4200
+ WMStats.RequestLogModel.setTrigger(WMStats.CustomEvents.LOG_LOADED);
4201
+
4202
+ $(WMStats.Globals.Event).on(WMStats.CustomEvents.REQUESTS_LOADED,
4203
+ function(event) {
4204
+ var options = {"stale": "update_after"};
4205
+
4206
+ WMStats.RequestLogModel.retrieveData("logByRequest", options);
4207
+ });WMStats.namespace("GenericController");
4208
+
4209
+ (function($) {
4210
+ var vm = WMStats.ViewModel;
4211
+ // collapsible bar
4212
+ function closeRequestDetail() {
4213
+ $("#request_view div.detail_data").hide('puff', {}, 500);
4214
+ $("#acdc_submission").hide('puff', {}, 500);
4215
+ vm.RequestDetail.open = false;
4216
+ };
4217
+
4218
+ $(document).on('click', 'div.caption img', function(event){
4219
+ $(this).parent('div.caption').siblings('div.body').toggle('nomal');
4220
+ });
4221
+
4222
+ $(document).on('click', 'div.closingButton', function(event){
4223
+ //$(this).parent('div').hide('puff', {}, 500);
4224
+ //TODO: generalize to all the button not just for request detail
4225
+ closeRequestDetail();
4226
+ event.preventDefault();
4227
+ });
4228
+
4229
+ $(document).keyup(function(event) {
4230
+ if (vm.RequestDetail.open && event.keyCode == 27) {
4231
+ closeRequestDetail();
4232
+ event.preventDefault();
4233
+ }
4234
+ });
4235
+
4236
+
4237
+ WMStats.GenericController.switchDiv = function (showSelector, hideSelectors) {
4238
+ for (var i in hideSelectors) {
4239
+ $(hideSelectors[i]).hide();
4240
+ }
4241
+ $(showSelector).show();
4242
+ };
4243
+
4244
+ })(jQuery);
4245
+ WMStats.namespace("ActiveRequestController");
4246
+
4247
+ (function($){
4248
+
4249
+ var E = WMStats.CustomEvents;
4250
+
4251
+ var vm = WMStats.ViewModel;
4252
+
4253
+ $(WMStats.Globals.Event).on(E.REQUESTS_LOADED,
4254
+ function(event) {
4255
+ vm.propagateUpdate();
4256
+ });
4257
+
4258
+ $(WMStats.Globals.Event).on(E.AGENTS_LOADED,
4259
+ function(event, agentData) {
4260
+ vm.propagateUpdate();
4261
+ });
4262
+
4263
+ $(WMStats.Globals.Event).on(E.ERROR_LOG_LOADED,
4264
+ function(event, logData) {
4265
+ vm.propagateUpdate();
4266
+ });
4267
+
4268
+ $(WMStats.Globals.Event).on(E.JOB_SUMMARY_READY,
4269
+ function(event, data) {
4270
+ vm.JobView.updateDataAndChild(data);
4271
+ //vm.AlertJobView.updateDataAndChild(data);
4272
+ });
4273
+
4274
+ $(WMStats.Globals.Event).on(E.JOB_DETAIL_READY,
4275
+ function(event, data) {
4276
+ vm.JobDetail.data(data);
4277
+ });
4278
+
4279
+ $(WMStats.Globals.Event).on(E.RESUBMISSION_SUMMARY_READY,
4280
+ function(event, data) {
4281
+ var rData = vm.Resubmission.formatResubmissionData(data);
4282
+ vm.Resubmission.data(rData);
4283
+ });
4284
+
4285
+ $(WMStats.Globals.Event).on(E.LOADING_DIV_START,
4286
+ function(event, data) {
4287
+ // TODO: need to update when partial_request happens)
4288
+ var count = vm.ActiveRequestPage.refreshCount();
4289
+ vm.ActiveRequestPage.refreshCount(count + 1);
4290
+ if (vm.page() === vm.ActiveRequestPage && vm.ActiveRequestPage.refreshCount() === 1) {
4291
+ $('#loading_page').show();
4292
+ }
4293
+ });
4294
+
4295
+ $(WMStats.Globals.Event).on(E.LOADING_DIV_END,
4296
+ function(event, data) {
4297
+ $('#loading_page').hide();
4298
+ });
4299
+
4300
+ $(WMStats.Globals.Event).on(E.AJAX_LOADING_START,
4301
+ function(event, data) {
4302
+ $('#loading_page').show();
4303
+ });
4304
+
4305
+ })(jQuery);
4306
+ WMStats.namespace("WorkloadSummaryController");
4307
+
4308
+ (function($){
4309
+ var vm = WMStats.ViewModel;
4310
+ var E = WMStats.CustomEvents;
4311
+ $(WMStats.Globals.Event).on(E.WORKLOAD_SUMMARY_READY,
4312
+ function(event, data) {
4313
+ var data = WMStats.RequestSearchModel.getData();
4314
+ vm.SearchPage.data(data);
4315
+ });
4316
+
4317
+ })(jQuery);