基本プリミタイプ タイプとオブジェクトでデルタ操作を実行しようとするとエラーが発生する
@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");
}
エラースタックトレースは次のとおりです
javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException:
cache.ROCCacheTest$$Lambda$9/1985869725 org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1618) org.apache.ignite.internal.processors.cache.IgniteCacheProxy.cacheException(IgniteCacheProxy) .java:1841) org.apache.ignite.internal.processors.cache.IgniteCacheProxy.invokeAll(IgniteCacheProxy.java:1544) で cache.ROCCache.invokeAll(ROCCache.java:129) で cache.ROCCacheTest.testDeltaOnAllListOfPojoFields(ROCCacheTest. java:529) で sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) で sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) で java.lang org.junit.runners.model.FrameworkMethod$1 の .reflect.Method.invoke(Method.java:497)。org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) で runReflectiveCall(FrameworkMethod.java:50) org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) で.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) org.springframework.test.context .junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) org.junit.runners.ParentRunner.runLeaf(ParentRunner) .java:325) 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) org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) で org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) で org.springframework.test.context. junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) org.junit.runners.ParentRunner.run(ParentRunner.java:363) 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. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) の RemoteTestRunner.runTests(RemoteTestRunner.java:675) org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:192) 原因: クラス org.apache.ignite.IgniteCheckedException: org.apache.ignite.internal.processors.cache.GridCacheIoManager の cache.ROCCacheTest$$Lambda$9/1985869725。unmarshall(GridCacheIoManager.java:1044) で org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:275) で org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager. java:204) org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:80) で org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java: 163) org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:821) で org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:103) でorg.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:784) java.util.クラスorg.apache.ignite.binary.BinaryInvalidTypeException: org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:492) で org.apache.ignite.internal.binary で cache.ROCCacheTest$$Lambda$9/1985869725 org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1443) の .BinaryContext.descriptorForTypeId(BinaryContext.java:489) org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java) :292) org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal(BinaryMarshaller.java:112) 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 以上原因: java.lang.ClassNotFoundException: cache.ROCCacheTest$$Lambda$9/1985869725 java.lang.Class.forName0(Native Method) で java.lang.Class.forName(Class.java:340) で org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8172) で org org.apache.ignite.internal.binary の .apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185)。BinaryContext.descriptorForTypeId(BinaryContext.java:483) ... 17 詳細
以前は、すべてのテストが正常に実行されていました。クライアントとサーバーのセットアップを試みた後、テストが失敗し、同じ 2 つのシステムがサーバーとして使用されている場合、または構成がサーバーのみのモードである場合にテストが失敗します。
構成は次のとおりです
<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>