0
votes

Getting an error while trying to perform a delta operation on basic primitype type as well as on Objects

    @Test
  public void TestDeltaOnField() {

    String name = "SreeHari";
    ROCCacheConfiguration<String, String> rc1 = new ROCCacheConfiguration<>();
    rc1.setName("seventhCache");
    ROCCache<String, String> r1 = rocCachemanager.createCache(rc1);

    r1.put("a", name);
    assertEquals(r1.get("a"), "SreeHari");
    rocCachemanager.withKeepBinary(r1.getName()).invoke("a", (entry, args) -> {

      String a = (String) entry.getValue();

      entry.setValue(a = "Hari");

      return null;
    });
    assertEquals(r1.get("a"), "Hari");
    r1.replace("a", "Hari", "Hari1");
    assertEquals(r1.get("a"), "Hari1");
    rocCachemanager.destroyCache("seventhCache");

  }



     @Test
      public void TestDeltaOnPojoFields() {

    TestPojo t1 = new TestPojo(1, "SreeHari1");

    TestPojo t2 = new TestPojo(2, "Hari1");

    TestPojo t3 = new TestPojo(3, "SreeHari2");

     TestPojo t4 = new TestPojo(4, "Hari2");

        TestPojo t5 = new TestPojo(5, "SreeHari3");
        TestPojo t6 = new TestPojo(6, "Hari3");
        TestPojo t7 = new TestPojo(7, "SreeHari4");
        TestPojo t8 = new TestPojo(8, "Hari4");

    ROCCacheConfiguration<String, TestPojo> rc1 = new ROCCacheConfiguration<>();
    rc1.setName("eighthCache");
    ROCCache<String, TestPojo> r1 = rocCachemanager.createCache(rc1);

    r1.put("a", t1);
    r1.put("b", t2);
    r1.put("c", t3);
    r1.put("d", t4);
    assertEquals(r1.get("a").getName(), "SreeHari1");

    rocCachemanager.withKeepBinary(r1.getName()).invoke("a", (entry, args) -> {

      BinaryObjectBuilder bldr = ((BinaryObject) entry.getValue()).toBuilder();

      // Update the field in the builder.
      bldr.setField("name", "SreeHari3");

      int val = bldr.getField("id");
      bldr.setField("id", val + 1);
      // Set new value to the entry.
      entry.setValue(bldr.build());

      return null;
    });

    assertEquals(r1.get("a").getName(), "SreeHari3");
    assertEquals(r1.get("a").getId(), 2);
    rocCachemanager.destroyCache("eighthCache");
  }



     @Test
      public void TestDeltaOnAllPojoFields() {

    Set<String> key = new HashSet<String>();

     key.add("a");

      key.add("b");

       key.add("c");

       key.add("d");

     TestPojo t1 = new TestPojo(1, "SreeHari1");

       TestPojo t2 = new TestPojo(2, "Hari1");

        TestPojo t3 = new TestPojo(3, "SreeHari2");

      TestPojo t4 = new TestPojo(4, "Hari2");
    ROCCacheConfiguration<String, TestPojo> rc1 = new ROCCacheConfiguration<>();
    rc1.setName("ninethCache");
    ROCCache<String, TestPojo> r1 = rocCachemanager.createCache(rc1);

    r1.put("a", t1);
    r1.put("b", t2);
    r1.put("c", t3);
    r1.put("d", t4);
    assertEquals(r1.get("a").getName(), "SreeHari1");
    rocCachemanager.withKeepBinary(r1.getName()).invokeAll(key, (entry, args) -> {

      BinaryObjectBuilder bldr = ((BinaryObject) entry.getValue()).toBuilder();

      // Update the field in the builder.
      bldr.setField("name", "SreeHari3");

      // Set new value to the entry.
      entry.setValue(bldr.build());

      return null;
    });

    assertEquals(r1.get("b").getName(), "SreeHari3");
    rocCachemanager.destroyCache("eigthCache");

    r1.replace("b", t1);
    assertEquals(r1.get("b").getName(), "SreeHari1");
    rocCachemanager.destroyCache("nineththCache");

  }

  @Test
  public void testDeltaOnAllListOfPojoFields() {

    Set<String> key = new HashSet<String>();
    key.add("a");
    key.add("b");
    key.add("c");
    key.add("d");
    TestPojo t1 = new TestPojo(1, "SreeHari1");
    TestPojo t2 = new TestPojo(2, "Hari1");
    TestPojo t3 = new TestPojo(3, "SreeHari2");
    TestPojo t4 = new TestPojo(4, "Hari2");
    TestPojo t5 = new TestPojo(5, "SreeHari3");
    TestPojo t6 = new TestPojo(6, "Hari3");
    TestPojo t7 = new TestPojo(7, "SreeHari4");
    TestPojo t8 = new TestPojo(8, "Hari4");


    List<TestPojo> listob1 = new ArrayList<TestPojo>();
    listob1.add(t1);
    listob1.add(t2);
    List<TestPojo> listob2 = new ArrayList<TestPojo>();
    listob2.add(t3);
    listob2.add(t4);
    List<TestPojo> listob3 = new ArrayList<TestPojo>();
    listob3.add(t5);
    listob3.add(t6);
    List<TestPojo> listob4 = new ArrayList<TestPojo>();
    listob4.add(t7);
    listob4.add(t8);

    Map<String, List<TestPojo>> igMap = new HashMap<String, List<TestPojo>>();
    igMap.put("a", listob1);
    igMap.put("b", listob2);
    igMap.put("c", listob3);
    igMap.put("d", listob4);

    ROCCacheConfiguration<String, List<TestPojo>> rc1 = new ROCCacheConfiguration<>();
    rc1.setName("tenthCache");
    ROCCache<String, List<TestPojo>> r1 = (ROCCache<String, List<TestPojo>>) rocCachemanager.createCache(rc1);
    r1.putAll(igMap);
    rocCachemanager.withKeepBinary(r1.getName()).invokeAll(key, (entry, args) -> {



      BinaryObjectBuilder bldr = ((BinaryObject) entry.getValue()).toBuilder();

      // Update the field in the builder.
      bldr.setField("name", "SreeHari3");

      // Set new value to the entry.
      entry.setValue(bldr.build());

      return null;
    });

    assertEquals(r1.getAll(key).get("a").get(0).getName(), "SreeHari1");
    rocCachemanager.destroyCache("tenthCache");

  }

Error Stack trace is as follows

javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException:

cache.ROCCacheTest$$Lambda$9/1985869725 at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1618) at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy.java:1841) at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.invokeAll(IgniteCacheProxy.java:1544) at cache.ROCCache.invokeAll(ROCCache.java:129) at cache.ROCCacheTest.testDeltaOnAllListOfPojoFields(ROCCacheTest.java:529) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: class org.apache.ignite.IgniteCheckedException: cache.ROCCacheTest$$Lambda$9/1985869725 at org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1044) at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:275) at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:204) at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:80) at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:163) at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:821) at org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:103) at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:784) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: cache.ROCCacheTest$$Lambda$9/1985869725 at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:492) at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:489) at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1443) at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:292) at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal(BinaryMarshaller.java:112) at org.apache.ignite.internal.processors.cache.GridCacheMessage.unmarshalCollection(GridCacheMessage.java:606) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest.finishUnmarshal(GridNearAtomicUpdateRequest.java:621) at org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1038) ... 10 more Caused by: java.lang.ClassNotFoundException: cache.ROCCacheTest$$Lambda$9/1985869725 at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:340) at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8172) at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185) at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:483) ... 17 more

Earlier all the tests were running fine. After trying to having a client and server setup the tests are failing , and now the tests are failing when the same two systems are used as servers or when the config is in server only mode.

Config is as follows

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">

    <!-- Datasource for sample in-memory H2 database. -->
    <bean id="h2-example-db" class="org.h2.jdbcx.JdbcDataSource">
        <property name="URL" value="jdbc:h2:tcp://localhost/mem:ExampleDb" />
        <property name="user" value="sa" />
    </bean>

    <bean abstract="true" id="ignite.cfg"
        class="org.apache.ignite.configuration.IgniteConfiguration">
        <!-- Set to true to enable distributed class loading for examples, default 
            is false. -->
        <property name="peerClassLoadingEnabled" value="false" />

        <!-- Enable task execution events for examples. -->
        <property name="includeEventTypes">
            <list>
                <!--Task execution events -->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED" />
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET" />
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED" />

                <!--Cache events -->
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" />
            </list>
        </property>

        <!-- Explicitly configure TCP discovery SPI to provide list of initial 
            nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="joinTimeout" value="60000" />
                <property name="ipFinder">
                    <!-- Ignite provides several options for automatic discovery that can 
                        be used instead os static IP based discovery. For information on all options 
                        refer to our documentation: http://apacheignite.readme.io/docs/cluster-config -->
                    <!-- Uncomment static IP finder to enable static-based discovery of 
                        initial nodes. -->
                    <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> -->
                    <bean
                        class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <!-- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> -->
                        <property name="addresses">
                            <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <value>10.113.56.231:47500..47509</value>
                                <value>10.113.56.110:47500..47509</value>

                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
        <!-- property name="marshaller"> <bean class="com.esotericsoftware.kryo.serializers.DefaultSerializers"> 
            <property name="requireSerializable" value="false" /> </bean> </property -->

        <!--property name="binaryConfiguration"> <bean class="org.apache.ignite.configuration.BinaryConfiguration"> 
            <property name="typeConfigurations"> <list> <bean class="org.apache.ignite.binary.BinaryTypeConfiguration"> 
            <property name="typeName" value="testPojo" /> <property name="serializer"> 
            <bean class="com.esotericsoftware.kryo.serializers.DefaultSerializers" /> 
            </property> </bean> </list> </property> </bean> </property -->
    </bean>
</beans>
1
For the above question when i killed the server process and started the ignite in embedded mode , all the tests passed.If i am trying to run a Delta operation on a cached object in client server mode , the test is failing. - Abhishek Shenoy

1 Answers

1
votes

Looks like there are nodes in topology that don't have all required classes on classpath. In your case you have to deploy the class that declares the entry processor lambda.

Another option is to switch on peer class loading:

<property name="peerClassLoadingEnabled" value="true"/>