Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Conversation

@ottobackwards
Copy link
Contributor

@ottobackwards ottobackwards commented Sep 27, 2017

This PR contains the Bundle system and Maven Plugin.

The bundle system and the plugin are adapted from the Apache Nifi project.

bundles-maven-plugin

The bundles-maven-plugin is an adapted version of the jar dependency plugin whose function is to bundle a jar of jars based on the dependencies for a project. It also creates metadata attributes.
A project's jar, and it's non-provided dependency jars are place in a /lib entry in the bundle, with the bundle itself being in jar format.

bundles-lib

The bundles-lib contains the functionality required to:

  • discover bundles
  • inspect bundles for exposed extension types
  • load the bundles
  • create special class loaders for bundles
  • deliver instances of extension types for use

NAR exposed the bundles through many classes. I have created the BundleSystem interface to expose a more usable, simplified api for our use cases.

From the original PR for METRON-777:

Metron Bundle Plugin

  • adaptation of the nifi plugin
  • more configurable wrt file extension/dependency and metadata naming
    bundle-lib
  • adaptation of nifi-nar-utils to be used outside of the nifi project
  • rudimentary extensibility to allow configuration and injection of service types and other things that were hard coded to nifi
  • refactored from File based to VFS based
  • rebranding to Bundle from Nar ( although the lib and the plugin allow that to be configured now )
  • added capability to the properties class to write to stream, adapted to uri from paths
  • added integration tests for hdfs
  • changed to be ClassIndex based instead of ServiceLoader. Service loader is slower, and Casey's ClassIndex work is great. This also removes the NAR's required manual maintenance of the service file.
  • refactored to use VFS to load the bundle/nar into the classloader AND to use VFS to load the dependency jars -> VFS as a composite filesystem. Thus going from NAR's 'working directory', exploded NARS to just loading the bundle/nar.

Previous Review

Please see @mattf_apache's review

changes from that review

I have changed the InitContext operations to have explicit builders, and made it so that creating a context can be done separately from initialization. Two contexts can then be 'merged'. This is to allow for the addition of new bundles after initialization.

In preparing this PR I have:

  • made checkstyle fixes
  • fixed several types
  • added a requested set of tests loading and executing simple interface/implementation from bundle beyond what is already in the bundle-lib tests

Testing

*cd bundles-maven-plugin && mvn -q install && cd .. must be run once to install the maven plugin

  • This review is code review and test code review and running only
  • Test Project can be examined as a simple example of how to create bundles.
  • The README.md has getting started and quickstart sections with some overview of creating by hand

For all changes:

  • Is there a JIRA ticket associated with this PR? If not one needs to be created at Metron Jira.
  • 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.
  • Has your PR been rebased against the latest commit within the target branch (typically master)?
  • Have you ensured that the full suite of tests and checks have been executed in the root metron \
  • Have you written or updated unit tests and or integration tests to verify your changes?

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?

@ottobackwards
Copy link
Contributor Author

ottobackwards commented Sep 27, 2017

@bbende
this is going in as a separate PR now. I am not sure if you are interested or not, but I figure I'll give you a heads up.

@ottobackwards
Copy link
Contributor Author

FlatFile tests are failing with timeouts, kicking

@nickwallen
Copy link
Contributor

nickwallen commented Oct 8, 2017

@ottobackwards Are we having intermittent test failures again?

@ottobackwards
Copy link
Contributor Author

On that day the Flat File test failed. Since it worked after open/close I wrote it off to a load / timing issue.

https://travis-ci.org/apache/metron/builds/280393026

@ottobackwards
Copy link
Contributor Author

From a quick check of other PR travis failures, it looks like my build was the only one to have that problem ( which as an expected 1000 got 908 issue )

@nickwallen
Copy link
Contributor

This review is code review and test code review and running only

I have just started into this, but seems like I can create a bundle using the Maven plugin with this PR, right?

@ottobackwards
Copy link
Contributor Author

yes you can

@ottobackwards
Copy link
Contributor Author

Testing the bundle plugin

I have created a sample project that can be examined for testing the plugin:

test-bundles-plugin

@JonZeolla
Copy link
Member

@nickwallen are you still looking at this?

@nickwallen
Copy link
Contributor

No, I need to get back to this. Are you? Don't let me stop your own review.

@nickwallen
Copy link
Contributor

nickwallen commented Oct 23, 2017

@nickwallen: I have just started into this, but seems like I can create a bundle using the Maven plugin with this PR, right?
@ottobackwards: yes you can

This was more of a leading question. Can we add this step to the test plan? Can you point to the directions on creating a bundle?

Is there anything else that should be part of the test plan?

@JonZeolla
Copy link
Member

@nickwallen I am doing some functional testing, but I'm not comfortable enough with it to give a full +1 on my own. When I'm done I will report back.

@nickwallen
Copy link
Contributor

Sounds good @JonZeolla thanks

@nickwallen
Copy link
Contributor

Test Project can be examined as a simple example of how to create bundles.

@ottobackwards Maybe I'm being really stupid, but I don't understand how the test-bundles-plugin shows me how to create bundles.

Wouldn't I use the code in this PR to create something like the test-bundles-plugin? Does that make sense?

What command do I run to create a bundle? How do I validate that the bundle created is valid?

@ottobackwards
Copy link
Contributor Author

Thanks for looking at this again Nick, let me try to answer your questions.

TL;DR

I'm sorry for my confusion with your original statement. I had in mind this part of @mattf-horton 's email on these pull requests:

The first PR will be just the “bundle” mechanism and the maven plugin.
Both are adaptations from the Apache NiFi project, and have already been
reviewed as part of PR# 530. Review is acknowledged to be purely
theoretical, and testing is based on the junit tests and integration
tests.

I thought an example project to look at would answer your question, not that you actually wanted to do it, or have instructions to do it. Especial since you didn't say "the readme should have better instructions for creating a project that uses the plugin".

While creating bundles by hand is not in the initial use case, if you feel it is important I'll write a readme.


As with the NiFi version of the maven plugin, the 100% use case in practice ( and for initial dev in metron ) is to have bundles create as part of the archetype project generation. When I 'adapted' the maven plugin, which consisted of adding the ability to rename the extension of the product and change the metadata prefixes, I did not make changes to the documentation of the plugin beyond documenting my changes. I also did not attempt to add maven test harness support for the plugin, as it was not present in the original project. Thus, the create by hand scenario for our version is as lacking as the create by hand scenario is in the origin nifi project. I tried to avoid changing the plugin as much as possible, as it is already in use in NiFi.

As we had discussed in the threads and the meetings, this initial PR would contain the plugin and the bundle, and the practical testing would be limited. I created and added reference to the test project because it is a simple example of a project that utilizes the plugin to create a bundle. I did this as opposed to writing out a step by step guide to how to create a multi module maven project, as I mistakenly thought this would be helpful given the context of the review.

@mattf-horton, would it be possible for you to help us with a comment as to your approach when you reviewed this functionality? It might help if you could summarize your feelings as well. The context is different, as the review within 777 could not be a +1 for the PR since this was only part of the total, but since you are the only one to have had reviewed this, your views are pretty important.

@ottobackwards
Copy link
Contributor Author

I will extend the readme

@ottobackwards
Copy link
Contributor Author

@nickwallen hopefully the Readme changes help.

@mattf-apache
Copy link
Member

mattf-apache commented Oct 27, 2017

@ottobackwards says:

would it be possible for you to help us with a comment as to your approach when you reviewed this functionality? It might help if you could summarize your feelings as well

{with music}
Oh spelunking we shall go, spelunking we shall go... :-)
{with music}

While reviewing the original incarnation of this, I tried to focus on the part most other Metron community members wouldn't be familiar with, the NiFi Bundle implementation, which I have some (small) experience with due to past work with NiFi. The review I did was an eyeball line-by-line code review. Of course actually running the code is also necessary, and at the time @mmiklavc was focusing on that side of things.

Knowing that (a) the NiFi feature works in NiFi, and (b) Otto's intent was to change it as little as possible while porting it into Metron, I took an approach to reviewing it that focused on the changes. Specifically, as best I remember, I applied the following logic:

  • I pulled a copy of the version of NiFi that Otto used as a base
  • I pulled a copy of Otto's dev branch (submitted in PR METRON-777 Metron Extension System and Parser Extensions #530)
  • I observed relationships between directory paths of corresponding files (code organization relationships) in the two code sets, including filename changes (which were mostly pattern-based)
  • I applied "diff -w" to corresponding file pairs
  • I reviewed THAT as the code deltas of interest, the way we would code review a simple PR based on master
  • I also reviewed in detail the small number of newly created files, and missing/deleted files, compared to the related NiFi sources
  • I mapped my questions and remarks back to the submitted code in Otto's PR METRON-777 Metron Extension System and Parser Extensions #530, and made the usual comments in that PR
  • We interacted and followed up as usual.

After many days and some untold number of comments, responses, and changes, I felt I understood and agreed with the state of the code, and gave it a +1 here: #530 (comment) ,
contingent on the practical trials being completed.

Now, we've changed gears a bit. Faced with the difficulty of trying to review the offering all at once, whether in a PR or in a "feature branch" (turned out that wasn't much help after all), @ottobackwards and I proposed, and you'all accepted, the idea of breaking it up into five or so chunks. This was specified in my email to dev@metron.apache.org, 25 Sep 2017, Subject: Re: feature branch bumps (see http://mail-archives.apache.org/mod_mbox/metron-dev/201709.mbox/browser , Thread view, page 2, about 3/4 way down the page).

It was specifically called out that for the first chunk, consisting of just the “bundle” mechanism and the maven plugin,

"Review is acknowledged to be purely theoretical, and testing is based on the junit tests and integration tests. We’ll add a simple integration test with a synthetic test jar containing a trivial
Class, unrelated to parsers, invoked in a test case via reflection (hence needing no glue
code). After passing that level of review and testing, it would be committed, with an understanding that additional revisions might be required as the result of subsequent PR comments.

So on the one hand, we agreed to a fairly light-weight review process, since by the nature of a piece-wise submission, the first part can't be tested on parsers. I encourage you to stick with that resolve.

On the other hand, the simple integration test suggested does call for being able to see a "hello-world" Stellar command loaded and run from a bundle, which actually would be kinda exciting.

@ottobackwards , can your test bundle be turned into a Stellar function, loaded, and invoked (by reflection so you don't need to worry about registration)? That would look more like an integration test than that bundle hanging out by itself.

@nickwallen
Copy link
Contributor

@ottobackwards hopefully the Readme changes help.

The Getting Started information that you added to the README is outstanding!

@ottobackwards
Copy link
Contributor Author

@mattf-horton I have added some more documentation, and I think the bundles-testing project provides a simple, integrated example. @nickwallen and I talked it over, and he is going to try that.

@nickwallen
Copy link
Contributor

I checkout your PR and then attempt to do an install and the build fails.

$ mvn clean install
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/metron/bundles-maven-plugin/0.4.2/bundles-maven-plugin-0.4.2.pom
[WARNING] The POM for org.apache.metron:bundles-maven-plugin:jar:0.4.2 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/apache/metron/bundles-maven-plugin/0.4.2/bundles-maven-plugin-0.4.2.jar
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin org.apache.metron:bundles-maven-plugin:0.4.2 or one of its dependencies could not be resolved: Could not find artifact org.apache.metron:bundles-maven-plugin:jar:0.4.2 in central (https://repo.maven.apache.org/maven2) @
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.apache.metron:bundles-testing:0.4.2 (/Users/nallen/tmp/metron-pr774/bundles-testing/pom.xml) has 1 error
[ERROR]     Unresolveable build extension: Plugin org.apache.metron:bundles-maven-plugin:0.4.2 or one of its dependencies could not be resolved: Could not find artifact org.apache.metron:bundles-maven-plugin:jar:0.4.2 in central (https://repo.maven.apache.org/maven2) -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

I noticed that you changed the .travis build instructions so that you have to manually go into the bundles-maven-plugin project and install that first.

$ git diff origin/master -- .travis.yml
diff --git a/.travis.yml b/.travis.yml
index f5edfb27..8023830a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,6 +33,7 @@ before_install:
   - npm config set prefix $HOME/.npm-prefix --global

 install:
+  - cd bundles-maven-plugin && mvn -q install && cd ..
   - time mvn -q -T 2C -DskipTests clean install

 script:

Ideally we need to be able to just build Metron by running an install from the root directory. Is there no way around this? What troubles did you run into that caused you to have to do this?

@ottobackwards
Copy link
Contributor Author

I'm sorry nick, the instruction for 'how to build metron' from the top level readme didn't get pulled over when I did the reconstruction.

The plugin is not in any repo for maven to install from. I don't know how to get it installed since we don't publish it. I will check my list history, but I think we (not you necessarily) talked about doing it this way until we figured out if we were going to publish the plugin.

* Add a new module for your bundle, it needs only to have a pom.xml
* Create the pom.xml as above, with the correct plugin and packaging entries, and add dependencies
for the module you want to bundle.
* `mvn package`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall to test your PR, I want to do the following...

  1. Create a bundle
  2. Write some custom code in that bundle
  3. Deploy the bundle somehow and see the code in that bundle execute

I am now trying to complete step 1 and just create a bundle. Isn't there a mvn archetype:generate command that I have to run to create a bundle? Where are the docs outlining those steps? I would have expected to see them here, I think, but I don't

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getting started section of the plugin documentation tells you how to create a bundle.
The bundles-testing module is a simple result of following those instructions, with an added integration module with an example of using a bundle in code like you are looking to do.

The archetype is for creating specific types of projects that produce artifacts that may include a bundle. For example an archetype for creating a parser extension that produces an assembly with a bundle in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should say the getting started and the quick-start

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to a specific file and section? I can't find instructions in the 3 new READMEs that I see in the PR. Maybe I am just missing it somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you looking for instructions on how to create the bundles-testing project step by step?
like : create a folder. in that folder create 4 folders. create a file pom.xml.... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish you would have stated your disagreement during the community meeting, or in the email list on the 26th when you gave a +1 to this.

It is unfortunate that we again have gone months on a PR in this now year long effort to no effect, especially since as stated this was supposed to be the 'lighter' review of all the pr's.

That being said, we should not be discouraging reviews under any circumstances, and your review certainly matters.

So please. Can you explain what would would like to do based on your current understanding now that I have attempted to clarify things, and tried to describe the projects that are present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifi does not have this documented, and does not have a 'generic' archetype. @nickwallen I wonder if an archetype that just creates a simple bundle project would be useful? Would that be more of what you are looking for than the bundles-testing? Or would a written guide be the thing? Does this guide have to document how to create the multi module project? Does it have to document both existing and from scratch scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me clarify, when I say that nifi doesn't have this documented, I mean that their documentation, as mine ( though not included in this PR ) revolves around creating NARs of NiFi components, and not generic NARs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ottobackwards. Not ignoring you. I have just been busy. Will get back to this soon. Thanks for your hard work in helping me through this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem, let me know if the new doc is in line with what you are looking for

@ottobackwards
Copy link
Contributor Author

ottobackwards commented Nov 9, 2017

Bringing over this from #530,

apache/nifi@d90cf84#diff-83e1afb34470ca47809f82aa1caf2138

is the commit in nifi for the nar-utils to diff.

@ottobackwards
Copy link
Contributor Author

@nickwallen I have added a usage document in the last commit. Is this what you are looking for?

@ottobackwards
Copy link
Contributor Author

I have refactored to have a top level metron-bundles directory, with the bundles lib and bundles testing under there.

as compared to the feature branch the differences are:
- Added some modules to test loading a bundle, and executing a function
- checkstyle changes
- some minor typo fixes
@ottobackwards
Copy link
Contributor Author

I have created a new feature branch feature/METRON-1211-extensions-parsers-gradual to track this.
and have rebased this PR on to that.

I have also updated confluence and jira : https://cwiki.apache.org/confluence/display/METRON/Metron+Extension+System+and+Parser+Extensions

  1. Feature Branch still makes sense
  2. now that we are splitting it up it will work better
  3. I don't want to have to worry about regression for short periods

Will email list

@ottobackwards
Copy link
Contributor Author

The new Trusty image breaks my build. I need to figure out why exactly, so I'll be trying a few things.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants