首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache Ignite: Classloader

Apache Ignite: Classloader
EN

Stack Overflow用户
提问于 2016-04-22 22:06:23
回答 1查看 852关注 0票数 1

通过阅读Apache Ignite的文档,我得到的印象是,我在Eclipse中使用的类(例如)将自动(我敢说,神奇地?)发送到Ignite服务器的分布式实例。

我有3个普通的服务器,没有加载的自定义类运行(./bin/ignite.sh),所有这些都在本地主机上。他们目光投射得很好。

我使用一个定制类运行一个Eclipse程序,用于加载到缓存中。简单的POJO、可串行化等。

当我试图运行一段计算代码时,远程服务器抱怨类不在类加载器中。

代码语言:javascript
复制
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

还有更多的魔力吗?

代码语言:javascript
复制
        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() + "\n@#$@#$@#$@#$@#$@#$@#$@#$@#$@#$@#$");

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

回答 1

Stack Overflow用户

发布于 2016-04-23 05:06:32

模型类不是对等部署的,但是你可以在缓存和查询BinaryObject上使用withKeepBinary()标志,这样就避免了服务器端的反序列化,也不会得到ClassNotFoundException

有关如何做到这一点,请参考以下示例:https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36795998

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档