-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-2148: Stellar REST POST function #1440
Conversation
|
This is cool, but wouldn't https support be needed for real world application? |
|
I understand that if GET doesn't have it, then we've already decided to put that off, but do we have a plan? |
|
I will do some research into adding SSL support, maybe it's a minimal amount of extra code. I would prefer to add that incrementally in a separate PR since code reviews seem to go faster when split into smaller units of work. I think REST POST support without SSL is an improvement on it's own. |
|
Having worked with the nifi SSL Controller Service, it isn't a small thing. but it is important. I'm fine with doing it later, but please create an investigate jira or something to link to this, so if someone wants to they can pick it up |
|
@merrimanr - did we ever get a Jira for the follow-on @ottobackwards mentioned? Can you link it back here in the comments as well as link it with the Jira for this PR (ie add a "relates-to" relationship to this Jira and the one for REST_GET)? |
|
@ottobackwards here is the SSL Jira: https://issues.apache.org/jira/browse/METRON-2165. Feel free to add any requirements you want. |
mmiklavc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one potential issue stands out to me here, nice work @merrimanr.
| httpRequestBase.setConfig(getRequestConfig(restConfig, proxy)); | ||
|
|
||
| // Schedule a command to abort the request if the timeout is exceeded | ||
| ScheduledFuture scheduledFuture = scheduledExecutorService.schedule(httpRequestBase::abort, restConfig.getTimeout(), TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to manage timeouts on our end? e.g. https://www.baeldung.com/httpclient-timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the link you reference:
HttpClient doesn’t have any configuration that allows us to set an overall timeout for a request; it does, however, provide abort functionality for requests, so we can leverage that mechanism to implement a simple timeout mechanism:
|
+1 by inspection, thanks @merrimanr! |
Contributor Comments
This PR adds a
REST_POSTStellar function with syntax and options similar to the existingREST_GETfunction for performing REST POST requests. A Stellar map can now be passed into the function and added to the request as query parameters (this feature was added toREST_GETas well). Separate global configs were added forREST_GETandREST_POSTin addition to the existing global config for REST functions. ForREST_POSTrequests, there is also an optionenforce.jsonthat ensures POST data is well-formed JSON.Changes Included
REST_POSTStellar function was added toRestFunctionsclass.RestFunctionsclass was refactored by moving common code used byREST_GETandREST_POSTto their own methods. Now code specific to either functions mostly consists of argument parsing and request building.RestFunctionsclass should be 100% covered.REST_POSTfunction and additional options added to both.Testing
This has been tested in full dev. Since there were significant changes to
RestFunctionsI regression tested using the test instructions in original Stellar Rest PR. Note a regression was introduced when using theREST_GETfunction in the enrichment topology (class version error). This is being addressed here.In addition to this I also followed these instructions:
Assuming full dev has already been spun up during regression testing described above, start the Stellar shell with
/usr/metron/0.7.2/bin/stellar --zookeeper node1:2181.Defined a variable to hold POST data:
The request should succeed with the correct POST data in the response.
The
argsandurlattributes in the response should contain the query parameters.The response should match the override value set in the config.
The response should match the global override value set in the config.
The response should match the rest post override value set in the config.
9 Configure the override in a variable that will be passed to the function:
The response should match the override in the config passed to the function.
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html:Have you ensured that any documentation diagrams have been updated, along with their source files, using draw.io? See Metron Development Guidelines for instructions.
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.