METRON-958: PCAP Query job throws exception when no files returned by time range query#593
METRON-958: PCAP Query job throws exception when no files returned by time range query#593mmiklavc wants to merge 5 commits intoapache:masterfrom
Conversation
… time range query
|
I also attempted to start using the Google codestyle format in IntelliJ for this PR. It seems a couple things don't match up neatly with the checkstyle plugin using Google's style guide, but I haven't looked into it yet. |
|
@mmiklavc Not everything gets handled by the auto-formatter,. Still do due diligence, because there may be some issue but some things will still get flagged by checkstyle without getting fixed by the autoformatter (e.g. if params are on newlines, it wants the comma with the previous params. Autoformat can't (won't?) do anything about it). My experience was that significantly more checkstyle issues got fixed with the Google profile. |
|
Added fix for the actual empty result set problem |
|
Here are some instructions for getting pycapa setup |
|
Kick to the Travis |
|
+1 worked as advertised. I tested this in full dev using a topic with an '_' character in the name. A query within the time range returned results and a query outside of the time range returned a "No results returned" message and did not throw an exception. I did notice that when I set the query time range to a different day or month a map reduce job still ran. Is this expected? I would expect the query map reduce job to be smart enough to exclude files in this case. That is outside the scope of this PR but wanted to bring it up. |
|
Thanks @merrimanr! Good observation on the start/end date. Part of the problem is that we don't know how large the file time ranges are or when they will roll over, so we might still miss some if we try to exclude by day. We might be able to add some clues to help with this though. |
https://issues.apache.org/jira/browse/METRON-958
When the PCAP topology is run against a Kafka topic with multiple partitions, there will be at least one file per partition. The current MR job only expects adding a left trailing file for a single partition, so we miss files when performing the filter by timestamp on the filenames and it ends up throwing an exception.
Testing
Part 1
To test this, run a pcap topology against a Kafka topic with multiple partitions, preferably 3 or more. You'll also want to set kafka.pcap.maxTimeMS to something like 5 minutes (300000). You'll need to install pycapa and run it to create some data - https://github.com/apache/metron/tree/master/metron-sensors/pycapa. Let it run for 4-5 minutes. To keep it simple, stop it shy of 5 minutes so there's only 1 large-ish file per partition.
Run pcap inspector on one of the files and make note of the starting and ending time. Pick a time in the middle and run a pcap query using that time, down to the minute, as a filter. e.g.
${METRON_HOME}/bin/pcap_query.sh query -df "yyyyMMddHHmm" -st 201705162000 --query ""EDIT - also try this with a Kakfa partition name that includes underscores, e.g.
pcap_5Part 2
Run a pcap query with a time outside of the range of times included in the pcap data and verify an exception is not thrown.
https://cwiki.apache.org/confluence/display/METRON/PCAP+CLI+Tool
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 incubating-metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
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.