You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by nickwallen <gi...@git.apache.org> on 2018/12/01 13:30:12 UTC

[GitHub] metron pull request #1288: METRON-1916 Stellar Classpath Function Resolver S...

GitHub user nickwallen opened a pull request:

    https://github.com/apache/metron/pull/1288

    METRON-1916 Stellar Classpath Function Resolver Should Handle ClassNotFoundException

    Stellar can be executed in an environment where not all of the dependencies are available for each of the functions available on the classpath. When this happens, the classpath resolver blows-up even if you do not use the function that is missing dependencies.
    
    For example this exception is thrown when not all of the dependencies are available for the new REST function.  I was only attempting to use STATS_INIT, not the REST function.
    ```
    2018-11-30 15:47:00 DEBUG BaseFunctionResolver:165 - Resolving Stellar function in class RestFunctions.RestGet
    2018-11-30 15:47:00 ERROR DefaultProfileBuilder:302 - Bad 'init' expression: error='Unable to parse: STATS_INIT() due to: org/apache/http/conn/HttpClientConnectionManager', expr='STATS_INIT()', profile='profile-with-stats', entity='global', variables-available='[adapter.threatinteladapter.end.ts, bro_timestamp, ip_dst_port, enrichmentsplitterbolt.splitter.end.ts, enrichmentsplitterbolt.splitter.begin.ts, adapter.hostfromjsonlistadapter.end.ts, adapter.geoadapter.begin.ts, uid, trans_depth, protocol, original_string, ip_dst_addr, threatinteljoinbolt.joiner.ts, host, enrichmentjoinbolt.joiner.ts, adapter.hostfromjsonlistadapter.begin.ts, threatintelsplitterbolt.splitter.begin.ts, ip_src_addr, user_agent, timestamp, method, request_body_len, uri, tags, source.type, adapter.geoadapter.end.ts, referrer, threatintelsplitterbolt.splitter.end.ts, adapter.threatinteladapter.begin.ts, ip_src_port, guid, response_body_len]'
    org.apache.metron.stellar.dsl.ParseException: Unable to parse: STATS_INIT() due to: org/apache/http/conn/HttpClientConnectionManager
    at org.apache.metron.stellar.common.BaseStellarProcessor.createException(BaseStellarProcessor.java:166)
    at org.apache.metron.stellar.common.BaseStellarProcessor.parse(BaseStellarProcessor.java:154)
    at org.apache.metron.stellar.common.DefaultStellarStatefulExecutor.execute(DefaultStellarStatefulExecutor.java:160)
    at org.apache.metron.stellar.common.DefaultStellarStatefulExecutor.assign(DefaultStellarStatefulExecutor.java:95)
    at org.apache.metron.profiler.DefaultProfileBuilder.assign(DefaultProfileBuilder.java:291)
    at org.apache.metron.profiler.DefaultProfileBuilder.apply(DefaultProfileBuilder.java:136)
    at org.apache.metron.profiler.DefaultMessageDistributor.distribute(DefaultMessageDistributor.java:177)
    at org.apache.metron.profiler.storm.ProfileBuilderBolt.handleMessage(ProfileBuilderBolt.java:411)
    at org.apache.metron.profiler.storm.ProfileBuilderBolt.execute(ProfileBuilderBolt.java:337)
    at org.apache.storm.topology.WindowedBoltExecutor$1.onActivation(WindowedBoltExecutor.java:307)
    at org.apache.storm.windowing.WindowManager.onTrigger(WindowManager.java:145)
    at org.apache.storm.windowing.WatermarkTimeTriggerPolicy.handleWaterMarkEvent(WatermarkTimeTriggerPolicy.java:80)
    at org.apache.storm.windowing.WatermarkTimeTriggerPolicy.track(WatermarkTimeTriggerPolicy.java:48)
    at org.apache.storm.windowing.WindowManager.track(WindowManager.java:177)
    at org.apache.storm.windowing.WindowManager.add(WindowManager.java:110)
    at org.apache.storm.windowing.WaterMarkEventGenerator.run(WaterMarkEventGenerator.java:80)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructor0(Class.java:3075)
    at java.lang.Class.getConstructor(Class.java:1825)
    at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.createFunction(BaseFunctionResolver.java:240)
    at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.resolveFunction(BaseFunctionResolver.java:194)
    at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.resolveFunctions(BaseFunctionResolver.java:166)
    at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:109)
    at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.apply(BaseFunctionResolver.java:149)
    at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.apply(BaseFunctionResolver.java:49)
    at org.apache.metron.stellar.common.StellarCompiler.resolveFunction(StellarCompiler.java:688)
    at org.apache.metron.stellar.common.StellarCompiler.lambda$exitTransformationFunc$13(StellarCompiler.java:656)
    at org.apache.metron.stellar.common.StellarCompiler$Expression.apply(StellarCompiler.java:259)
    at org.apache.metron.stellar.common.BaseStellarProcessor.parse(BaseStellarProcessor.java:151)
    ... 21 more
    ```
    
    When this happens the Classpath Function Resolver should allow me to use whichever functions can be loaded correctly.  With this change the following error message is logged and execution is allowed to continue.
    ```
    2018-12-01 08:22:42 ERROR BaseFunctionResolver:243 - Unable to load org.apache.metron.stellar.dsl.functions.RestFunctions$RestGet because org/apache/http/conn/HttpClientConnectionManager
    java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    	at java.lang.Class.getConstructor0(Class.java:3075)
    	at java.lang.Class.getConstructor(Class.java:1825)
    	at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.createFunction(BaseFunctionResolver.java:239)
    	at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.resolveFunction(BaseFunctionResolver.java:193)
    	at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.resolveFunctions(BaseFunctionResolver.java:165)
    	at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:109)
    	at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.apply(BaseFunctionResolver.java:149)
    	at org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.apply(BaseFunctionResolver.java:49)
    	at org.apache.metron.stellar.common.StellarCompiler.resolveFunction(StellarCompiler.java:688)
    	at org.apache.metron.stellar.common.StellarCompiler.lambda$exitTransformationFunc$13(StellarCompiler.java:656)
    	at org.apache.metron.stellar.common.StellarCompiler$Expression.apply(StellarCompiler.java:259)
    	at org.apache.metron.stellar.common.BaseStellarProcessor.parse(BaseStellarProcessor.java:151)
    	at org.apache.metron.stellar.common.DefaultStellarStatefulExecutor.execute(DefaultStellarStatefulExecutor.java:160)
    	at org.apache.metron.stellar.common.DefaultStellarStatefulExecutor.assign(DefaultStellarStatefulExecutor.java:95)
    	at org.apache.metron.profiler.DefaultProfileBuilder.assign(DefaultProfileBuilder.java:291)
    	at org.apache.metron.profiler.DefaultProfileBuilder.apply(DefaultProfileBuilder.java:136)
    	at org.apache.metron.profiler.DefaultMessageDistributor.distribute(DefaultMessageDistributor.java:177)
    	at org.apache.metron.profiler.storm.ProfileBuilderBolt.handleMessage(ProfileBuilderBolt.java:411)
    	at org.apache.metron.profiler.storm.ProfileBuilderBolt.execute(ProfileBuilderBolt.java:337)
    	at org.apache.storm.topology.WindowedBoltExecutor$1.onActivation(WindowedBoltExecutor.java:307)
    	at org.apache.storm.windowing.WindowManager.onTrigger(WindowManager.java:145)
    	at org.apache.storm.windowing.WatermarkTimeTriggerPolicy.handleWaterMarkEvent(WatermarkTimeTriggerPolicy.java:80)
    	at org.apache.storm.windowing.WatermarkTimeTriggerPolicy.track(WatermarkTimeTriggerPolicy.java:48)
    	at org.apache.storm.windowing.WindowManager.track(WindowManager.java:177)
    	at org.apache.storm.windowing.WindowManager.add(WindowManager.java:110)
    	at org.apache.storm.windowing.WaterMarkEventGenerator.run(WaterMarkEventGenerator.java:80)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    	... 35 more
    ```
    
    ## 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).
    - [ ] 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)?
    
    
    ### 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:
      ```
      mvn -q clean integration-test install && dev-utilities/build-utils/verify_licenses.sh 
      ```
    
    - [ ] 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](http://www.apache.org/legal/resolved.html#category-a)?
    - [ ] 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`:
    
      ```
      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/nickwallen/metron METRON-1916

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/1288.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 #1288
    
----
commit 63d9c39f6a90aaf1ccc7cab436e9f8bfc1f246c8
Author: Nick Allen <ni...@...>
Date:   2018-12-01T13:24:15Z

    METRON-1916 Stellar Classpath Function Resolver Should Handle ClassNotFoundException

----


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    Can we step back?  What dependencies where not present?  That may be the real issue for the users.


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    @cestella should check in on this


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    > In my mind we don't have a current state where Stellar is running but not all the functions in the class path are loaded. 
    
    The same thing would happen today if an `Exception` is thrown in any of the functions being loaded.  If an Exception is thrown, instead of N functions ready-to-rock, we would have N-1 functions.  This just expands that behavior to `ClassNotFoundException` which gets thrown when there is a missing dependency..
    
    > Before we would have crashed starting up. Now we will run and crash get an error later.
    
    I don't see it that way.  Let's look at both scenarios.
    * If I am NOT using the REST function, then things just work as they should.  Yay!   I don't want to worry about the missing dependency for a function that I have no knowledge about.
    * If I am using the REST function, an exception would still be thrown when the function definition could not be found.  So the user still gets an exception when there is a problem.
    
    (Q) Any thoughts on alternative approaches?
    
    I prefer not to have to worry about classpath dependencies (like those required by the REST function) that I am not using.  In this example, I was only trying to use the `STATS_*` functions, but it was the REST function that blew things up for me.  It is difficult for a user to track this down, because they have no knowledge of the REST function and its dependencies.
    
    (Alternative 1) An alternative approach would be to be more selective about what functions we add to `stellar-common`.  Anything added to `stellar-common` forces a required dependency on all Stellar users.  If the REST function had been a separate project, then a user could choose to use or not use that projects and not be burdened by the additional dependency
    
    (Alternative 2) Could the `stellar.function.resolver.includes` and `stellar.function.resolver.excludes` be enhanced to allow users to exclude functions they don't want to load?
    



---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    It was when I was working on #1289  .  After changing the POM, I found that multiple versions of httpclient were getting pulled in, which broke all the integration tests because a Stellar executor could not load.  It would throw the exception that I put in the JIRA.
    
    This is one specific scenario, but I can imagine that classpath issues like this are going to crop-up in different environments.  It seems like we should have a way to handle this.


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    So, my main concern here is the state of stellar _after_ loading in this condition.  What happens if you call a function that failed to load?  What happens if it is nested in a match or a lambda?
    
    Right now, it blows up, but when loaded everything is known to be 'ok'.  So this introduces a new state where we are loaded, but things that were supposed to load ( stellar functions introduced to the class path ) have failed.
    
    I'm not sure this is that simple.  Would we _ever_ for example accept this state in the topology?


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    In my mind we don't have a current state where Stellar is running but not all the functions in the class path are loaded.   This is different.  Before we would have crashed starting up.  Now we will run and crash later.


---

[GitHub] metron issue #1288: METRON-1916 Stellar Classpath Function Resolver Should H...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on the issue:

    https://github.com/apache/metron/pull/1288
  
    There is just one less function available on the close when this happens.  This is not something new unknown state.


---