You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by jinhong lu <lu...@gmail.com> on 2016/09/02 07:53:03 UTC

classpath of worker

Hi, I found this about storm worker class path:

protected String getWorkerClassPath(String stormJar, Map stormConf) {
    List<String> topoClasspath = new ArrayList<>();
    Object object = stormConf.get(Config.TOPOLOGY_CLASSPATH);

    if (object instanceof List) {
        topoClasspath.addAll((List<String>) object);
    } else if (object instanceof String) {
        topoClasspath.add((String) object);
    }
    LOG.debug("topology specific classpath is {}", object);

    String classPath = Utils.workerClasspath();
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
    return Utils.addToClasspath(classAddPath, topoClasspath);
}


According to this:
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
user’s code will be load behind storm/lib, and storm/extlib.

Is it right?
and if I want another version of jar(for example, guava.jar), how can I do that?


Thanks,
lujinhong


Re: classpath of worker

Posted by Kyle Nusbaum <kn...@yahoo-inc.com>.
This is intentional. We don't want user code to preempt any of storm's libraries. Storm shades most of the libraries it uses, so you should be able to bundle the libraries you want in with your topology jar.
For guava specifically, storm-core does not include it. You may just package it in your jar and use it.
 -- Kyle 

    On Friday, September 2, 2016 2:53 AM, jinhong lu <lu...@gmail.com> wrote:
 

 Hi, I found this about storm worker class path:

protected String getWorkerClassPath(String stormJar, Map stormConf) {
    List<String> topoClasspath = new ArrayList<>();
    Object object = stormConf.get(Config.TOPOLOGY_CLASSPATH);

    if (object instanceof List) {
        topoClasspath.addAll((List<String>) object);
    } else if (object instanceof String) {
        topoClasspath.add((String) object);
    }
    LOG.debug("topology specific classpath is {}", object);

    String classPath = Utils.workerClasspath();
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
    return Utils.addToClasspath(classAddPath, topoClasspath);
}


According to this:
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
user’s code will be load behind storm/lib, and storm/extlib.

Is it right?
and if I want another version of jar(for example, guava.jar), how can I do that?


Thanks,
lujinhong


   

Re: classpath of worker

Posted by Kyle Nusbaum <kn...@yahoo-inc.com.INVALID>.
This is intentional. We don't want user code to preempt any of storm's libraries. Storm shades most of the libraries it uses, so you should be able to bundle the libraries you want in with your topology jar.
For guava specifically, storm-core does not include it. You may just package it in your jar and use it.
 -- Kyle 

    On Friday, September 2, 2016 2:53 AM, jinhong lu <lu...@gmail.com> wrote:
 

 Hi, I found this about storm worker class path:

protected String getWorkerClassPath(String stormJar, Map stormConf) {
    List<String> topoClasspath = new ArrayList<>();
    Object object = stormConf.get(Config.TOPOLOGY_CLASSPATH);

    if (object instanceof List) {
        topoClasspath.addAll((List<String>) object);
    } else if (object instanceof String) {
        topoClasspath.add((String) object);
    }
    LOG.debug("topology specific classpath is {}", object);

    String classPath = Utils.workerClasspath();
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
    return Utils.addToClasspath(classAddPath, topoClasspath);
}


According to this:
    String classAddPath = Utils.addToClasspath(classPath, Arrays.asList(stormJar));
user’s code will be load behind storm/lib, and storm/extlib.

Is it right?
and if I want another version of jar(for example, guava.jar), how can I do that?


Thanks,
lujinhong