java - Apache 点燃: Classloader

标签 java eclipse classloader ignite

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

我有 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() + "\n@#$@#$@#$@#$@#$@#$@#$@#$@#$@#$@#$");

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

最佳答案

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

请参阅此示例了解如何完成此操作:https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java

关于java - Apache 点燃: Classloader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36795998/

相关文章:

java - Android:将 ArrayList 转换为 GSON 内存不足

java - 安卓 Eclipse : for each line of EditText

java - 任务 ':compileJava'的执行失败。 Gradle

使用 dexclassloader 使用外部库编译的 Android 加载类

java - Bing map 地理数据解压缩算法移植到 PHP

java - 想知道我是否正确地进行了这个不变性练习

java - 在 Kotlin 中开发的 Android 库模块在 Java 应用程序中引用,获取 : Lkotlin/jvm/internal/Intrinsics exception

java - 导入gradle项目时,Eclipse包结构被弄乱了

java - Tomcat6 似乎没有加载我的 LogFormatter 类

java - 为什么 Context ClassLoader 返回带有感叹号的路径?