msmonitor 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.
- Utils/CPMetrics.py +270 -0
- Utils/CertTools.py +62 -0
- Utils/EmailAlert.py +50 -0
- Utils/ExtendedUnitTestCase.py +62 -0
- Utils/FileTools.py +182 -0
- Utils/IteratorTools.py +80 -0
- Utils/MathUtils.py +31 -0
- Utils/MemoryCache.py +119 -0
- Utils/Patterns.py +24 -0
- Utils/Pipeline.py +137 -0
- Utils/PortForward.py +97 -0
- Utils/ProcessStats.py +103 -0
- Utils/PythonVersion.py +17 -0
- Utils/Signals.py +36 -0
- Utils/TemporaryEnvironment.py +27 -0
- Utils/Throttled.py +227 -0
- Utils/Timers.py +130 -0
- Utils/Timestamps.py +86 -0
- Utils/TokenManager.py +143 -0
- Utils/Tracing.py +60 -0
- Utils/TwPrint.py +98 -0
- Utils/Utilities.py +308 -0
- Utils/__init__.py +11 -0
- WMCore/Algorithms/Alarm.py +39 -0
- WMCore/Algorithms/MathAlgos.py +274 -0
- WMCore/Algorithms/MiscAlgos.py +67 -0
- WMCore/Algorithms/ParseXMLFile.py +115 -0
- WMCore/Algorithms/Permissions.py +27 -0
- WMCore/Algorithms/Singleton.py +58 -0
- WMCore/Algorithms/SubprocessAlgos.py +129 -0
- WMCore/Algorithms/__init__.py +7 -0
- WMCore/Cache/GenericDataCache.py +98 -0
- WMCore/Cache/WMConfigCache.py +572 -0
- WMCore/Cache/__init__.py +0 -0
- WMCore/Configuration.py +651 -0
- WMCore/DAOFactory.py +47 -0
- WMCore/DataStructs/File.py +177 -0
- WMCore/DataStructs/Fileset.py +140 -0
- WMCore/DataStructs/Job.py +182 -0
- WMCore/DataStructs/JobGroup.py +142 -0
- WMCore/DataStructs/JobPackage.py +49 -0
- WMCore/DataStructs/LumiList.py +734 -0
- WMCore/DataStructs/Mask.py +219 -0
- WMCore/DataStructs/MathStructs/ContinuousSummaryHistogram.py +197 -0
- WMCore/DataStructs/MathStructs/DiscreteSummaryHistogram.py +92 -0
- WMCore/DataStructs/MathStructs/SummaryHistogram.py +117 -0
- WMCore/DataStructs/MathStructs/__init__.py +0 -0
- WMCore/DataStructs/Pickleable.py +24 -0
- WMCore/DataStructs/Run.py +256 -0
- WMCore/DataStructs/Subscription.py +175 -0
- WMCore/DataStructs/WMObject.py +47 -0
- WMCore/DataStructs/WorkUnit.py +112 -0
- WMCore/DataStructs/Workflow.py +60 -0
- WMCore/DataStructs/__init__.py +8 -0
- WMCore/Database/CMSCouch.py +1349 -0
- WMCore/Database/ConfigDBMap.py +29 -0
- WMCore/Database/CouchUtils.py +118 -0
- WMCore/Database/DBCore.py +198 -0
- WMCore/Database/DBCreator.py +113 -0
- WMCore/Database/DBExceptionHandler.py +57 -0
- WMCore/Database/DBFactory.py +110 -0
- WMCore/Database/DBFormatter.py +177 -0
- WMCore/Database/Dialects.py +13 -0
- WMCore/Database/ExecuteDAO.py +327 -0
- WMCore/Database/MongoDB.py +241 -0
- WMCore/Database/MySQL/Destroy.py +42 -0
- WMCore/Database/MySQL/ListUserContent.py +20 -0
- WMCore/Database/MySQL/__init__.py +9 -0
- WMCore/Database/MySQLCore.py +132 -0
- WMCore/Database/Oracle/Destroy.py +56 -0
- WMCore/Database/Oracle/ListUserContent.py +19 -0
- WMCore/Database/Oracle/__init__.py +9 -0
- WMCore/Database/ResultSet.py +44 -0
- WMCore/Database/Transaction.py +91 -0
- WMCore/Database/__init__.py +9 -0
- WMCore/Database/ipy_profile_couch.py +438 -0
- WMCore/GroupUser/CouchObject.py +127 -0
- WMCore/GroupUser/Decorators.py +51 -0
- WMCore/GroupUser/Group.py +33 -0
- WMCore/GroupUser/Interface.py +73 -0
- WMCore/GroupUser/User.py +96 -0
- WMCore/GroupUser/__init__.py +11 -0
- WMCore/Lexicon.py +836 -0
- WMCore/MicroService/CherryPyThreads/HeartbeatMonitor.py +6 -0
- WMCore/MicroService/CherryPyThreads/__init__.py +0 -0
- WMCore/MicroService/DataStructs/DefaultStructs.py +101 -0
- WMCore/MicroService/DataStructs/__init__.py +0 -0
- WMCore/MicroService/MSCore/MSAuth.py +153 -0
- WMCore/MicroService/MSCore/MSCore.py +113 -0
- WMCore/MicroService/MSCore/MSManager.py +484 -0
- WMCore/MicroService/MSCore/TaskManager.py +218 -0
- WMCore/MicroService/MSCore/__init__.py +0 -0
- WMCore/MicroService/MSMonitor/MSMonitor.py +270 -0
- WMCore/MicroService/MSMonitor/__init__.py +0 -0
- WMCore/MicroService/Service/Data.py +225 -0
- WMCore/MicroService/Service/RestApiHub.py +46 -0
- WMCore/MicroService/Service/__init__.py +0 -0
- WMCore/MicroService/Tools/Common.py +579 -0
- WMCore/MicroService/Tools/PycurlRucio.py +419 -0
- WMCore/MicroService/Tools/__init__.py +0 -0
- WMCore/MicroService/WebGui/FrontPage.py +56 -0
- WMCore/MicroService/WebGui/__init__.py +0 -0
- WMCore/REST/Auth.py +202 -0
- WMCore/REST/CherryPyPeriodicTask.py +166 -0
- WMCore/REST/Error.py +333 -0
- WMCore/REST/Format.py +642 -0
- WMCore/REST/HeartbeatMonitorBase.py +90 -0
- WMCore/REST/Main.py +623 -0
- WMCore/REST/Server.py +2435 -0
- WMCore/REST/Services.py +24 -0
- WMCore/REST/Test.py +120 -0
- WMCore/REST/Tools.py +38 -0
- WMCore/REST/Validation.py +250 -0
- WMCore/REST/__init__.py +1 -0
- WMCore/ReqMgr/DataStructs/RequestStatus.py +209 -0
- WMCore/ReqMgr/DataStructs/RequestType.py +13 -0
- WMCore/ReqMgr/DataStructs/__init__.py +0 -0
- WMCore/ReqMgr/__init__.py +1 -0
- WMCore/Services/AlertManager/AlertManagerAPI.py +111 -0
- WMCore/Services/AlertManager/__init__.py +0 -0
- WMCore/Services/CRIC/CRIC.py +238 -0
- WMCore/Services/CRIC/__init__.py +0 -0
- WMCore/Services/DBS/DBS3Reader.py +1044 -0
- WMCore/Services/DBS/DBSConcurrency.py +44 -0
- WMCore/Services/DBS/DBSErrors.py +113 -0
- WMCore/Services/DBS/DBSReader.py +23 -0
- WMCore/Services/DBS/DBSUtils.py +139 -0
- WMCore/Services/DBS/DBSWriterObjects.py +381 -0
- WMCore/Services/DBS/ProdException.py +133 -0
- WMCore/Services/DBS/__init__.py +8 -0
- WMCore/Services/FWJRDB/FWJRDBAPI.py +118 -0
- WMCore/Services/FWJRDB/__init__.py +0 -0
- WMCore/Services/HTTPS/HTTPSAuthHandler.py +66 -0
- WMCore/Services/HTTPS/__init__.py +0 -0
- WMCore/Services/LogDB/LogDB.py +201 -0
- WMCore/Services/LogDB/LogDBBackend.py +191 -0
- WMCore/Services/LogDB/LogDBExceptions.py +11 -0
- WMCore/Services/LogDB/LogDBReport.py +85 -0
- WMCore/Services/LogDB/__init__.py +0 -0
- WMCore/Services/MSPileup/__init__.py +0 -0
- WMCore/Services/MSUtils/MSUtils.py +54 -0
- WMCore/Services/MSUtils/__init__.py +0 -0
- WMCore/Services/McM/McM.py +173 -0
- WMCore/Services/McM/__init__.py +8 -0
- WMCore/Services/MonIT/Grafana.py +133 -0
- WMCore/Services/MonIT/__init__.py +0 -0
- WMCore/Services/PyCondor/PyCondorAPI.py +154 -0
- WMCore/Services/PyCondor/PyCondorUtils.py +105 -0
- WMCore/Services/PyCondor/__init__.py +0 -0
- WMCore/Services/ReqMgr/ReqMgr.py +261 -0
- WMCore/Services/ReqMgr/__init__.py +0 -0
- WMCore/Services/ReqMgrAux/ReqMgrAux.py +419 -0
- WMCore/Services/ReqMgrAux/__init__.py +0 -0
- WMCore/Services/RequestDB/RequestDBReader.py +267 -0
- WMCore/Services/RequestDB/RequestDBWriter.py +39 -0
- WMCore/Services/RequestDB/__init__.py +0 -0
- WMCore/Services/Requests.py +624 -0
- WMCore/Services/Rucio/Rucio.py +1287 -0
- WMCore/Services/Rucio/RucioUtils.py +74 -0
- WMCore/Services/Rucio/__init__.py +0 -0
- WMCore/Services/RucioConMon/RucioConMon.py +128 -0
- WMCore/Services/RucioConMon/__init__.py +0 -0
- WMCore/Services/Service.py +400 -0
- WMCore/Services/StompAMQ/__init__.py +0 -0
- WMCore/Services/TagCollector/TagCollector.py +155 -0
- WMCore/Services/TagCollector/XMLUtils.py +98 -0
- WMCore/Services/TagCollector/__init__.py +0 -0
- WMCore/Services/UUIDLib.py +13 -0
- WMCore/Services/UserFileCache/UserFileCache.py +160 -0
- WMCore/Services/UserFileCache/__init__.py +8 -0
- WMCore/Services/WMAgent/WMAgent.py +63 -0
- WMCore/Services/WMAgent/__init__.py +0 -0
- WMCore/Services/WMArchive/CMSSWMetrics.py +526 -0
- WMCore/Services/WMArchive/DataMap.py +463 -0
- WMCore/Services/WMArchive/WMArchive.py +33 -0
- WMCore/Services/WMArchive/__init__.py +0 -0
- WMCore/Services/WMBS/WMBS.py +97 -0
- WMCore/Services/WMBS/__init__.py +0 -0
- WMCore/Services/WMStats/DataStruct/RequestInfoCollection.py +300 -0
- WMCore/Services/WMStats/DataStruct/__init__.py +0 -0
- WMCore/Services/WMStats/WMStatsPycurl.py +145 -0
- WMCore/Services/WMStats/WMStatsReader.py +445 -0
- WMCore/Services/WMStats/WMStatsWriter.py +273 -0
- WMCore/Services/WMStats/__init__.py +0 -0
- WMCore/Services/WMStatsServer/WMStatsServer.py +134 -0
- WMCore/Services/WMStatsServer/__init__.py +0 -0
- WMCore/Services/WorkQueue/WorkQueue.py +492 -0
- WMCore/Services/WorkQueue/__init__.py +0 -0
- WMCore/Services/__init__.py +8 -0
- WMCore/Services/pycurl_manager.py +574 -0
- WMCore/WMBase.py +50 -0
- WMCore/WMConnectionBase.py +164 -0
- WMCore/WMException.py +183 -0
- WMCore/WMExceptions.py +269 -0
- WMCore/WMFactory.py +76 -0
- WMCore/WMInit.py +228 -0
- WMCore/WMLogging.py +108 -0
- WMCore/Wrappers/JsonWrapper/JSONThunker.py +342 -0
- WMCore/Wrappers/JsonWrapper/__init__.py +7 -0
- WMCore/Wrappers/__init__.py +6 -0
- WMCore/__init__.py +10 -0
- msmonitor-2.3.10.data/data/bin/wmc-dist-patch +15 -0
- msmonitor-2.3.10.data/data/bin/wmc-dist-unpatch +8 -0
- msmonitor-2.3.10.data/data/bin/wmc-httpd +3 -0
- msmonitor-2.3.10.dist-info/LICENSE +202 -0
- msmonitor-2.3.10.dist-info/METADATA +21 -0
- msmonitor-2.3.10.dist-info/NOTICE +16 -0
- msmonitor-2.3.10.dist-info/RECORD +210 -0
- msmonitor-2.3.10.dist-info/WHEEL +5 -0
- msmonitor-2.3.10.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File : MSManager.py
|
|
3
|
+
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
|
|
4
|
+
Alan Malta <alan dot malta AT cern dot ch >
|
|
5
|
+
Description: MSManager class provides full functionality of the MSManager service.
|
|
6
|
+
It provides a interface to reqmgr2ms service and should be
|
|
7
|
+
used in service config.py as following
|
|
8
|
+
|
|
9
|
+
.. doctest::
|
|
10
|
+
|
|
11
|
+
# REST interface
|
|
12
|
+
data = views.section_('data')
|
|
13
|
+
data.object = 'WMCore.MicroService.Service.RestApiHub.RestApiHub'
|
|
14
|
+
data.manager = 'WMCore.MicroService.MSManager.MSManager'
|
|
15
|
+
data.reqmgr2Url = "%s/reqmgr2" % BASE_URL
|
|
16
|
+
data.limitRequestsPerCycle = 500
|
|
17
|
+
data.enableStatusTransition = False
|
|
18
|
+
data.enableDataTransfer = False
|
|
19
|
+
data.verbose = True
|
|
20
|
+
data.interval = 60
|
|
21
|
+
data.rucioAccount = RUCIO_ACCT
|
|
22
|
+
data.dbsUrl = "%s/dbs/%s/global/DBSReader" % (BASE_URL, DBS_INS)
|
|
23
|
+
"""
|
|
24
|
+
# futures
|
|
25
|
+
from __future__ import division, print_function
|
|
26
|
+
|
|
27
|
+
# system modules
|
|
28
|
+
from builtins import object
|
|
29
|
+
from time import sleep
|
|
30
|
+
from datetime import datetime
|
|
31
|
+
|
|
32
|
+
# 3rd party modules
|
|
33
|
+
from cherrypy import HTTPError
|
|
34
|
+
|
|
35
|
+
# WMCore modules
|
|
36
|
+
from WMCore.MicroService.Tools.Common import getMSLogger
|
|
37
|
+
from WMCore.MicroService.MSCore.TaskManager import start_new_thread
|
|
38
|
+
from Utils.Utilities import strToBool
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def daemon(func, reqStatus, interval, logger):
|
|
42
|
+
"Daemon to perform given function action for all request in our store"
|
|
43
|
+
while True:
|
|
44
|
+
try:
|
|
45
|
+
func(reqStatus)
|
|
46
|
+
except Exception as exc:
|
|
47
|
+
logger.exception("MS daemon error: %s", str(exc))
|
|
48
|
+
sleep(interval)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def daemonOpt(func, interval, logger, *args, **kwargs):
|
|
52
|
+
"Daemon to perform given function action for all request in our store"
|
|
53
|
+
while True:
|
|
54
|
+
try:
|
|
55
|
+
func(*args, **kwargs)
|
|
56
|
+
except Exception as exc:
|
|
57
|
+
logger.exception("MS daemon error: %s", str(exc))
|
|
58
|
+
sleep(interval)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class MSManager(object):
|
|
62
|
+
"""
|
|
63
|
+
Entry point for the MicroServices.
|
|
64
|
+
This class manages both transferor and monitoring services.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(self, config=None, logger=None):
|
|
68
|
+
"""
|
|
69
|
+
Initialize MSManager class with given configuration,
|
|
70
|
+
logger, ReqMgr2/ReqMgrAux/PhEDEx/Rucio objects,
|
|
71
|
+
and start transferor and monitoring threads.
|
|
72
|
+
:param config: reqmgr2ms service configuration
|
|
73
|
+
:param logger:
|
|
74
|
+
"""
|
|
75
|
+
self.config = config
|
|
76
|
+
self.logger = getMSLogger(getattr(config, 'verbose', False), logger)
|
|
77
|
+
self._parseConfig(config)
|
|
78
|
+
self.logger.info("Configuration including default values:\n%s", self.msConfig)
|
|
79
|
+
self.statusTrans = {}
|
|
80
|
+
self.statusMon = {}
|
|
81
|
+
self.statusOutput = {}
|
|
82
|
+
self.statusRuleCleaner = {}
|
|
83
|
+
self.statusUnmerged = {}
|
|
84
|
+
self.statusPileup = {}
|
|
85
|
+
|
|
86
|
+
# initialize pileup module
|
|
87
|
+
if 'pileup' in self.services:
|
|
88
|
+
from WMCore.MicroService.MSPileup.MSPileup import MSPileup
|
|
89
|
+
self.msPileup = MSPileup(self.msConfig, logger=self.logger)
|
|
90
|
+
thname = 'MSPileup'
|
|
91
|
+
self.pileupThread = start_new_thread(thname, daemonOpt,
|
|
92
|
+
(self.pileup,
|
|
93
|
+
self.msConfig['interval'],
|
|
94
|
+
self.logger))
|
|
95
|
+
self.logger.info("### Running %s thread %s", thname, self.pileupThread.running())
|
|
96
|
+
|
|
97
|
+
# initialize pileup-tasks module
|
|
98
|
+
if 'pileup-tasks' in self.services:
|
|
99
|
+
from WMCore.MicroService.MSPileup.MSPileupTaskManager import MSPileupTaskManager
|
|
100
|
+
self.msPileupTasks = MSPileupTaskManager(self.msConfig, logger=self.logger)
|
|
101
|
+
thname = 'MSPileupTasks'
|
|
102
|
+
self.pileupTasksThread = start_new_thread(thname, daemonOpt,
|
|
103
|
+
(self.pileupTasks,
|
|
104
|
+
self.msConfig['interval'],
|
|
105
|
+
self.logger))
|
|
106
|
+
self.logger.info("### Running %s thread %s", thname, self.pileupTasksThread.running())
|
|
107
|
+
|
|
108
|
+
# initialize transferor module
|
|
109
|
+
if 'transferor' in self.services:
|
|
110
|
+
from WMCore.MicroService.MSTransferor.MSTransferor import MSTransferor
|
|
111
|
+
self.msTransferor = MSTransferor(self.msConfig, logger=self.logger)
|
|
112
|
+
thname = 'MSTransferor'
|
|
113
|
+
self.transfThread = start_new_thread(thname, daemon,
|
|
114
|
+
(self.transferor,
|
|
115
|
+
'assigned',
|
|
116
|
+
self.msConfig['interval'],
|
|
117
|
+
self.logger))
|
|
118
|
+
self.logger.info("### Running %s thread %s", thname, self.transfThread.running())
|
|
119
|
+
|
|
120
|
+
# initialize monitoring module
|
|
121
|
+
if 'monitor' in self.services:
|
|
122
|
+
from WMCore.MicroService.MSMonitor.MSMonitor import MSMonitor
|
|
123
|
+
self.msMonitor = MSMonitor(self.msConfig, logger=self.logger)
|
|
124
|
+
thname = 'MSMonitor'
|
|
125
|
+
self.monitThread = start_new_thread(thname, daemon,
|
|
126
|
+
(self.monitor,
|
|
127
|
+
'staging',
|
|
128
|
+
self.msConfig['interval'],
|
|
129
|
+
self.logger))
|
|
130
|
+
self.logger.info("+++ Running %s thread %s", thname, self.monitThread.running())
|
|
131
|
+
|
|
132
|
+
# initialize output module
|
|
133
|
+
if 'output' in self.services:
|
|
134
|
+
from WMCore.MicroService.MSOutput.MSOutput import MSOutput
|
|
135
|
+
reqStatus = ['closed-out', 'announced']
|
|
136
|
+
|
|
137
|
+
thname = 'MSOutputConsumer'
|
|
138
|
+
self.msOutputConsumer = MSOutput(self.msConfig, mode=thname, logger=self.logger)
|
|
139
|
+
# set the consumer to run twice faster than the producer
|
|
140
|
+
consumerInterval = self.msConfig['interval'] // 2
|
|
141
|
+
self.outputConsumerThread = start_new_thread(thname, daemon,
|
|
142
|
+
(self.outputConsumer,
|
|
143
|
+
reqStatus,
|
|
144
|
+
consumerInterval,
|
|
145
|
+
self.logger))
|
|
146
|
+
self.logger.info("=== Running %s thread %s", thname, self.outputConsumerThread.running())
|
|
147
|
+
|
|
148
|
+
thname = 'MSOutputProducer'
|
|
149
|
+
self.msOutputProducer = MSOutput(self.msConfig, mode=thname, logger=self.logger)
|
|
150
|
+
self.outputProducerThread = start_new_thread(thname, daemon,
|
|
151
|
+
(self.outputProducer,
|
|
152
|
+
reqStatus,
|
|
153
|
+
self.msConfig['interval'],
|
|
154
|
+
self.logger))
|
|
155
|
+
self.logger.info("=== Running %s thread %s", thname, self.outputProducerThread.running())
|
|
156
|
+
|
|
157
|
+
# initialize rule cleaner module
|
|
158
|
+
if 'ruleCleaner' in self.services:
|
|
159
|
+
from WMCore.MicroService.MSRuleCleaner.MSRuleCleaner import MSRuleCleaner
|
|
160
|
+
reqStatus = ['announced', 'aborted-completed', 'rejected']
|
|
161
|
+
self.msRuleCleaner = MSRuleCleaner(self.msConfig, logger=self.logger)
|
|
162
|
+
thname = 'MSRuleCleaner'
|
|
163
|
+
self.ruleCleanerThread = start_new_thread(thname, daemon,
|
|
164
|
+
(self.ruleCleaner,
|
|
165
|
+
reqStatus,
|
|
166
|
+
self.msConfig['interval'],
|
|
167
|
+
self.logger))
|
|
168
|
+
self.logger.info("--- Running %s thread %s", thname, self.ruleCleanerThread.running())
|
|
169
|
+
|
|
170
|
+
# initialize unmerged module
|
|
171
|
+
if 'unmerged' in self.services:
|
|
172
|
+
from WMCore.MicroService.MSUnmerged.MSUnmerged import MSUnmerged
|
|
173
|
+
self.msUnmerged = MSUnmerged(self.msConfig, logger=self.logger)
|
|
174
|
+
thname = 'MSUnmerged'
|
|
175
|
+
self.unmergedThread = start_new_thread(thname, daemonOpt,
|
|
176
|
+
(self.unmerged,
|
|
177
|
+
self.msConfig['interval'],
|
|
178
|
+
self.logger))
|
|
179
|
+
self.logger.info("--- Running %s thread %s", thname, self.unmergedThread.running())
|
|
180
|
+
|
|
181
|
+
def _parseConfig(self, config):
|
|
182
|
+
"""
|
|
183
|
+
__parseConfig_
|
|
184
|
+
Parse the MicroService configuration and set any default values.
|
|
185
|
+
:param config: config as defined in the deployment
|
|
186
|
+
"""
|
|
187
|
+
self.logger.info("Using the following MicroServices config: %s", config.dictionary_())
|
|
188
|
+
self.services = getattr(config, 'services', [])
|
|
189
|
+
|
|
190
|
+
self.msConfig = {}
|
|
191
|
+
self.msConfig.update(config.dictionary_())
|
|
192
|
+
|
|
193
|
+
self.msConfig['reqmgrCacheUrl'] = self.msConfig['reqmgr2Url'].replace('reqmgr2',
|
|
194
|
+
'couchdb/reqmgr_workload_cache')
|
|
195
|
+
|
|
196
|
+
def pileup(self, *args, **kwargs):
|
|
197
|
+
"""
|
|
198
|
+
MSManager pileup function.
|
|
199
|
+
"""
|
|
200
|
+
startTime = datetime.utcnow()
|
|
201
|
+
self.logger.info("Starting the pileup thread...")
|
|
202
|
+
res = self.msPileup.status()
|
|
203
|
+
endTime = datetime.utcnow()
|
|
204
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
205
|
+
self.logger.info("Total pileup execution time: %.2f secs", res['execution_time'])
|
|
206
|
+
self.statusPileup = res
|
|
207
|
+
|
|
208
|
+
def pileupTasks(self, *args, **kwargs):
|
|
209
|
+
"""
|
|
210
|
+
MSManager pileup tasks function.
|
|
211
|
+
"""
|
|
212
|
+
startTime = datetime.utcnow()
|
|
213
|
+
self.logger.info("Starting the pileup-tasks thread...")
|
|
214
|
+
self.msPileupTasks.executeCycle()
|
|
215
|
+
res = self.msPileupTasks.status()
|
|
216
|
+
endTime = datetime.utcnow()
|
|
217
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
218
|
+
self.logger.info("Total pileup-tasks execution time: %.2f secs", res['execution_time'])
|
|
219
|
+
self.statusPileupTasks = res
|
|
220
|
+
|
|
221
|
+
def transferor(self, reqStatus):
|
|
222
|
+
"""
|
|
223
|
+
MSManager transferor function.
|
|
224
|
+
It performs input data placement logic for workflows that have
|
|
225
|
+
been assigned in the system. Successful workflows will be moved
|
|
226
|
+
to the staging status in ReqMgr2.
|
|
227
|
+
For references see
|
|
228
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-Transferor
|
|
229
|
+
"""
|
|
230
|
+
startTime = datetime.utcnow()
|
|
231
|
+
self.logger.info("Starting the transferor thread...")
|
|
232
|
+
res = self.msTransferor.execute(reqStatus)
|
|
233
|
+
endTime = datetime.utcnow()
|
|
234
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
235
|
+
self.logger.info("Total transferor execution time: %.2f secs", res['execution_time'])
|
|
236
|
+
self.statusTrans = res
|
|
237
|
+
|
|
238
|
+
def monitor(self, reqStatus):
|
|
239
|
+
"""
|
|
240
|
+
MSManager monitoring function.
|
|
241
|
+
It performs transfer requests from staging to staged state of ReqMgr2.
|
|
242
|
+
For references see
|
|
243
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-Transferor
|
|
244
|
+
"""
|
|
245
|
+
startTime = datetime.utcnow()
|
|
246
|
+
self.logger.info("Starting the monitor thread...")
|
|
247
|
+
res = self.msMonitor.execute(reqStatus)
|
|
248
|
+
endTime = datetime.utcnow()
|
|
249
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
250
|
+
self.logger.info("Total monitor execution time: %d secs", res['execution_time'])
|
|
251
|
+
self.statusMon = res
|
|
252
|
+
|
|
253
|
+
def outputConsumer(self, reqStatus):
|
|
254
|
+
"""
|
|
255
|
+
MSManager Output Data Placement function.
|
|
256
|
+
It subscribes the output datasets to the Data Management System.
|
|
257
|
+
For references see
|
|
258
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-Output
|
|
259
|
+
reqStatus: Status of requests to work on
|
|
260
|
+
"""
|
|
261
|
+
startTime = datetime.utcnow()
|
|
262
|
+
self.logger.info("Starting the outputConsumer thread...")
|
|
263
|
+
res = self.msOutputConsumer.execute(reqStatus)
|
|
264
|
+
endTime = datetime.utcnow()
|
|
265
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
266
|
+
self.logger.info("Total outputConsumer execution time: %d secs", res['execution_time'])
|
|
267
|
+
self.statusOutput = res
|
|
268
|
+
|
|
269
|
+
def outputProducer(self, reqStatus):
|
|
270
|
+
"""
|
|
271
|
+
MSManager MongoDB Uploader function.
|
|
272
|
+
It uploads the documents describing a workflow output Data subscription
|
|
273
|
+
into MongoDb. For references see
|
|
274
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-Output
|
|
275
|
+
reqStatus: Status of requests to work on
|
|
276
|
+
"""
|
|
277
|
+
startTime = datetime.utcnow()
|
|
278
|
+
self.logger.info("Starting the outputProducer thread...")
|
|
279
|
+
res = self.msOutputProducer.execute(reqStatus)
|
|
280
|
+
endTime = datetime.utcnow()
|
|
281
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
282
|
+
self.logger.info("Total outputProducer execution time: %d secs", res['execution_time'])
|
|
283
|
+
self.statusOutput = res
|
|
284
|
+
|
|
285
|
+
def ruleCleaner(self, reqStatus):
|
|
286
|
+
"""
|
|
287
|
+
MSManager ruleCleaner function.
|
|
288
|
+
It cleans the block level Rucio rules created by WMAgent and
|
|
289
|
+
performs request status transition from ['announced', 'aborted-completed', 'rejected'] to
|
|
290
|
+
'{normal, aborted, rejected}-archived' state of ReqMgr2.
|
|
291
|
+
For references see
|
|
292
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-RuleCleaner
|
|
293
|
+
"""
|
|
294
|
+
startTime = datetime.utcnow()
|
|
295
|
+
self.logger.info("Starting the ruleCleaner thread...")
|
|
296
|
+
res = self.msRuleCleaner.execute(reqStatus)
|
|
297
|
+
endTime = datetime.utcnow()
|
|
298
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
299
|
+
self.logger.info("Total ruleCleaner execution time: %d secs", res['execution_time'])
|
|
300
|
+
self.statusRuleCleaner = res
|
|
301
|
+
|
|
302
|
+
def unmerged(self, *args, **kwargs):
|
|
303
|
+
"""
|
|
304
|
+
MSManager unmerged function.
|
|
305
|
+
It cleans the Unmerged area of the CMS LFN Namespace
|
|
306
|
+
For references see
|
|
307
|
+
https://github.com/dmwm/WMCore/wiki/ReqMgr2-MicroService-Unmerged
|
|
308
|
+
"""
|
|
309
|
+
startTime = datetime.utcnow()
|
|
310
|
+
self.logger.info("Starting the unmerged thread...")
|
|
311
|
+
res = self.msUnmerged.execute()
|
|
312
|
+
endTime = datetime.utcnow()
|
|
313
|
+
self.updateTimeUTC(res, startTime, endTime)
|
|
314
|
+
self.logger.info("Total Unmerged execution time: %d secs", res['execution_time'])
|
|
315
|
+
self.statusUnmerged = res
|
|
316
|
+
|
|
317
|
+
def stop(self):
|
|
318
|
+
"Stop MSManager"
|
|
319
|
+
status = None
|
|
320
|
+
# stop MSMonitor thread
|
|
321
|
+
if 'monitor' in self.services and hasattr(self, 'monitThread'):
|
|
322
|
+
self.monitThread.stop()
|
|
323
|
+
status = self.monitThread.running()
|
|
324
|
+
# stop MSPileup thread
|
|
325
|
+
if 'pileup' in self.services and hasattr(self, 'pileupThread'):
|
|
326
|
+
self.pileupThread.stop() # stop checkStatus thread
|
|
327
|
+
status = self.pileupThread.running()
|
|
328
|
+
# stop MSPileupTasks thread
|
|
329
|
+
if 'pileup-tasks' in self.services and hasattr(self, 'pileupTasksThread'):
|
|
330
|
+
self.pileupTasksThread.stop() # stop checkStatus thread
|
|
331
|
+
status = self.pileupTasksThread.running()
|
|
332
|
+
# stop MSTransferor thread
|
|
333
|
+
if 'transferor' in self.services and hasattr(self, 'transfThread'):
|
|
334
|
+
self.transfThread.stop() # stop checkStatus thread
|
|
335
|
+
status = self.transfThread.running()
|
|
336
|
+
# stop MSOutput threads
|
|
337
|
+
if 'output' in self.services and hasattr(self, 'outputConsumerThread'):
|
|
338
|
+
self.outputConsumerThread.stop()
|
|
339
|
+
status = self.outputConsumerThread.running()
|
|
340
|
+
if 'output' in self.services and hasattr(self, 'outputProducerThread'):
|
|
341
|
+
self.outputProducerThread.stop()
|
|
342
|
+
status = self.outputProducerThread.running()
|
|
343
|
+
# stop MSRuleCleaner thread
|
|
344
|
+
if 'ruleCleaner' in self.services and hasattr(self, 'ruleCleanerThread'):
|
|
345
|
+
self.ruleCleanerThread.stop()
|
|
346
|
+
status = self.ruleCleanerThread.running()
|
|
347
|
+
# stop MSUnmerged thread
|
|
348
|
+
if 'unmerged' in self.services and hasattr(self, 'unmergedThread'):
|
|
349
|
+
self.unmergedThread.stop()
|
|
350
|
+
status = self.unmergedThread.running()
|
|
351
|
+
return status
|
|
352
|
+
|
|
353
|
+
def info(self, reqName=None, **kwargs):
|
|
354
|
+
"""
|
|
355
|
+
Return transfer information for a given request
|
|
356
|
+
:param reqName: request name
|
|
357
|
+
:param kwargs: other arguments that can be provided for different
|
|
358
|
+
microservices. Examples:
|
|
359
|
+
rse: string with the name of the RSE (e.g 'T2_DE_DESY')
|
|
360
|
+
:return: data transfer information for this request
|
|
361
|
+
"""
|
|
362
|
+
if 'ruleCleaner' in self.services or 'unmerged' in self.services \
|
|
363
|
+
or 'pileup' in self.services or 'pileup-tasks' in self.services:
|
|
364
|
+
data = {}
|
|
365
|
+
else:
|
|
366
|
+
data = {"request": reqName, "transferDoc": None}
|
|
367
|
+
if reqName:
|
|
368
|
+
transferDoc = None
|
|
369
|
+
# obtain the transfer information for a given request records from couchdb for given request
|
|
370
|
+
if 'monitor' in self.services:
|
|
371
|
+
transferDoc = self.msMonitor.reqmgrAux.getTransferInfo(reqName)
|
|
372
|
+
elif 'transferor' in self.services:
|
|
373
|
+
transferDoc = self.msTransferor.reqmgrAux.getTransferInfo(reqName)
|
|
374
|
+
elif 'output' in self.services:
|
|
375
|
+
transferDoc = self.msOutputProducer.getTransferInfo(reqName)
|
|
376
|
+
if transferDoc:
|
|
377
|
+
# it's always a single document in Couch
|
|
378
|
+
data['transferDoc'] = transferDoc[0]
|
|
379
|
+
|
|
380
|
+
if 'unmerged' in self.services:
|
|
381
|
+
detail = strToBool(kwargs.get('detail', False))
|
|
382
|
+
|
|
383
|
+
if kwargs.get("rse"):
|
|
384
|
+
data = self.msUnmerged.getStatsFromMongoDB(detail=detail, rse=kwargs['rse'])
|
|
385
|
+
return data
|
|
386
|
+
|
|
387
|
+
def get(self, **kwds):
|
|
388
|
+
"""
|
|
389
|
+
Fetch data in backend, HTTP GET request
|
|
390
|
+
:param args: input parameters
|
|
391
|
+
:param kwds: positional arguments
|
|
392
|
+
:return: list of results
|
|
393
|
+
"""
|
|
394
|
+
if 'pileup' in self.services:
|
|
395
|
+
return self.msPileup.getPileup(**kwds)
|
|
396
|
+
return []
|
|
397
|
+
|
|
398
|
+
def post(self, doc):
|
|
399
|
+
"""
|
|
400
|
+
Either create or fetch data from backend, HTTP POST request
|
|
401
|
+
|
|
402
|
+
:param doc: input JSON doc for HTTP POST request
|
|
403
|
+
:return: list of results
|
|
404
|
+
"""
|
|
405
|
+
res = []
|
|
406
|
+
if 'pileup' in self.services:
|
|
407
|
+
if 'pileupName' in doc:
|
|
408
|
+
# this is create POST request
|
|
409
|
+
res = self.msPileup.createPileup(doc)
|
|
410
|
+
if 'query' in doc:
|
|
411
|
+
# this is POST request to get data for a given JSON query
|
|
412
|
+
res = self.msPileup.queryDatabase(doc)
|
|
413
|
+
elif 'transferor' in self.services:
|
|
414
|
+
if 'workflow' in doc:
|
|
415
|
+
res = self.msTransferor.updateSites(doc)
|
|
416
|
+
else:
|
|
417
|
+
raise HTTPError(400, 'invalid payload %s to MSTransferor REST API, expecting {"workflow": <workflow>}' % doc)
|
|
418
|
+
return res
|
|
419
|
+
|
|
420
|
+
def update(self, doc):
|
|
421
|
+
"""
|
|
422
|
+
Update resource in backend, HTTP PUT request
|
|
423
|
+
|
|
424
|
+
:param doc: input JSON doc for HTTP PUT request
|
|
425
|
+
:return: list of results
|
|
426
|
+
"""
|
|
427
|
+
if 'pileup' in self.services:
|
|
428
|
+
return self.msPileup.updatePileup(doc)
|
|
429
|
+
return []
|
|
430
|
+
|
|
431
|
+
def delete(self, spec):
|
|
432
|
+
"""
|
|
433
|
+
Delete resource in backend, HTTP DELETE request
|
|
434
|
+
|
|
435
|
+
:param doc: input JSON spec for HTTP DELETE request
|
|
436
|
+
:return: list of results
|
|
437
|
+
"""
|
|
438
|
+
if 'pileup' in self.services:
|
|
439
|
+
return self.msPileup.deletePileup(spec)
|
|
440
|
+
return []
|
|
441
|
+
|
|
442
|
+
def status(self, detail, **kwargs):
|
|
443
|
+
"""
|
|
444
|
+
Return the current status of a MicroService and a summary
|
|
445
|
+
of its last execution activity.
|
|
446
|
+
:param detail: boolean used to retrieve some extra information
|
|
447
|
+
regarding the service
|
|
448
|
+
:param kwargs: other arguments that can be provided for different
|
|
449
|
+
microservices. Examples:
|
|
450
|
+
rse_type: string with the type of the RSEs to fetch (MSUnmerged)
|
|
451
|
+
Meaningful values at the moment are: "t1", "t2t3" and "t2t3us"
|
|
452
|
+
:return: a dictionary
|
|
453
|
+
"""
|
|
454
|
+
data = {"status": "OK"}
|
|
455
|
+
if detail and 'transferor' in self.services:
|
|
456
|
+
data.update(self.statusTrans)
|
|
457
|
+
elif detail and 'pileup' in self.services:
|
|
458
|
+
data.update(self.statusPileup)
|
|
459
|
+
elif detail and 'pileup-tasks' in self.services:
|
|
460
|
+
data.update(self.statusPileupTasks)
|
|
461
|
+
elif detail and 'monitor' in self.services:
|
|
462
|
+
data.update(self.statusMon)
|
|
463
|
+
elif detail and 'output' in self.services:
|
|
464
|
+
data.update(self.statusOutput)
|
|
465
|
+
elif detail and 'ruleCleaner' in self.services:
|
|
466
|
+
data.update(self.statusRuleCleaner)
|
|
467
|
+
elif 'unmerged' in self.services:
|
|
468
|
+
if kwargs.get("rse_type"):
|
|
469
|
+
data.update({"rse_type": kwargs.get("rse_type")})
|
|
470
|
+
if detail:
|
|
471
|
+
data.update(self.statusUnmerged)
|
|
472
|
+
return data
|
|
473
|
+
|
|
474
|
+
def updateTimeUTC(self, reportDict, startT, endT):
|
|
475
|
+
"""
|
|
476
|
+
Given a report summary dictionary and start/end time, update
|
|
477
|
+
the report with human readable timing information
|
|
478
|
+
:param reportDict: summary dictionary
|
|
479
|
+
:param startT: epoch start time for a given service
|
|
480
|
+
:param endT: epoch end time for a given service
|
|
481
|
+
"""
|
|
482
|
+
reportDict['start_time'] = startT.strftime("%a, %d %b %Y %H:%M:%S UTC")
|
|
483
|
+
reportDict['end_time'] = endT.strftime("%a, %d %b %Y %H:%M:%S UTC")
|
|
484
|
+
reportDict['execution_time'] = (endT - startT).total_seconds()
|