-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-1674: Create REST endpoint for job status abstraction #1109
METRON-1674: Create REST endpoint for job status abstraction #1109
Conversation
Pcap job manager generics from cestella
…r for synchronicity. Kill remnants of the job service.
…into pcap-job-manager
Get PcapTopologyIntegrationTest working
| return pcapJob.submit(PcapFinalizerStrategies.REST, pcapRequest); | ||
| } catch (JobException e) { | ||
| return null; | ||
| //return new JobStatus().withState(JobStatus.State.FAILED).withDescription(JobStatus.State.FAILED.toString()); |
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.
Is this intended? Seems like we should be passing back info about the exception or at the very least throwing a runtime exception, right?
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.
Yes this was a mistake. A runtime exception is thrown now.
|
|
||
| public static byte[] readBytes(Path inPath) throws IOException { | ||
| FileSystem fs = FileSystem.get(inPath.toUri(), new Configuration()); | ||
| FSDataInputStream inputStream = fs.open(inPath); |
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.
This should be in a try with resources block otherwise you're leaving streams open.
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.
I retract this, it originated in @mmiklavc 's PR. I moved the comment there.
cestella
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.
This is looking good, I'm going to try to pick out the parts that are unique to this and not @mmiklavc 's ticket for review. I'll make another pass in a bit.
|
Here is what I've done so far: Capture a random PCAP using tcpdump, place that PCAP into /apps/metron/pcap/input on HDFS, run the service in Swager under POST /api/v1/pcap/fixed I send { which are the right timestamps for my PCAP, and get back an error: { Which in metron-rest.log corresponds to: Jul 18, 2018 6:00:45 AM org.apache.catalina.core.StandardWrapperValve invoke |
|
The latest commit addresses feedback received so far. I also changed the structure of the HDFS paths to avoid issues around reading input and also to output data to unique locations. Previously all data was written to @james-sirota this should resolve the error you were getting. |
|
+1 works great. I was able to put the output of the pcap topology into a directory in HDFS, run a query over it, got a page in the output directory (with status correctly updating while the job was running), was able to open the page in wireshark |
| @Override | ||
| protected Path getOutputPath(Map<String, Object> config, int partition) { | ||
| String jobId = PcapOptions.JOB_ID.get(config, String.class); | ||
| String finalOutputPath = PcapOptions.FINAL_OUTPUT_PATH.get(config, String.class); |
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 isn't the user passed into the config rather than being in a member variable? This seems inconsistent. I'd expect a PcapOptions.USERNAME.get(config, String.class) rather than a member variable.
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.
The reason I did it that way is because that user property is only used here. Happy to change it to a config.
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.
@merrimanr Yeah, let's do what we did with the interim output path. We've gone down the Map config path so I think we should keep that consistent. There may be some brainstorming we can do around creating pointed option validation (e.g. specific to a finalizer), but for now the PcapOptions route seems sufficient to me.
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.
Done
…r cestella request.
…into pcap-job-manager
…anel' into pcap-job-manager
|
Is it necessary to have /{user}/{jobType}/ in the output url? On our side, pageId is a simple int at the moment. Is "page-*" at the end of the URL pattern means the service expecting something like "page-5"? |
|
@tiborm That is an HDFS path, not a URL. It's of no concern to the UI. |
|
I see, thanks. Is there an endpoint for the PDML output? |
|
That PR should be up for review soon. |
Contributor Comments
This PR is built on top of #1108 and should be merged and final review done after that is accepted into the feature branch. This exposes the job manager and job status abstraction through a REST endpoint.
A summary of the changes included:
startTimeMsandendTimeMsThis has been tested in full dev. The HDFS paths must be created manually for the paths specified in application.yml:
To test in full dev, create the HDFS directories mentioned above and put pcap data in
/apps/metron/pcap/input. Submit a fixed pcap query:A job id should be returned in the response:
Job status can now be retrieved using the get job status endpoint:
Check the job status with this endpoint for the next minute or so. The
percentCompletefield in the response should increase over time:The
jobStatusfield should transition from RUNNING > FINALIZING > SUCCEEDED. Once the job is in the SUCCEEDED state, the results should be available in HDFS. The result path will follow this pattern:Depending on the page size, the output should look something like:
A full, comprehensive review should be done after #1108 has been merged.
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: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.