GitHub user cestella opened a pull request: https://github.com/apache/metron/pull/795
METRON-1241: Enable the REST API to use a cache for the zookeeper config similar to the Bolts ## Contributor Comments Currently, our bolts use a TreeCache to capture and update internal state. The REST API, on the other hand, polls zookeeper every time a request is made to retrieve a configuration, a poll model. Rather than do this, it would be better to share an abstraction between the two pieces of infrastructure to enable the REST API to be backed by a TreeCache, which will prevent zookeeper from being abused and migrate it to a push model. Testing instruction to come. ## Pull Request Checklist Thank you for submitting a contribution to Apache Metron. Please refer to our [Development Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235) for the complete guide to follow for contributions. Please refer also to our [Build Verification Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview) 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: - [ ] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel). - [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [x] Has your PR been rebased against the latest commit within the target branch (typically master)? ### For code changes: - [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed? - [x] Have you included steps or a guide to how the change may be verified and tested manually? - [x] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via: ``` mvn -q clean integration-test install && build_utils/verify_licenses.sh ``` - [x] Have you written or updated unit tests and or integration tests to verify your changes? - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [x] 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: - [x] 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`: ``` cd site-book mvn site ``` #### 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](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request. You can merge this pull request into a Git repository by running: $ git pull https://github.com/cestella/incubator-metron zookeeper_refactor Alternatively you can review and apply these changes as the patch at: https://github.com/apache/metron/pull/795.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #795 ---- commit 0570ba18d773688bfc2d71e2f081155583c21a2e Author: cstella <ceste...@gmail.com> Date: 2017-10-09T19:03:32Z Abstracting zookeeper substantially. commit e59a82266c7cefb2a4fe6c033e9b14c2fe7c001b Author: cstella <ceste...@gmail.com> Date: 2017-10-09T20:10:57Z Updating tests to use the new API. commit 8d64f05f33bb248ae3306cb580ac589400887b81 Author: cstella <ceste...@gmail.com> Date: 2017-10-09T20:15:51Z Missed a couple of tests. commit a195ae51e3c5a04079c2b401ae325bcf4e46c05e Author: cstella <ceste...@gmail.com> Date: 2017-10-09T20:32:41Z moved the cache into commons. commit 0932c30e9af4b75285c7003e722888e4a5675f9f Author: cstella <ceste...@gmail.com> Date: 2017-10-09T21:15:20Z Updating test. commit 7c05716ceb6db505ec323f7b04716df07399a05c Author: cstella <ceste...@gmail.com> Date: 2017-10-09T23:41:44Z Refactored tests to mock the configurations cache commit 8a295a271fe94995283e02b2b291f50ec2db30ef Author: cstella <ceste...@gmail.com> Date: 2017-10-10T00:13:41Z fixing tests. commit dd41e6ed9a28a3b30102aad76f5396c51cf540f4 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T00:54:57Z Updating some weird bugs. commit 24df486a0c0d254f14f298ba8fb09e14152a2bf8 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T01:47:05Z updating config test. commit e6d48efd03bd848ca4eefd11c4277b2148550330 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T02:42:48Z Updating log4j properties to debug travis. commit 3e320d63512a860f571ee3fc0a8b41fa98b7558d Author: cstella <ceste...@gmail.com> Date: 2017-10-10T02:59:00Z updating with better logging commit 09019a52a4c689cdb71b512643c6f381dec114cf Author: cstella <ceste...@gmail.com> Date: 2017-10-10T03:17:20Z reducing logging. commit 9948df08bd2dc7a11e10bf800fe71427ba482b44 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T03:41:32Z Removing debugging commit 9134b81a5e1d5200e698131b0f66fc3ea015c56b Author: cstella <ceste...@gmail.com> Date: 2017-10-10T03:45:41Z Better error debugging... commit bbe87c5f1e29cb362f0dac90eb33f537285c1b27 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T03:47:21Z Warn level. commit 105127ed32003f0defdc7a7bed1f7357a69128ab Author: cstella <ceste...@gmail.com> Date: 2017-10-10T03:55:34Z Small error in getTypes() commit 475853cb72ab891ead4a360ca37c0e53035ba183 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T04:36:11Z Updating configurations util commit a0ce71be196b6c8c068a2f4ee4697af5a4e8d0f1 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T04:45:35Z Updating integration tests. commit c3c3c36e664c9e9216e04c72a06005a37d2a2652 Author: cstella <ceste...@gmail.com> Date: 2017-10-10T06:21:18Z Fixing tests. ---- ---