kgiusti commented on a change in pull request #503: DISPATCH-974 - Added code 
to qdstat and qdmanage clients to repeatedl…
URL: https://github.com/apache/qpid-dispatch/pull/503#discussion_r282879722
 
 

 ##########
 File path: python/qpid_dispatch/management/client.py
 ##########
 @@ -225,12 +225,61 @@ def query(self, type=None, attribute_names=None, 
offset=None, count=None):
         @keyword count: A count of the maximum number of results to return.
         @return: A L{QueryResponse}
         """
-        request = self.node_request(
-            {u'attributeNames': attribute_names or []},
-            operation=u'QUERY', entityType=type, offset=offset, count=count)
 
-        response = self.call(request)
-        return Node.QueryResponse(self, response.body[u'attributeNames'], 
response.body[u'results'])
+        # There is a bug in proton (PROTON-1846) wherein we cannot ask for
+        # too many rows. So, as a safety we are going to ask only for
+        # MAX_ALLOWED_COUNT_PER_REQUEST. Since this is used by both qdstat
+        # and qdmanage, we have determined that the optimal value for
+        # MAX_ALLOWED_COUNT_PER_REQUEST is 700
+        MAX_ALLOWED_COUNT_PER_REQUEST = 700
+
+        response_results = []
+        response_attr_names = []
+        if offset is None:
+            offset = 0
+
+        if count is None:
+            # count has not been specified. For each request the
+            # maximum number of rows we can get without proton
+            # failing is MAX_ALLOWED_COUNT_PER_REQUEST
+            request_count = MAX_ALLOWED_COUNT_PER_REQUEST
+        else:
+            if count > MAX_ALLOWED_COUNT_PER_REQUEST:
+                request_count = MAX_ALLOWED_COUNT_PER_REQUEST
+            else:
+                request_count = count
+
+        while True:
+
+            request = self.node_request(
+                {u'attributeNames': attribute_names or []},
+                operation=u'QUERY', entityType=type, offset=offset,
+                count=request_count)
+
+            response = self.call(request)
+
+            if not response_attr_names:
+                response_attr_names += response.body[u'attributeNames']
+
+            response_results += response.body[u'results']
 
 Review comment:
   You might consider using a map indexed by entity id here as a way to filter 
out duplicates.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to