Skip to content

Commit db9e9a6

Browse files
authored
Merge pull request #5927 from fstagni/80_fixes21
[8.0] new TornadoDataIntegrityHandler
2 parents 02db60a + 99e99ea commit db9e9a6

File tree

8 files changed

+63
-36
lines changed

8 files changed

+63
-36
lines changed

docs/source/AdministratorGuide/ServerInstallations/scalingAndLimitations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Services
7777
+--------------------+---------------------------------------------------------------------------------------------------+-------------+---------------------------------------------------------------------------+-----------+
7878
| Configuration | :mod:`Configuration <DIRAC.ConfigurationSystem.Service.ConfigurationHandler>` | PARTIAL | One master (rw) and slaves (ro). It's advised to have several CS slaves | YES +
7979
+--------------------+---------------------------------------------------------------------------------------------------+-------------+---------------------------------------------------------------------------+-----------+
80-
| DataManagement | :mod:`DataIntegrity <DIRAC.DataManagementSystem.Service.DataIntegrityHandler>` | YES | | +
80+
| DataManagement | :mod:`DataIntegrity <DIRAC.DataManagementSystem.Service.DataIntegrityHandler>` | YES | | YES +
8181
+ +---------------------------------------------------------------------------------------------------+-------------+---------------------------------------------------------------------------+-----------+
8282
| | :mod:`FileCatalog <DIRAC.DataManagementSystem.Service.FileCatalogHandler>` | YES | | YES +
8383
+ +---------------------------------------------------------------------------------------------------+-------------+---------------------------------------------------------------------------+-----------+

src/DIRAC/DataManagementSystem/ConfigTemplate.cfg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ Services
88
Default = authenticated
99
}
1010
}
11+
##BEGIN TornadoDataIntegrity
12+
TornadoDataIntegrity
13+
{
14+
Protocol = https
15+
Authorization
16+
{
17+
Default = authenticated
18+
}
19+
}
20+
##END
1121
##BEGIN FTS3Manager
1222
FTS3Manager
1323
{
@@ -56,7 +66,7 @@ Services
5666
}
5767
}
5868

59-
# Caution: tech preview, with LHCb specific managers
69+
# Caution: LHCb specific managers
6070
TornadoFileCatalog
6171
{
6272
Protocol = https
@@ -76,7 +86,6 @@ Services
7686
Default = authenticated
7787
}
7888
}
79-
######################
8089

8190
##BEGIN StorageElement
8291
StorageElement

src/DIRAC/DataManagementSystem/Service/DataIntegrityHandler.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
the DISET framework
99
1010
"""
11-
# imports
12-
import six
13-
1411
# from DIRAC
1512
from DIRAC import S_OK
1613
from DIRAC.Core.DISET.RequestHandler import RequestHandler
1714
from DIRAC.DataManagementSystem.DB.DataIntegrityDB import DataIntegrityDB
1815

1916

20-
class DataIntegrityHandler(RequestHandler):
17+
class DataIntegrityHandlerMixin:
2118
"""
2219
.. class:: DataIntegrityHandler
2320
@@ -31,7 +28,7 @@ def initializeHandler(cls, serviceInfoDict):
3128
cls.dataIntegrityDB = DataIntegrityDB()
3229
return S_OK()
3330

34-
types_removeProblematic = [list(six.integer_types) + [list]]
31+
types_removeProblematic = [[int, list]]
3532

3633
def export_removeProblematic(self, fileID):
3734
"""Remove the file with the supplied FileID from the database"""
@@ -57,7 +54,7 @@ def export_getProblematic(self):
5754
)
5855
return res
5956

60-
types_getPrognosisProblematics = [list(six.string_types)]
57+
types_getPrognosisProblematics = [str]
6158

6259
def export_getPrognosisProblematics(self, prognosis):
6360
"""Get problematic files from the problematics table of the IntegrityDB"""
@@ -69,7 +66,7 @@ def export_getPrognosisProblematics(self, prognosis):
6966
)
7067
return res
7168

72-
types_setProblematicStatus = [list(six.integer_types), list(six.string_types)]
69+
types_setProblematicStatus = [int, str]
7370

7471
def export_setProblematicStatus(self, fileID, status):
7572
"""Update the status of the problematics with the provided fileID"""
@@ -79,7 +76,7 @@ def export_setProblematicStatus(self, fileID, status):
7976
self.log.error("DataIntegrityHandler.setProblematicStatus: Failed to set status.", res["Message"])
8077
return res
8178

82-
types_incrementProblematicRetry = [list(six.integer_types)]
79+
types_incrementProblematicRetry = [int]
8380

8481
def export_incrementProblematicRetry(self, fileID):
8582
"""Update the retry count for supplied file ID."""
@@ -91,7 +88,7 @@ def export_incrementProblematicRetry(self, fileID):
9188
)
9289
return res
9390

94-
types_insertProblematic = [list(six.string_types), dict]
91+
types_insertProblematic = [str, dict]
9592

9693
def export_insertProblematic(self, source, fileMetadata):
9794
"""Insert problematic files into the problematics table of the IntegrityDB"""
@@ -111,7 +108,7 @@ def export_changeProblematicPrognosis(self, fileID, newPrognosis):
111108
self.log.error("DataIntegrityHandler.changeProblematicPrognosis: Failed to update.", res["Message"])
112109
return res
113110

114-
types_getTransformationProblematics = [list(six.integer_types)]
111+
types_getTransformationProblematics = [int]
115112

116113
def export_getTransformationProblematics(self, transID):
117114
"""Get the problematics for a given transformation"""
@@ -148,3 +145,7 @@ def export_getDistinctPrognosis(self):
148145
else:
149146
self.log.error("DataIntegrityHandler.getDistinctPrognosis: Failed to get unique prognosis.", res["Message"])
150147
return res
148+
149+
150+
class DataIntegrityHandler(DataIntegrityHandlerMixin, RequestHandler):
151+
pass

src/DIRAC/DataManagementSystem/Service/FTS3ManagerHandler.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
:caption: FTS3Manager options
99
1010
"""
11-
import six
12-
13-
# from DIRAC
1411
from DIRAC import S_OK, S_ERROR, gLogger
1512
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
1613
from DIRAC.Core.DISET.RequestHandler import RequestHandler, getServiceOption
@@ -25,7 +22,7 @@
2522
########################################################################
2623

2724

28-
class FTS3ManagerHandlerMixin(object):
25+
class FTS3ManagerHandlerMixin:
2926
"""
3027
.. class:: FTS3ManagerHandlerMixin
3128
@@ -86,7 +83,7 @@ def _isAllowed(opObj, remoteCredentials):
8683

8784
return False
8885

89-
types_persistOperation = [six.string_types]
86+
types_persistOperation = [str]
9087

9188
def export_persistOperation(self, opJSON):
9289
"""update or insert request into db
@@ -105,7 +102,7 @@ def export_persistOperation(self, opJSON):
105102

106103
return self.fts3db.persistOperation(opObj)
107104

108-
types_getOperation = [six.integer_types]
105+
types_getOperation = [int]
109106

110107
@classmethod
111108
def export_getOperation(cls, operationID):
@@ -117,14 +114,14 @@ def export_getOperation(cls, operationID):
117114
"""
118115
getOperation = cls.fts3db.getOperation(operationID)
119116
if not getOperation["OK"]:
120-
gLogger.error("getOperation: %s" % getOperation["Message"])
117+
gLogger.error("getOperation:", getOperation["Message"])
121118
return getOperation
122119

123120
getOperation = getOperation["Value"]
124121
opJSON = encode(getOperation)
125122
return S_OK(opJSON)
126123

127-
types_getActiveJobs = [six.integer_types, [type(None)] + [six.string_types], six.string_types]
124+
types_getActiveJobs = [int, [type(None)] + [str], str]
128125

129126
@classmethod
130127
def export_getActiveJobs(cls, limit, lastMonitor, jobAssignmentTag):
@@ -168,7 +165,7 @@ def export_updateJobStatus(cls, jobStatusDict):
168165
jobStatusDict = strToIntDict(jobStatusDict)
169166
return cls.fts3db.updateJobStatus(jobStatusDict)
170167

171-
types_getNonFinishedOperations = [six.integer_types, six.string_types]
168+
types_getNonFinishedOperations = [int, str]
172169

173170
@classmethod
174171
def export_getNonFinishedOperations(cls, limit, operationAssignmentTag):
@@ -188,7 +185,7 @@ def export_getNonFinishedOperations(cls, limit, operationAssignmentTag):
188185

189186
return S_OK(nonFinishedOperationsJSON)
190187

191-
types_getOperationsFromRMSOpID = [six.integer_types]
188+
types_getOperationsFromRMSOpID = [int]
192189

193190
@classmethod
194191
def export_getOperationsFromRMSOpID(cls, rmsOpID):
@@ -200,7 +197,7 @@ def export_getOperationsFromRMSOpID(cls, rmsOpID):
200197
"""
201198
res = cls.fts3db.getOperationsFromRMSOpID(rmsOpID)
202199
if not res["OK"]:
203-
gLogger.error("getOperationsFromRMSOpID: %s" % res["Message"])
200+
gLogger.error("getOperationsFromRMSOpID", res["Message"])
204201
return res
205202

206203
operations = res["Value"]

src/DIRAC/DataManagementSystem/Service/FileCatalogHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from DIRAC.DataManagementSystem.DB.FileCatalogDB import FileCatalogDB
1414

1515

16-
class FileCatalogHandlerMixin(object):
16+
class FileCatalogHandlerMixin:
1717
"""
1818
A simple Replica and Metadata Catalog service.
1919
"""

src/DIRAC/DataManagementSystem/Service/S3GatewayHandler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import errno
1515

1616
# from DIRAC
17-
import six
1817
from DIRAC import S_OK, S_ERROR, gLogger
1918

2019
from DIRAC.Core.DISET.RequestHandler import RequestHandler
@@ -93,7 +92,7 @@ def _hasAccess(self, lfn, s3_method):
9392

9493
return returnSingleResult(self._fc.hasAccess(lfn, opType))
9594

96-
types_createPresignedUrl = [six.string_types, six.string_types, (dict, list), six.integer_types]
95+
types_createPresignedUrl = [str, str, (dict, list), int]
9796

9897
def export_createPresignedUrl(self, storageName, s3_method, urls, expiration):
9998
"""Generate a presigned URL for a given object, given method, and given storage

src/DIRAC/DataManagementSystem/Service/StorageElementHandler.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import re
2929
import errno
3030
import shlex
31-
import six
3231

3332
# from DIRAC
3433
from DIRAC import gLogger, S_OK, S_ERROR
@@ -226,15 +225,15 @@ def __getFileStat(path):
226225

227226
return S_OK(resultDict)
228227

229-
types_exists = [six.string_types]
228+
types_exists = [str]
230229

231230
def export_exists(self, fileID):
232231
"""Check existence of the fileID"""
233232
if os.path.exists(self.__resolveFileID(fileID)):
234233
return S_OK(True)
235234
return S_OK(False)
236235

237-
types_getMetadata = [six.string_types]
236+
types_getMetadata = [str]
238237

239238
def export_getMetadata(self, fileID):
240239
"""Get metadata for the file or directory specified by fileID"""
@@ -260,7 +259,7 @@ def export_getTotalDiskSpace():
260259
"""
261260
return getTotalDiskSpace()
262261

263-
types_createDirectory = [six.string_types]
262+
types_createDirectory = [str]
264263

265264
def export_createDirectory(self, dir_path):
266265
"""Creates the directory on the storage"""
@@ -282,7 +281,7 @@ def export_createDirectory(self, dir_path):
282281
gLogger.error("StorageElementHandler.createDirectory: %s" % errStr, repr(x))
283282
return S_ERROR(errStr)
284283

285-
types_listDirectory = [six.string_types, six.string_types]
284+
types_listDirectory = [str, str]
286285

287286
def export_listDirectory(self, dir_path, mode):
288287
"""Return the dir_path directory listing"""
@@ -419,7 +418,7 @@ def transfer_bulkToClient(self, fileId, token, fileHelper):
419418
gLogger.error("Failed to send bulk to network", res["Message"])
420419
return res
421420

422-
types_remove = [six.string_types, six.string_types]
421+
types_remove = [str, str]
423422

424423
def export_remove(self, fileID, token):
425424
"""Remove fileID from the storage. token is used for access rights confirmation."""
@@ -440,7 +439,7 @@ def __removeFile(self, fileID, token):
440439
else:
441440
return S_ERROR("File removal %s not authorized" % fileID)
442441

443-
types_getDirectorySize = [six.string_types]
442+
types_getDirectorySize = [str]
444443

445444
def export_getDirectorySize(self, fileID):
446445
"""Get the size occupied by the given directory"""
@@ -455,7 +454,7 @@ def export_getDirectorySize(self, fileID):
455454
else:
456455
return S_ERROR("Directory does not exists")
457456

458-
types_removeDirectory = [six.string_types, six.string_types]
457+
types_removeDirectory = [str, str]
459458

460459
def export_removeDirectory(self, fileID, token):
461460
"""Remove the given directory from the storage"""
@@ -475,7 +474,7 @@ def export_removeDirectory(self, fileID, token):
475474
gLogger.error(str(error))
476475
return S_ERROR("Failed to remove directory %s" % dir_path)
477476

478-
types_removeFileList = [list, six.string_types]
477+
types_removeFileList = [list, str]
479478

480479
def export_removeFileList(self, fileList, token):
481480
"""Remove files in the given list"""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Service handler for DataIntegrity using https
3+
4+
.. literalinclude:: ../ConfigTemplate.cfg
5+
:start-after: ##BEGIN TornadoDataIntegrity
6+
:end-before: ##END
7+
:dedent: 2
8+
:caption: TornadoDataIntegrity options
9+
10+
"""
11+
12+
from DIRAC import gLogger
13+
from DIRAC.Core.Tornado.Server.TornadoService import TornadoService
14+
from DIRAC.DataManagementSystem.Service.DataIntegrityHandler import DataIntegrityHandlerMixin
15+
16+
sLog = gLogger.getSubLogger(__name__)
17+
18+
19+
class TornadoDataIntegrityHandler(DataIntegrityHandlerMixin, TornadoService):
20+
"""Tornado handler for the DataIntegrityHandler"""
21+
22+
log = sLog

0 commit comments

Comments
 (0)