Skip to content

Commit

Permalink
Load JSON file with replications in AgentStatusPoller
Browse files Browse the repository at this point in the history
  • Loading branch information
amaltaro committed Oct 16, 2024
1 parent ffd06b4 commit 16d6e8e
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/python/WMComponent/AgentStatusWatcher/AgentStatusPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
3. Couchdb replication status (and status of its database)
4. Disk usage status
"""
from __future__ import division
from future.utils import viewitems

import os
import time
import json
import logging
import threading
from pprint import pformat
Expand Down Expand Up @@ -62,7 +63,12 @@ def __init__(self, config):
self.hostPortAMQ = getattr(config.AgentStatusWatcher, "hostPortAMQ", [('cms-mb.cern.ch', 61313)])

# WorkQueue replication
self.workqueueSelector = getattr(config.AgentStatusWatcher, "workqueueSelector", {})
replicationFile = os.path.join(os.getcwd(), "replication_selector.json")
if os.path.exists(replicationFile):
with open(replicationFile, 'r') as fd:
self.replicationDict = json.load(fd)
else:
raise RuntimeError(f"Could not find CouchDB replication JSON file at: {replicationFile}")

# T0 doesn't have WorkQueue, so some monitoring/replication code has to be skipped here
if hasattr(self.config, "Tier0Feeder"):
Expand All @@ -86,19 +92,24 @@ def setUpCouchDBReplication(self):

self.replicatorDocs = []
# set up common replication code
wmstatsSource = self.config.JobStateMachine.jobSummaryDBName
wmstatsTarget = self.config.General.centralWMStatsURL
self.replicatorDocs.append({'source': wmstatsSource, 'target': wmstatsTarget,
'filter': "WMStatsAgent/repfilter"})
self.replicatorDocs.append({'source': self.config.JobStateMachine.jobSummaryDBName,
'target': self.config.General.centralWMStatsURL,
'selector': self.replicationDict["WMStatsAgent/repfilter"]})

if self.isT0agent:
t0Source = self.config.Tier0Feeder.requestDBName
t0Target = self.config.AnalyticsDataCollector.centralRequestDBURL
self.replicatorDocs.append({'source': t0Source, 'target': t0Target,
'filter': "T0Request/repfilter"})
# Tier0 specific replication
self.replicatorDocs.append({'source': self.config.Tier0Feeder.requestDBName,
'target': self.config.AnalyticsDataCollector.centralRequestDBURL,
'selector': self.replicationDict["T0Request/repfilter"]})
else:
# set up workqueue replication
parentQueueUrl = self.workqueueSelector["WMCore\.WorkQueue\.DataStructs\.WorkQueueElement\.WorkQueueElement"]["ParentQueueUrl"]
# Production specific workqueue replication
parentQueueUrl = self.config.WorkQueueManager.queueParams["ParentQueueCouchUrl"]
childQueueUrl = self.config.WorkQueueManager.queueParams["QueueURL"]
localQInboxURL = "%s_inbox" % self.config.AnalyticsDataCollector.localQueueURL
# Update the selector filter
workqueueEscapedKey = "WMCore\.WorkQueue\.DataStructs\.WorkQueueElement\.WorkQueueElement"
self.replicationDict['WorkQueue/queueFilter'][workqueueEscapedKey]["ParentQueueUrl"] = parentQueueUrl
self.replicationDict['WorkQueue/queueFilter'][workqueueEscapedKey]["ChildQueueUrl"] = childQueueUrl
self.replicatorDocs.append({'source': parentQueueUrl,
'target': localQInboxURL,
'selector': self.workqueueSelector})
Expand Down

0 comments on commit 16d6e8e

Please sign in to comment.