Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dbs block metadata in t0datasvc #5024

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/python/T0/WMBS/Oracle/T0DataSvc/GetDbsbufferPendingBlocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
_GetDbsbufferPendingBlocks_

Oracle implementation of GetDbsbufferPendingBlocks

Returns count of dbs blocks with status different than InDBS by acquisition era

"""

from WMCore.Database.DBFormatter import DBFormatter

class GetDbsbufferPendingBlocks(DBFormatter):

def execute(self, conn = None, transaction = False):

sql = """SELECT dbsbuffer_dataset.acquisition_era as acq_era, COUNT(dbsbuffer_block.blockname) as pending_blocks
FROM dbsbuffer_block
INNER JOIN dbsbuffer_dataset ON dbsbuffer_dataset.id = dbsbuffer_block.dataset_id
WHERE dbsbuffer_block.status NOT LIKE 'InDBS'
"""

results = self.dbi.processData(sql, binds = {}, conn = conn,
transaction = transaction)

return self.formatDict(results)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
_InsertDbsbufferPendingBlocks_

Oracle implementation of InsertDbsbufferPendingBlocks

Insert count of pending blocks by era into Tier0 Data Service

"""

from WMCore.Database.DBFormatter import DBFormatter

class InsertDbsbufferPendingBlocks(DBFormatter):

def execute(self, binds, conn = None, transaction = False):

sql = """MERGE INTO dbsbuffer_pending_blocks
USING DUAL ON ( acq_era = :ACQ_ERA )
WHEN MATCHED THEN
UPDATE SET pending_blocks = :PENDING_BLOCKS
WHEN NOT MATCHED THEN
INSERT (acq_era, pending_blocks)
VALUES (:ACQ_ERA, :PENDING_BLOCKS)
"""

self.dbi.processData(sql, binds, conn = conn,
transaction = transaction)

return