2016-04-22 25 views
0

從閱讀關於Apache Ignite的文檔,我的印象是,我在Eclipse中使用的類(例如)會自動發送到Ignite服務器的分佈式實例。Apache Ignite:Classloader

我有3個香草服務器,沒有自定義的類加載運行(./bin/ignite.sh),都在本地主機上。他們同行非常好。

我運行一個Eclipse程序時使用了一個用於加載到緩存中的自定義類。簡單的POJO,可序列化等。

當我嘗試運行一段計算代碼時,遠程服務器抱怨類不在類加載器中。

Caused by: java.lang.ClassNotFoundException: com.company.dms.ignite.batch.model.MessageCustAccount 
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) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:348) 
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8213) 
at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185) 
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:607) 
... 29 more 

更有魔力嗎?

 ExecutorService exec = ignite.executorService(ignite.cluster().forRemotes()); 

     // Iterate through all words in the sentence and create jobs. 
     quickCounter = 10; 
     while(it.hasNext() && quickCounter-- > 0){// "Print words using runnable".split(" ")) { 
      final String word = it.next(); 
      // Execute runnable on some node. 
      String interna_cache_name = DMSIgniteHelpers.getInstance().getCurrentCacheLocation(ignite, MSG_CUST_ACCT_CACHE); 

      exec.submit(new IgniteRunnable() { 
      @Override public void run() { 
        String delimeter = "\u0001"; 
        String[] lineTokens = word.split("\\"+delimeter); 

        String three_pk = null; 
        if(lineTokens[2].toString() != null && lineTokens[4].toString() != null && lineTokens[3] != null) { 
          String sor_id = new Integer(lineTokens[2]).toString(); 
          String cust_id = new Long(lineTokens[4]).toString(); 
          String acct_id = lineTokens[3]; 
          three_pk = sor_id + cust_id + acct_id; 
          System.out.println("Looking for ("+sor_id+") ("+cust_id+") ("+acct_id+") : " + three_pk + " ----- "); 
          System.out.println("Going to query cache: " + interna_cache_name); 
          IgniteCache<Integer, MessageCustAccount> msgCustAccountCache = ignite.cache(interna_cache_name); 

          MessageCustAccount a = sqlQuery(msgCustAccountCache,three_pk); 
          System.out.println("*************=================\n\n" + a.toString() + "\[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#[email protected]#$"); 

        } 
       System.out.println(">>> Printing '" + word + "' on this node from grid job."); 
      } 
      }); 
     } 
+0

跟進,如預期,我從我的源創建的JAR文件。把它放在Ignite/gridgain的libs文件夾中,並重新執行我的代碼。所有的工作都很完美....並不感到驚訝......但我真的希望能夠在沒有這個部署步驟的情況下完成這項工作 – chrisfauerbach

回答