Github user chinmaykolhatkar commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/208#discussion_r51119455
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/StramLocalCluster.java 
---
    @@ -318,6 +333,21 @@ public StramLocalCluster(LogicalPlan dag) throws 
IOException, ClassNotFoundExcep
         }
       }
     
    +  private void addExtraJarsToClasspath(Set<String> jars)
    +      throws InvocationTargetException, IllegalAccessException, 
MalformedURLException, NoSuchMethodException
    +  {
    +    List<URL> jarUrls = new LinkedList<>();
    +    for (String jarPath : jars) {
    +      File file = new File(jarPath);
    +      URL url = file.toURI().toURL();
    +      jarUrls.add(url);
    +    }
    +
    +    ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
    +    ClassLoader urlCl = URLClassLoader.newInstance(jarUrls.toArray(new 
URL[jarUrls.size()]), prevCl);
    +    Thread.currentThread().setContextClassLoader(urlCl);
    --- End diff --
    
    Thomas can answer this question better. But here is additional information 
as per my understanding:
    The place where Constructor of StramLocalCluster is called is a common 
point where both code paths joins.
    
    But there is a slight difference in how the operators are loaded by these 2 
paths.
    
    In LocalMode.runApp, the operator classes are already part of the System 
class loader. This is because when ApplicationTest is launched the operators 
are already in classpath provided by maven.
    
    StreamAppLauncher.runLocal is invoked by an application launched from dtcli 
(a java process). dtcli do not have operators present in its system classpath.
    
    Hence, in StramAppLauncher.runLocal (dtcli -local), there is a context 
class loader created which has information about operator classes. This context 
classloader is later used to load the operator classes.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to