|
1 | | -""" The FileCatalogClient is a class representing the client of the DIRAC File Catalog |
2 | | -""" |
| 1 | +"""The FileCatalogClient is a class representing the client of the DIRAC File Catalog""" |
| 2 | + |
3 | 3 | import json |
4 | 4 | import os |
5 | 5 |
|
6 | 6 | from DIRAC import S_OK, S_ERROR |
| 7 | +from DIRAC.Core.Utilities.List import breakListIntoChunks |
7 | 8 | from DIRAC.Core.Tornado.Client.ClientSelector import TransferClientSelector as TransferClient |
8 | 9 |
|
9 | 10 | from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOMSAttributeForGroup, getDNForUsername |
10 | 11 | from DIRAC.Resources.Catalog.Utilities import checkCatalogArguments |
11 | 12 | from DIRAC.Resources.Catalog.FileCatalogClientBase import FileCatalogClientBase |
12 | 13 |
|
| 14 | +GET_REPLICAS_CHUNK_SIZE = 10_000 |
| 15 | + |
13 | 16 |
|
14 | 17 | class FileCatalogClient(FileCatalogClientBase): |
15 | 18 | """Client code to the DIRAC File Catalogue""" |
@@ -135,14 +138,20 @@ def __init__(self, url=None, **kwargs): |
135 | 138 | @checkCatalogArguments |
136 | 139 | def getReplicas(self, lfns, allStatus=False, timeout=120): |
137 | 140 | """Get the replicas of the given files""" |
138 | | - rpcClient = self._getRPC(timeout=timeout) |
139 | | - result = rpcClient.getReplicas(lfns, allStatus) |
| 141 | + successful = {} |
| 142 | + failed = {} |
140 | 143 |
|
141 | | - if not result["OK"]: |
142 | | - return result |
| 144 | + for chunk in breakListIntoChunks(lfns, GET_REPLICAS_CHUNK_SIZE): |
| 145 | + rpcClient = self._getRPC(timeout=timeout) |
| 146 | + result = rpcClient.getReplicas(chunk, allStatus) |
| 147 | + |
| 148 | + if not result["OK"]: |
| 149 | + return result |
| 150 | + successful.update(result["Value"]["Successful"]) |
| 151 | + failed.update(result["Value"]["Failed"]) |
143 | 152 |
|
144 | 153 | # If there is no PFN returned, just set the LFN instead |
145 | | - lfnDict = result["Value"] |
| 154 | + lfnDict = {"Successful": successful, "Failed": failed} |
146 | 155 | for lfn in lfnDict["Successful"]: |
147 | 156 | for se in lfnDict["Successful"][lfn]: |
148 | 157 | if not lfnDict["Successful"][lfn][se]: |
|
0 commit comments