Throttle Overlay - Match subrequests with received responses

Poster Content
nk4um User
Posts: 90
May 2, 2016 14:22

Hi Tony,

is the second solution a hack because internals can change in the future?

In the meantime I worked around by adding an argument to the subrequest. This works fine though I'm not sure if arguments should be used for such information, which is more a processing hint or some kind of metadata.

Thanks for the quick response,


Like · Post Reply
nk4um Moderator
Posts: 595
May 2, 2016 09:32

Hi Stefan,

the way to get the request correlated with the response you receive is to use

INKFRequest response.getRequest()

However this doesn't have methods to interrogate the headers as it's designed write-only for constructing an outgoing request.

Two options: 1) either correlate the request yourself and use your own map to store the size data 2) (HACK) cast INKFRequest to NKFRequestImpl and the use .getKernelRequest() - this will give you access to the internals

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 90
May 1, 2016 19:00Throttle Overlay - Match subrequests with received responses


I'm using a ThrottleOverlay to control access to a memory intensive endpoint. Inside the throttle the incoming requests are inspected by an arguments value size and a variable issuedRequests is adapted accordingly. E.g. small size adds 1 and large size adds 2 so with a concurrency of 4 throughput varies from maximal 4 to minimal 2. The problem is that inside the method

receiveResponse(INKFResponseReadOnly response,
            INKFRequestContext aContext)

I need to know which response was sent back, one with a small or large size, to adapt issuedRequests accordingly. I tried to set a header 'type' on the issued subrequest, but inside receiveResponse I found no way to read this header:

- response.getHeaders() has no headers at all

- aContext.getThisRequest().getHeaders() has all the headers of the very first request but not the header 'type' which was set on the subrequest

- inside the response is a private field mRequest which has all original headers plus the header 'type' but I found no way to access them.

Is there a solution to mark a subrequest inside a throttle and then find it again in the receiveResponse method without extra bookkeeping?

Thanks a lot,


Like · Post Reply