colinsurprenant / redstorm

JRuby on Storm
Other
298 stars 56 forks source link

Allow adding arbitrary resources to cluster-topology.jar #109

Closed arielvalentin closed 5 years ago

arielvalentin commented 10 years ago

I would like to add arbitrary resources to the jar and load them with Guava's Resources API. I created a bolt that tries to load a resource as part of it's init block:

ruby on_init { Java::ComGoogleCommonIo::Resources.get_resource('resources/abc.txt') }


The resource is present in the jar so I can assume it will run in cluster mode:

``` bash```
[midpoint@gordon jetstream_app (develop)]$ zipinfo target/cluster-topology.jar | grep abc
-rw-r--r--  2.0 unx        0 b- defN 14-Jul-24 18:16 resources/abc.txt
-rw-r--r--  2.0 unx        0 b- defN 14-Jul-24 18:16 lib/resources/abc.txt

However when I try to run the topology in local mode:

bash

$ redstorm local topologies/sample_topology.rb

It fails with an IllegalArgumentException:

bash ERROR backtype.storm.daemon.executor - java.lang.IllegalArgumentException: resource resources/abc.txt not found. at com.google.common.base.Preconditions.checkArgument(com/google/common/base/Preconditions.java:119) ~[guava-13.0.jar:na] at com.google.common.io.Resources.getResource(com/google/common/io/Resources.java:157) ~[guava-13.0.jar:na] at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:606) ~[na:1.7.0_60] at RUBY.on_init(/home/midpoint/dev/jetstream/jetstream_app/lib/jetstream/bolts/sample_bolt.rb:11) ~[na:na] at RUBY.prepare(/home/midpoint/dev/jetstream/jetstream_app/target/lib/red_storm/dsl/bolt.rb:93) ~[na:na] at RUBY.prepare(/home/midpoint/dev/jetstream/jetstream_app/lib/core_ext/red_storm/dsl/bolt.rb:6) ~[na:na] at redstorm.storm.jruby.JRubyBolt.prepare(redstorm/storm/jruby/JRubyBolt.java:56) ~[classes/:na] at backtype.storm.daemon.executor$eval5170$fn5171$fn5183.invoke(executor.clj:689) ~[na:na] at backtype.storm.daemon.executor$eval5170$fn5171$fn5183.invoke(backtype/storm/daemon/executor.clj:689) ~[na:na] at backtype.storm.util$async_loop$fn__390.invoke(util.clj:431) ~[na:na] at backtype.storm.util$async_loop$fn__390.invoke(backtype/storm/util.clj:431) ~[na:na] at clojure.lang.AFn.run(clojure/lang/AFn.java:24) ~[clojure-1.4.0.jar:na] at java.lang.Thread.run(java/lang/Thread.java:745) ~[na:1.7.0_60]



I would also like to be able to specify where resources are installed in the JAR; e.g. most resources are at the root of the jar and not in a subdirectory named "resources"
colinsurprenant commented 10 years ago

Thanks. Yeah, supporting both jar/local contexts is a bit challenging, but I believe this should be an easy fix.