[ 
https://issues.apache.org/jira/browse/HDDS-585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Elek, Marton updated HDDS-585:
------------------------------
    Status: Patch Available  (was: Open)

The trick here is that I created a @RequestScoped holder class which is created 
for each request by the CDI framework. We don't need anything but inject it to 
the exception handler and CommonHeadersContainerResponseFilter and exactly the 
same requestId will be available everywhere.

Examples:

{code}
 curl -X DELETE -v localhost:9878/vol1/bucket2                     
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9878 (#0)
> DELETE /vol1/bucket2 HTTP/1.1
> Host: localhost:9878
> User-Agent: curl/7.61.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Mon, 08 Oct 2018 14:47:56 GMT
< Cache-Control: no-cache
< Expires: Mon, 08 Oct 2018 14:47:56 GMT
< Date: Mon, 08 Oct 2018 14:47:56 GMT
< Pragma: no-cache
< Content-Type: application/xml
< X-Content-Type-Options: nosniff
< X-FRAME-OPTIONS: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: Ozone
< x-amz-id-2: SlcosVEJ58X0
< x-amz-request-id: 0fa5d6bc-e7d4-4d6e-8cd7-cb1905cab59f
< Content-Length: 233
< 
<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>NoSuchBucket</Code>
  <Message>The specified bucket does not exist</Message>
  <Resource>Bucket</Resource>
  <RequestId>0fa5d6bc-e7d4-4d6e-8cd7-cb1905cab59f</RequestId>
</Error>
{code}

(Please note that the requestIds in the header and in the error are the same)


Without error: 

{code}
curl -X DELETE -v localhost:9878/vol1/bucket
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9878 (#0)
> DELETE /vol1/bucket HTTP/1.1
> Host: localhost:9878
> User-Agent: curl/7.61.1
> Accept: */*
> 
< HTTP/1.1 204 No Content
< Date: Mon, 08 Oct 2018 14:47:40 GMT
< Cache-Control: no-cache
< Expires: Mon, 08 Oct 2018 14:47:40 GMT
< Date: Mon, 08 Oct 2018 14:47:40 GMT
< Pragma: no-cache
< Content-Type: text/plain;charset=utf-8
< X-Content-Type-Options: nosniff
< X-FRAME-OPTIONS: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: Ozone
< x-amz-id-2: xYrTS8YCOp2V
< x-amz-request-id: c091a4b2-3f69-4fd4-b6fd-192517faf157
< 
* Connection #0 to host localhost left intact
{code}

> Handle common request identifiers in a transparent way
> ------------------------------------------------------
>
>                 Key: HDDS-585
>                 URL: https://issues.apache.org/jira/browse/HDDS-585
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>            Reporter: Elek, Marton
>            Assignee: Elek, Marton
>            Priority: Major
>         Attachments: HDDS-585.001.patch
>
>
> As of now multiple endpoint contains the code to handle the amazon specific 
> request id-s.
> {code}
>     setRequestId(OzoneUtils.getRequestID());
> ...
>     return Response.ok().status(HttpStatus.SC_NO_CONTENT).header(
>         "x-amz-request-id", getRequestId()).header("x-amz-id-2",
>         RandomStringUtils.randomAlphanumeric(8, 16)).build();
> {code}
> I propose to handle the request id generation + adding it to the headers in 
> one location which is transparent for all the rest endpoints.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to