Skip to content

Commit

Permalink
Merge pull request #396 from PanDAWMS/usersubs
Browse files Browse the repository at this point in the history
Remove obsoleted functions related to ATLAS_PANDAMETA.usersubs
  • Loading branch information
fbarreir authored Aug 20, 2024
2 parents fb32f7b + c40145e commit 104701d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 163 deletions.
119 changes: 0 additions & 119 deletions pandaserver/taskbuffer/OraDBProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11301,125 +11301,6 @@ def peekJobLog(self, pandaID, days=None):
# return None
return None

# get user subscriptions
def getUserSubscriptions(self, datasetName, timeRange):
comment = " /* DBProxy.getUserSubscriptions */"
_logger.debug(f"getUserSubscriptions({datasetName},{timeRange})")
sql0 = "SELECT site FROM ATLAS_PANDAMETA.UserSubs "
sql0 += "WHERE datasetName=:datasetName and modificationDate>CURRENT_DATE-:timeRange"
varMap = {}
varMap[":datasetName"] = datasetName
varMap[":timeRange"] = timeRange
try:
# start transaction
self.conn.begin()
# select
self.cur.execute(sql0 + comment, varMap)
resSs = self.cur.fetchall()
# commit
if not self._commit():
raise RuntimeError("Commit error")
retList = []
for (tmpSite,) in resSs:
retList.append(tmpSite)
return retList
except Exception:
# roll back
self._rollback()
errType, errValue = sys.exc_info()[:2]
_logger.error(f"getUserSubscriptions : {errType} {errValue}")
return []

# get the number of user subscriptions
def getNumUserSubscriptions(self):
comment = " /* DBProxy.getNumUserSubscriptions */"
_logger.debug("getNumUserSubscriptions")
sql0 = "SELECT site,COUNT(*) FROM ATLAS_PANDAMETA.UserSubs "
sql0 += "WHERE creationDate>CURRENT_DATE-2 GROUP BY site"
try:
# start transaction
self.conn.begin()
# select
self.cur.execute(sql0 + comment, {})
resSs = self.cur.fetchall()
# commit
if not self._commit():
raise RuntimeError("Commit error")
retList = {}
for tmpSite, countNum in resSs:
retList[tmpSite] = countNum
return retList
except Exception:
# roll back
self._rollback()
errType, errValue = sys.exc_info()[:2]
_logger.error(f"getNumUserSubscriptions : {errType} {errValue}")
return []

# add user subscriptions
def addUserSubscription(self, datasetName, dq2IDs):
comment = " /* DBProxy.addUserSubscription */"
_logger.debug(f"addUserSubscription({datasetName},{dq2IDs})")
sql0 = "INSERT INTO ATLAS_PANDAMETA.UserSubs "
sql0 += "(datasetName,site,creationDate,modificationDate,nUsed) "
sql0 += "VALUES (:datasetName,:site,CURRENT_DATE,CURRENT_DATE,:nUsed)"
try:
# start transaction
self.conn.begin()
for site in dq2IDs:
varMap = {}
varMap[":datasetName"] = datasetName
varMap[":site"] = site
varMap[":nUsed"] = 0
# insert
self.cur.execute(sql0 + comment, varMap)
# commit
if not self._commit():
raise RuntimeError("Commit error")
return True
except Exception:
# roll back
self._rollback()
errType, errValue = sys.exc_info()[:2]
_logger.error(f"addUserSubscription : {errType} {errValue}")
return False

# increment counter for subscription
def incrementUsedCounterSubscription(self, datasetName):
comment = " /* DBProxy.incrementUsedCounterSubscription */"
_logger.debug(f"incrementUsedCounterSubscription({datasetName})")
sql0 = "UPDATE ATLAS_PANDAMETA.UserSubs SET nUsed=nUsed+1 "
sql0 += "WHERE datasetName=:datasetName AND nUsed IS NOT NULL"
sqlU = "SELECT MAX(nUsed) FROM ATLAS_PANDAMETA.UserSubs "
sqlU += "WHERE datasetName=:datasetName"
try:
# start transaction
self.conn.begin()
varMap = {}
varMap[":datasetName"] = datasetName
# update
self.cur.execute(sql0 + comment, varMap)
# get nUsed
nUsed = 0
retU = self.cur.rowcount
if retU > 0:
# get nUsed
self.cur.execute(sqlU + comment, varMap)
self.cur.arraysize = 10
res = self.cur.fetchone()
if res is not None:
nUsed = res[0]
# commit
if not self._commit():
raise RuntimeError("Commit error")
return nUsed
except Exception:
# roll back
self._rollback()
errType, errValue = sys.exc_info()[:2]
_logger.error(f"incrementUsedCounterSubscription : {errType} {errValue}")
return -1

# get active datasets
def getActiveDatasets(self, computingSite, prodSourceLabel):
comment = " /* DBProxy.getActiveDatasets */"
Expand Down
44 changes: 0 additions & 44 deletions pandaserver/taskbuffer/TaskBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2402,50 +2402,6 @@ def getJobIdUser(self, dn):
# return
return ret

# get user subscriptions
def getUserSubscriptions(self, datasetName, timeRange):
# query an SQL return Status
proxy = self.proxyPool.getProxy()
# get
ret = proxy.getUserSubscriptions(datasetName, timeRange)
# release proxy
self.proxyPool.putProxy(proxy)
# return
return ret

# get the number of user subscriptions
def getNumUserSubscriptions(self):
# query an SQL return Status
proxy = self.proxyPool.getProxy()
# get
ret = proxy.getNumUserSubscriptions()
# release proxy
self.proxyPool.putProxy(proxy)
# return
return ret

# add user subscriptions
def addUserSubscription(self, datasetName, dq2IDs):
# query an SQL return Status
proxy = self.proxyPool.getProxy()
# get
ret = proxy.addUserSubscription(datasetName, dq2IDs)
# release proxy
self.proxyPool.putProxy(proxy)
# return
return ret

# increment counter for subscription
def incrementUsedCounterSubscription(self, datasetName):
# query an SQL return Status
proxy = self.proxyPool.getProxy()
# get
ret = proxy.incrementUsedCounterSubscription(datasetName)
# release proxy
self.proxyPool.putProxy(proxy)
# return
return ret

# get active datasets
def getActiveDatasets(self, computingSite, prodSourceLabel):
# query an SQL return Status
Expand Down

0 comments on commit 104701d

Please sign in to comment.